Attribute Comparison Operators
These operators return the number of relationship
items that have been selected for which the comparison is true. For
example, you can use numAttr>
to find out how many
items with Length greater than 5 feet in a relationship have been
selected.
The operators count all the items selected from the relationship,
not the number of different items. In the preceding example, if the
user selects two of the same item and enters a length greater than
5 feet, the numAttr>
operator will return 2.
The operators take two arguments, A and B. Argument A is the full path from the root of the product to the attribute. Argument B is the comparison value. This value can be of type Integer, Number, Date, or Time. Type DateTime is not supported. Argument B can also be a sub-expression that resolves to one of these data types.
In addition, for the numAttr==
and numAttr!=
operators, argument B can be a text string.
Use the attribute comparison operators shown in the following table to create subexpressions that form conditions.
Operator | Syntax | Properties |
---|---|---|
Greater than |
|
Returns the number of items in the relationship for which the value of attribute A is greater than B. |
Not less than |
|
Returns the number of items in the relationship for which the value of attribute A is greater than or equal to B. |
Equals |
|
Returns the number of items in the relationship for which the value of attribute A is equal to B. |
Not equal to |
|
Returns the number of items in the relationship for which the value of attribute A is not equal to B. |
Not greater than |
|
Returns the number of items in the relationship for which the value of attribute A is less than or equal to B. |
Less than |
|
Returns the number of items in the relationship for which the value of attribute A is less than or equal to B. |
You can use the numAttr operators to create "any/all" conditions in constraints involving attributes:
You create the condition "any instance of products in R has attribute A=X" as follows:
>=(numAttr==(@.[R].[A], X), 1)
You create the condition "all instances of products in R have attribute A=X" as follows:
==(numAttr==(@.[R].[A], X), @.[R])
For example, you want to write the constraint, when all the instances of products in P have attribute A=X then exclude any instance of products in Q that have attribute B =Y. You would write this constraint as follows:
excl(==(numAttr==(@.[P].[A], X), @[P]),
>=(numAttr(==(@.[Q].[B], Y), 1)))