高级自定义 > 业务逻辑自定义 > 业务规则 > 业务规则配置和执行 > 示例代码
  
示例代码
以下是已交付更改通告工作流模板中工作流条件语法的示例。工作流条件将调用业务规则引擎的 CHANGEABLE_PRE_RELEASE 业务规则集。CHANGEABLE_PRE_RELEASE 业务规则包含 CHECKOUT_RULERELEASE_TARGET 业务规则。
路由表达式
result = "NOT_READY";
com.ptc.core.businessRules.engine.BusinessRuleSetBean[] ruleSetBeans =
new com.ptc.core.businessRules.engine.BusinessRuleSetBean[] {
com.ptc.core.businessRules.engine.BusinessRuleSetBean.
newBusinessRuleSetBean("CHANGEABLE_PRE_RELEASE", "wt.change2.ChangeRecord2")
};
//Invoke the business rule engine
com.ptc.core.businessRules.validation.RuleValidationResultSet resultSet =
wt.businessRules.BusinessRulesHelper.engine.execute(primaryBusinessObject,
ruleSetBeans);
if ( !resultSet.hasResultsByStatus(com.ptc.core.businessRules.validation.
RuleValidationStatus.FAILURE)) {
result = "PROCEED";
}
else {
//This line of code will start exception handling for the business
rules that failed
businessRulesResultSetGlobal = wt.businessRules.BusinessRulesHelper.
serialize(resultSet);
preReleaseConflictsMsg = new wt.util.WTMessage("com.ptc.windchill.
enterprise.change2.change2ClientResource", com.ptc.windchill.enterprise.
change2.change2ClientResource.BUSINESS_RULES_PRERELEASE_VALIDATION_MSG,
null).getLocalizedMessage();
preReleaseConflictsMsg = preReleaseConflictsMsg + "\n" + resultSet.
getFailedRulesMessage(java.util.Locale.getDefault());
}
请注意,如果验证结果不成功,则系统会将 businessRulesResultSetGlobal 属性设置为验证结果集的序列化字符串。“查看冲突”报告链接将显示在“审计更改通告”和“解决发布冲突”工作流任务页面上。