高级自定义 > 业务逻辑自定义 > 业务规则 > 业务规则类型 > 属性规则 > 示例
  
示例
假设有一个特定部件可变类型,且为其设置了名为 weight 的属性来表示部件的重量。释放带有重量的部件前,要确保将部件的重量设置为合理的值。为此,您需要构建业务规则以验证重量属性在 1-100 范围内。
实现属性规则的业务规则集
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE BusinessRuleSet SYSTEM "standardX20.dtd">
<BusinessRuleSet>
<ObjectID><localId>wt.businessRules.BusinessRuleSet:45347
</localId></ObjectID>
<objectContainerPath>/wt.inf.container.
OrgContainer=BusinessRulesTestOrganization
/wt.pdmlink.PDMLinkProduct=BusinessRulesTestProduct
</objectContainerPath>
<key>CHANGEABLE_PRE_RELEASE</key>
<name>Test_Changeable_ReleaseRuleSet</name>
<description>To test basic Attribute RuleSet Validation
</description>
<enabled>true</enabled>
<overridable>true</overridable>
<updateIfExists>true</updateIfExists>
</BusinessRuleSet>
实现属性规则的业务规则
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE BusinessRule SYSTEM "standardX20.dtd">
<BusinessRule>
<ObjectID><localId>wt.businessRules.BusinessRule:
168926</localId></ObjectID>
<objectContainerPath>/wt.inf.container.OrgContainer
=BusinessRulesTestOrganization/
wt.pdmlink.PDMLinkProduct=BusinessRulesTestProduct
</objectContainerPath>
<key>PART_ATTRIBUTE_RULE</key>
<selector>ATTRIBUTE_RULE</selector>
<name>Test Attribute Rule</name>
<description>Test Attribute Rule</description>
<enabled>true</enabled>
<updateIfExists>true</updateIfExists>
<configs>
<config name="objectType"
value="wt.part.AttributeRulePart"></config>
<config name="weight" value="[0..100]"></config>
</configs>
</BusinessRule>
实现属性规则的业务规则链接
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE BusinessRuleLink SYSTEM "standardX20.dtd">
<BusinessRuleLink>
<ObjectID><localId>wt.businessRules.BusinessRuleLink:168919
</localId></ObjectID>
<ruleSet><ObjectReference><localId>wt.businessRules.BusinessRuleSet:45347
</localId></ObjectReference></ruleSet>
<rule><ObjectReference><localId>wt.businessRules.BusinessRule:168926
</localId></ObjectReference></rule>
<blockNumber>1</blockNumber>
<updateIfExists>true</updateIfExists>
</BusinessRuleLink>