body (in ruletask)

The body keyword defines the body of the rule task.

Purpose

This keyword is used to define a rule task body in ruletask statements.

Context

Rule task definitions

Syntax

(1) ruletask  ruleTaskName  
    {
        body {ruleName1, ..., ruleNamen}
    };

(2) ruletask  ruleTaskName  
    {
        body = dynamicselect([variableName]) 
        { 
            action1;
            ...
            actionn;
        }
    };

Description

You can write the body of a rule task in different syntaxes.

Syntax (1)

The rule task body is composed of the rules that are explicitly listed by their names. These rules must belong to the same ruleset as the rule task.

Syntax (2)

The rule task body has been specified by comprehension: the rules that compose the task body are not explicitly listed. The contents of the task body is computed when the code given as body for each rule in the ruleset is executed.

This body definition can be seen as an IRL function with a Boolean return type and an argument of type IlrRule. In this case, a variable name is specified. The code is executed for each rule of the ruleset. When the execution returns true, the rule becomes part of the rule task. Otherwise it does not. The body is computed before each task is executed. This is useful when the body content depends on variables whose values change during the ruleflow execution.

Example

ruletask DetectGridFull
{
   ordering = literal;
   firinglimit = 1;
   body = { DetectGridFull }
};
 
 
ruletask ExpandObjects
{
   ordering = dynamic;
   firing = allrules;
 
   body = select(?rule)
   {
      String ?task = ?rule.getProperties().getString("task","");
      return ?task.equals("ExpandObjects");
   }
};