Expressions can be used in process definitions for evaluating the following conditions:
Validating variable values at the completion of a task
Checking whether a transition should be traversed or not
Checking whether an iteration has completed or not
Expressions are evaluated using variable values and are defined using a scripting language such as Python (default) or BeanShell. The scripting language for a process is set in your process template attributes. Table 13.1: Syntax for Logical Operations shows the syntax for logical expressions that you can use in scripts, and Table 13.2: Syntax for Arithmetic Operations shows arithmetic expressions syntax.
Table 13.1: Syntax for Logical Operations
| Logical Operation | Syntax |
|---|---|
| and | @and |
| or | @or |
| not | ! |
| not equal to | != |
| equal to | == |
| greater than (>) | @gt |
| greater than equal to (>=) | @gteq |
| less than (<) | @lt |
| less than equal to (<=) | @lteq |
Table 13.2: Syntax for Arithmetic Operations
| Arithmetic Operation | Syntax |
|---|---|
| addition | + |
| multiplication | * |
| integer or real division | / |
| modulo | % |
When you utilize expressions in process templates, you should be aware of how the values of variables are represented and the operations that are supported on them.
For Boolean variables @and, @or, !, == and != operations
are allowed.
For example if x and y are two Boolean variables then
the expression x @and y will evaluate to true
only if both x and y are true. The expression x @or !y will evaluate to true if either x is true
or y is false. The previous expression can
also be specified as: x == true @or y == false.
For Long and Double values @gt, @gteq, @lt, @lteq, +, *, / and % operations are allowed.
For example if x and y are two Long variables then the expression x @lt 2*y will
evaluate to true if the value of x is less
than double of y.
String variables are represented
as instances of java.lang.String, which do
not support any operations.
For string comparisons you
should use the equals() method instead of logical
operators such as == or !=. For example if x and y are two String variables then the expression x == y will not evaluate to true even if the value of x and y are the same. You must
use the expression: x.equals(y). String literals
can also be used in expressions by putting them under double quotes
(“”). If you use literals within
the expression then you must use single quotes for the expression.
For example the expression 'x.equals(“Hello World”)' will evaluate to true if the value of x is Hello World.
Reference variables are represented
as instances of ModelObjectInterface, which
belongs to EKM's scripting interface. You can use any of the
methods defined in ModelObjectInterface on
the reference variable instance, such as getName(), getProperties(), and so on.
For example, if x is a reference variable,
the expression ‘x.getName().equals(“foo”)’ evaluates to true if the reference points to an object whose name
is foo. For checking whether the reference
is valid or not, you should compare it to the void keyword. For example
the expression x == void will return true is
the reference variable x points to an object
that does not exist.
Date variables are represented
as instances of java.util.Date class. You
cannot use logical operations such as <, > or == with dates. However, you
can use after(), before() or equals() methods of the Date class to compare one date with another.
Multivalued variables are represented as an array
of objects. Each object can be of type Boolean, Long, Double, String, Date or ModelObjectInterface.
For example, if x is a multivalued String variable that has values a, b and c then in expressions
this variable is available as the list: [“a”, “b”, “c”].
Usually you will use multivalued variables in expressions under the
following conditions:
To determine the number of values specified.
For example, the expression x.length > 2 evaluates to true if x has more than two
values specified.
To determine whether the list contains a particular value.
Because Java arrays do not provide a direct method for checking whether an element is contained within the array, you could use a macro in this case. An example of this is provided later.
You can also use parentheses for grouping sub-expressions, for example:
x @lt 2*y @and (x @lt 10 @or x @gt 20)