Attribute Rule
The attribute rule validates that specified attributes meet certain conditions. The object type is the only required input for an attribute rule configuration. The object type should be a wt.fc.Persistable type object. For example, com.ptc.Waiver is a subtype of wt.change2.WTVariance.
<configs>
<config name="objectType" value="com.ptc.Waiver"></config>
</configs>
You can specify the type name or the type string value by using only the type external name (com.ptc.Waiver or WCTYPE|wt.change2.WTVariance|com.ptc.Waiver )
You can exclude subtypes of the specified object type from the attribute rule. For example, the following attribute rule configuration for object type WTVariance would exclude com.ptc.Waiver and com.ptc.Deviation type variances from being evaluated.
<configs>
<config name="objectType" value="wt.change2.WTVariance "></config>
<config name="excludedType" value="com.ptc.Waiver"></config>
<config name="excludedType" value="com.ptc.Deviation"></config>
</configs>
To configure a condition that validates against an attribute of the specified object type, the configuration name is Attribute Name and the value is Condition. The following attribute configuration checks if a com.ptc.Waiver has an approved quantity between 10 and 100.
<configs>
<config name="objectType" value="com.ptc.Waiver"></config>
<config name="approvedQuantity" value="[10..100]"></config>
</configs>
The following is an example where weight is the internal name of a global attribute on some subtype of part.
<configs>
<config name="objectType" value="com.ptc.SubTypePart"></config>
<config name="weight" value="<=100"></config>
</configs>
The following table shows the supported operations and object types supported in attribute rule configuration.
Operator
Value Types
Description
Example Load Conditions
>, >=, <, <=
Long, String, Date, Timestamp, FloatingPoint, FloatingPointWithUnits
Validates that the object attribute value is greater than, greater than or equal to, less than, or less than or equal to the value specified.
The operator characters are reserved characters in the import load; the less than operator (<) needs to be specified as ‘&lt;’ and greater than operator (>) as ‘&gt;’.
&gt;2012-01-12 00:00:00=&lt;=20.002&gt;=10
[0..10]
Long, String, Date, Timestamp, FloatingPoint, FloatingPointWithUnits
Validates that the object attribute value is within the specified range. If no minimum value in the range is specified, the condition is equivalent to less than or equal to. If the maximum value in the range is not specified, the condition is treated a greater than or equal to.
[-10.09..10.09][2012-01-12 00:00:00..2012-02-12 00:00:00][..100][0..]
=, !=
Boolean, Long, String, Date, Timestamp, FloatingPoint, FloatingPointWithUnits
Validates that the object attribute value is or is not the value specified.
The operator character ! is a reserved character in the import load; it must be specified as ‘#33;’
=true#33;=2012-02-12 00:00:00=10.09
[A,B]
Boolean, Long, String, Date, Timestamp, FloatingPoint, FloatingPointWithUnits
Validates that the object attribute value is within the discrete set.
[true][2012-02-01 00:00:00,2012-02-15 00:00:00,2012-02-30 00:00:00][MAJOR,CRITICAL][10.01,10.02][10,100,1000]
SET
Boolean, Long, String, Date, Timestamp, FloatingPoint, FloatingPointWithUnits
Validates that the object attribute value is not null. Only the keyword SET is needed to specify the operation.
SET
NOT_SET
Boolean, Long, String, Date, Timestamp, FloatingPoint, FloatingPointWithUnits
Validates that the object attribute value is null. Only the keyword NOT_SET is needed to specify the operation.
NOT_SET
EQUALS
String
Validates that the object attribute value is the specified string.
EQUALS(MAJOR)
NOT_EQUALS
String
Validates that the object attribute value is not the specified string
NOT_EQUALS(MAJOR)
BEGINSWITH
String
Validates that the object attribute value starts with a specified string.
BEGINSWITH(PN)
NOT_BEGINSWITH
String
Validates that the object attribute value does not start with a specified string.
NOT_BEGINSWITH(PN)
ENDSWITH
String
Validates that the object attribute value ends with a specified string.
ENDSWITH(0)
NOT_ENDSWITH
String
Validates that the object attribute value does not end with a specified string.
NOT_ENDSWITH(0)
CONTAINS
String
Validates that the object attribute value contains the specified string.
CONTAINS(PN0)
NOT_CONTAINS
String
Validates that the object attribute value does not contain the specified string.
NOT_CONTAINS(PN0)
LENGTH
String
Validates that the object attribute string length is within the specified range.
LENGTH(0..40)LENGTH(0..)LENGTH(..40)
* 
The system locale is used for the format of the dates and timestamps in the attribute condition.
Example
Suppose you have a specific subtype of a part that has an attribute called weight to represent how heavy the part is. Before releasing parts that have a weight, you want to ensure that a weight is set to a reasonable figure. In order to do this, construct a business rule to verify the weight attribute falls within the range 1-100.
Business rule set:
<?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>
Business rule:
<?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>
Business rule link:
<?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>
</BuisnessRuleLink>
Isto foi útil?