Server Administration > Change Packages for SCM > Change Package Reviewer and Watcher Rules > Condition Structure and Elements
  
Condition Structure and Elements
This section describes the structure of conditions and the elements that can be included.
IssueFieldCondition Element
Issue field conditions allow you to associate the review of a change package to the value of a field in the issue associated with the change package. This allows you to specify who the reviewer should be, if some specified field has a specified value. All issue fields are supported in IssueFieldCondition expressions. Further, regular expressions are allowed when specifying field values.
The IssueFieldCondition element has two attributes that must be specified: fieldName and operator. In addition, IssueFieldCondition must be followed by one of the FieldValue, UserFieldValue, or GroupFieldValue elements. The fieldName attribute allows you to specify the name of the field you want to use in the expression. The operator attribute allows you to specify the operator to use when comparing field values. Currently, the two operators Equal and NotEqual are supported. In regular expressions, these operators mean "matches" and "does not match," respectively. If the type of the value of the field is a group (of users), then operator Equal means "Is the user in the group." All comparisons are always case sensitive.
If the type of the field value is user, then the IssueFieldCondition element must be followed by the UserFieldValue element. If the type is group (of users), then the IssueFieldCondition element must be followed by a GroupFieldValue. In all other cases, the IssueFieldCondition element is followed by the FieldValue element.
The FieldValue element contains the optional attribute regularExpression, which can be set to True or False. This allows you to specify if you want to use regular expressions when comparing field values. The default value is False; however, if you set the value of the attribute to True, then the specified field value can be a regular expression that is used to match actual field values.
For example, the condition "If the item associated with the change package we are reviewing has a Project field value of SI/GUI/Diff, is written as:
<IssueFieldCondition fieldName="Project" operator="Equal">
<FieldValue>
SI/GUI/Diff
</FieldValue>
</IssueFieldCondition>
If you wanted to review all GUI projects, the condition in this case would be "If the item’s Project field matches expression .*swing.*", written as:
<IssueFieldCondition fieldName="Project" operator="Equal">
<FieldValue regularExpression="True" >
.*swing.*
</FieldValue>
</IssueFieldCondition>
Another example would be the condition "If the item was created by a user from group Co-op," which can be written as:
<IssueFieldCondition fieldName="Created User" operator="Equal">
<GroupFieldValue>
Co-op
</GroupFieldValue>
</IssueFieldCondition>
Errors and messages
If you specify an IssueFieldCondition and the change package reviewed has no item associated with it, the condition is met by default. If the field name specified in the issue field condition does not exist, an error is logged; however, the condition is still considered met. If the FieldValue uses regular expressions and the expression is malformed and causes an exception when matching is done, the error is logged and the expression is matched.
ChangePackageFieldCondition Element
The ChangePackageFieldCondition element allows you to associate the review of a change package to change package field values. The following fields are valid: summary, user (change package creator), and description. Similar to IssueFieldCondition, ChangePackageFieldCondition contains the attributes fieldName and operator, which have the same meanings and restrictions.
If you specify a field name that is not supported, a message is logged; however, the condition is not met.
ChangePackageEntryFieldCondition Element
Currently, the supported change package entry fields are: member, project, archive and variant. If any other field is specified for ChangePackageEntryFieldCondition, it is ignored, the message is logged, and condition is not met.
MemberAttributeCondition Element
Member attribute conditions allow you to associate the review of a change package to the value of a specific user defined attribute belonging to a change package member. This allows you to specify what entity should be the reviewer in case any member of a change package has an attribute with a specified value. The specified value can also be a regular expression, and in that case, any attribute with a given name satisfies the condition if its value matches the regular expression pattern. All user defined member attributes are supported in MemberAttributeCondition.
The MemberAttributeCondition element contains the attributes attributeName and operator. The operator attribute allows you to specify the operator to use when comparing field values. Currently, the operators Equal and NotEqual are supported. For regular expressions, these mean "matches" and "does not match," respectively. The attributeName attribute specifies the name of the member attribute to use in the condition. MemberAttributeCondition must be followed by exactly one MemberAttributeValue element, which has an optional attribute, regularExpression. This element allows you to specify the value that the member attribute should have, or if you are using regular expressions, a regular expression pattern that the actual member attribute value should match.
Reviewers Element
The Reviewers element allows you to specify which enumeration policy to use (currently, only the All policy is supported), which voting policy to use (currently, only UnOrdered is supported), as well as how to treat rejected reviews. After these policies are specified, the Reviewers element allows you to specify the individual User or Group reviewers or to specify that a user or group reviewer should come from an item field.
In the case of UserExpression or GroupExpression, if there is no issue associated with the change package being reviewed, a message is logged and when there are no reviewers and the issue field is not an appropriate type, an error message is logged and no reviewer is returned.
All reviewers obtained directly from the User or Group tag or resolved reviewers from Issue fields are validated against the realm. If a user or group is found in the list of all reviewers but is not in the realm, an error is logged and the reviewer is ignored.
Reviewer Rule
The reviewer rule consists of an optional condition and reviewer expression. If the review condition is absent, then the (non-existent) condition is considered met by default and all reviewers specified in the reviewer expression are returned. If the condition is specified, it is evaluated against the concrete change package being submitted and its associated item (if any). If the condition is met, the reviewers from the reviewer expression are returned, otherwise no reviewers are returned.