Use Case 2: Creating Custom Business Rules
1. The Business Rule name and description attributes are supported for localization. If you wish to have localized name and description, then you must create java resource file to define the name and description of Business Rules. Following is an example of change2ClientResource.java :
package com.org;
import wt.util.resource.RBComment;
import wt.util.resource.RBEntry;
import wt.util.resource.RBUUID;
import wt.util.resource.WTListResourceBundle;
@RBUUID("com.org. change2ClientResource")
public final class change2ClientResource extends WTListResourceBundle {
@RBEntry("Change Business Rule")
@RBComment("Name of Business Rule")
public static final String CHANGE_PRE_RELEASE_RULESET_NAME = "
CHANGE_PRE_RELEASE_RULESET_NAME ";
@RBEntry("This rule determines if there are objects INWORK state")
@RBComment("Description for S CHANGE_PRE_RELEASE_RULESET_NAME ")
public static final String CHECK_OUT_VALIDATOR_RULE_DESC = "
CHECK_OUT_VALIDATOR_RULE_DESC ";
}
2. Create an IXB load XML file.
Following are the business rule objects that use IXB load files :
a. BusinessRule.xml – A BusinessRule object holds the information about the Rule to be executed. Each Rule may have unique configuration requirements associated to it. A key and the container should be unique for creating BusinessRule objects.
Following is an example of BusinessRule.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE BusinessRule SYSTEM "standardX24.dtd">
<BusinessRule>
<ObjectID><localId>wt.businessRules.BusinessRule:45346</localId>
</ObjectID>
<objectContainerPath>/</objectContainerPath>
<key>IXBBusinessRule1_key</key>
<name>com.org.change2ClientResource:CHECK_OUT_VALIDATOR_RULE_NAME</name>
<description>
com.org.change2ClientResource:CHECK_OUT_VALIDATOR_RULE_DESC</description>
<enabled>true</enabled>
<configs>
<config name="key1" value="value1"></config>
<config name="key2" value="value1"></config>
<config name="key1" value="value2"></config>
</configs>
</BusinessRule>
b. BusinessRuleSet.xml - A BusinessRuleSet instance is the persistence configuration of a set of Validation Rule. Typically holds the rules configured to be executed for the container. A key and the container should be unique for creating BusinessRuleSet objects.
Following is an example of BusinessRuleSet.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE BusinessRuleSet SYSTEM "standardX24.dtd">
<BusinessRuleSet>
<ObjectID><localId>wt.businessRules.BusinessRuleSet:45345</localId>
</ObjectID>
<objectContainerPath>
/wt.inf.container.OrgContainer=PTC/wt.pdmlink.PDMLinkProduct=GOLF_CART
</objectContainerPath>
<key>IXBBusinessRuleSet1_key</key>
<name>com.org.change2ClientResource:CHANGE_PRE_RELEASE_RULESET_NAME</name>
<description>
com.org.change2ClientResource:CHANGE_PRE_RELEASE_RULESET_DESC</description>
<enabled>true</enabled>
<overridable>true</overridable>
</BusinessRuleSet>
c. StateLink.xml - A ObjectToObject binary link holding the references to BusinessRuleSet and Rules.
Following is an example of StateLink.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE BusinessRuleLink SYSTEM "standardX24.dtd">
<BusinessRuleLink>
<ObjectID><localId>wt.businessRules.BusinessRuleLink:356747
</localId></ObjectID>
<ruleSet><ObjectReference>
<localId>wt.businessRules.BusinessRuleSet:45345
</localId>
</ObjectReference></ruleSet>
<rule><ObjectReference>
<localId>wt.businessRules.BusinessRule:45346
</localId>
</ObjectReference></rule>
<blockNumber>10</blockNumber>
</BusinessRuleLink>
3. Add the load files to a zip file. For example, add the above files in a zip file such as /configurations/loadFiles/custom/ixbImport/BusinessRuleObjects.zip
4. Create the XML load file to load the generated zip file created in step 2 and copy it in /configurations/loadFiles/custom/BusinessRulesLoader.xml
Following is an example of BusinessRuleLoader.xml :
<?xml version="1.0"?>
<!DOCTYPE NmLoader SYSTEM "standardX24.dtd">
<NmLoader>
<csvExecuteImport handler="wt.load.LoadImport.executeImport">
<csvimportFilename>loadFiles/custom/ixbImport/BusinessRuleObjects.zip
</csvimportFilename>
</csvExecuteImport>
</NmLoader>
5. Create customLoader.xml to load above created loader file in desired container.
Following is an example of BusinessRulesLoader.xml added in customLoader.xml :
<?xml version="1.0"?>
<!DOCTYPE loadFileList SYSTEM "/wt/load/windchillLoad.dtd">
<loadFileList containerPath="/">
<loadFile title="Load custom Business Rules" localized="true" ...
filename="custom/ BusinessRulesLoader.xml"/>
</loadFileList>
6. Add entry of this load file in /configurations/deploy.xml.
Following is an example of deploy.xml :
<deploy>
<loadFileSet>custom/customLoader.xml</loadFileSet>
</deploy>
7. Name your module in the descriptor.xml file.
Following is an example of descriptor.xml :
<module>
<name>BusinessRulesPkg</name>
</module>
Final Package structure for adding BusinessRules will look like
Customization
\---BusinessRules
\---main
\---src
\---com
\---org
\---change2ClientResource.java
| descriptor.xml
\---configurations
\---loadFiles
\---custom
\--- ixbImport
| BusinessRuleObjects.zip
| BusinessRulesLoader.xml
| customLoader.xml
| deploy.xml
Parent topic