ARL rules 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.
10.0newShipment()12* monthlyIncomeIn this example, the value of the monthlyIncome variable is used to compute the
value of another variable.
Action
discount =10.0;note("the discount is now: "+discount);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.
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:
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.