Use Case 2: Creating Custom Business Rules
1. The business rule name and description attributes are supported for localization. To have a localized name and description, create JAVA resource file to define the names and descriptions 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 ";
}
* 
For information, see the following updates:
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 rules. It typically holds the rules that are 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 - AObjectToObjectbinary link holding the references toBusinessRuleSetand 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 an 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 the load file created in the previous step in the 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 an entry for this load file in /configurations/deploy.xml.
Following is an example of deploy.xml :
<deploy>
<loadFileSet>custom/customLoader.xml</loadFileSet>
</deploy>
7. Specify module name in the descriptor.xml file within your module.
Following is an example of descriptor.xml:
<module>
<name>BusinessRulesPkg</name>
</module>
The final package structure for adding BusinessRules will look like this:
<customizationRootDirectory>
└── BusinessRules
├── descriptor.xml
└── main
├── src
│ └── com
│ ├── org
│ └── change2ClientResource.java
├── configurations
│ ├── deploy.xml
│ ├── loadFiles
│ │ └── custom
│ │ ├── ixbImport
│ │ └── customLoader.xml
│ │ └── BusinessRulesLoader.xml
│ │ └── BusinessRuleObjects.zip
Was this helpful?