Example of Multiple Rules, Rule Sets, and Relationships
Suppose you have a need to configure rules against multiple products and multiple relationships. Consider the following example:
Product 1
|
Product 2
|
Product 3
|
Organization
|
Two rule sets:
• Affected objects (checkout rule)
• Resulting objects (checkout rule and part attribute rule—name must be less than 10)
|
One rule set:
• Resulting objects (part attribute rule—name must be start with EXT)
|
No rules or rule sets
|
One rule set:
• Change notice rule—name must start with CN
|
After all the rules are created, you could configure the workflow to use these rule sets by using code such as the following:
com.ptc.core.businessRules.engine.BusinessRuleSetBean[] ruleSetBeans = new
com.ptc.core.businessRules.engine.BusinessRuleSetBean[] {
com.ptc.core.businessRules.engine.BusinessRuleSetBean.
newBusinessRuleSetBean ("CNOrgRuleSet", com.ptc.core.businessRules.engine.
BusinessRuleSetBean.PRIMARY_BUSINESS_OBJECT),
com.ptc.core.businessRules.engine.BusinessRuleSetBean.
newBusinessRuleSetBean("AffectedPartProdRuleSet", wt.change2.
AffectedActivityData.class.getName()),
com.ptc.core.businessRules.engine.BusinessRuleSetBean.newBusinessRuleSetBean
("ResultingPartProdRuleSet", wt.change2.ChangeRecord2.class.getName())
};
businessRulesResultSetGlobal = "";
preReleaseConflictsMsg = "";
com.ptc.core.businessRules.validation.RuleValidationResultSet
resultSet = wt.businessRules.BusinessRulesHelper.engine.execute
(primaryBusinessObject, ruleSetBeans );
Examples:
• If you had a part in Product 1 that was a resulting object, the part would have to have a part name less than 10 characters, and it could not be checked out.
• If you had a document in Product 2 that was a resulting object, then there are no rules for it because there are only rules for parts.