ARL task model examples
This section provides examples of using the ARL rule language in task models.
Initial value
You can use the ARL rule language specify the initial value of a variable.
You can enter a literal value:
10.0You can create a new object:
newShipment()You can use the value of a variable to initialize the value of another variable:
12* monthlyIncomeIn this example, the value of the monthlyIncome variable is used to compute the
value of another variable.
Action
You can use the ARL rule language to modify variables in action nodes, and in the initial and
final actions of task nodes. For example:
discount =10.0;You can add a note:
note("the discount is now: "+discount);You can also write arbitrary complex code:
for (Shipment shipment : shipments) {
insert(shipment);
}In this example, the shipments are copied from a variable of type list shipments
and into the working memory.
The following methods can be used in actions:
note(<string>)- Creates a note. Notes are displayed in the execution trace.
insert(<object>)- Creates an object and insert it into the working memory.
retract(<object>)- Removes an object from the working memory.
retractAll()- Removes all objects from the working memory.
Transition conditions
You can use Boolean expressions in ARL to specify transition conditions.
The following example shows an object with a Boolean attribute:
loan.accepted
You can also write arbitrary complex code:
loan.accepted || (loan.amount <100&& customer.grade ==Grade.Gold)
Rule selection filter
You can specify a rule selection filter with a Boolean expression in the ARL rule language. The
rule variable can be used to represent the rule to be selected or ignored.
The rule name can be used to select a rule:
return rule.name.startsWith("XYZ")
You can access the following attributes from the rule variable:
name- The fully qualified name of rule, including its package name.
shortName- The short name of the rule, without its package name.
packageName- The name of the package containing the rule. It can be
null. description- The description of the rule.