ruletask

The ruletask keyword declares a rule task.

Purpose

The keyword used to declare a rule task.

Context

At the top level of rulesets

Syntax

ruletask ruleTaskName 
{
   [property propertyName = value;] 
   [algorithm = default|sequential;] 
   [matchedclasses = matchedClasses] 
   [iterator = value;] 
   [ordering = dynamic|sorted|literal;] 
   [firing = allrules|rule;] 
   [firinglimit = integer value;] 
   [agendafilter = agendaFilter] 
   [initialaction {action1 ... actionm}] 
   [finalaction {action1 ... actionn}] 
   [completionflag = value;] [scope = scope]
   [body body]
};  
matchedClasses is given a value in one of two ways:
matchedclasses = {class1, class2, ..., classn}
matchedclasses = value;
agendaFilter is defined in one of two ways:
agendafilter = filter(?instance) {action1 ... actions}
agendafilter = value;
body is defined in one of three ways:
body {ruleName1, ruleName2,..., ruleNamep}
body = select(?rule) {action1 ... actionq}
body = dynamicselect(?rule) {action1 ... actionr}

Description

A rule task is one of the three kinds of tasks available in a ruleflow. A rule task lists the rule or rules that define the rule task.

Note:
  1. The ruleflow syntax is described in Grammar specification.

  2. If a formal comment (/**...*/) precedes the task definition, it is saved so that you can retrieve it later using the API.

A rule task can have the following attributes:

Example

Example 1

In this rule task, the body consists of the rules DectectConnect4 and DetectGridFull. The rule ordering is set to literal: the order in which the rules are listed in the body is kept for the execution.

ruletask DetectConnect4
{
   ordering = literal;
   body = { DetectConnect4, DetectGridFull }
};
Example 2

In this rule task, the body is defined by comprehension. To compute the body, the code is executed for each rule in the ruleset. The rules for which the return value is true are part of the rule task body. The others are not part of the body.

The ordering here is set to sorted: the rules are sorted in decreasing order of static priority before being executed.

The firing value is set to rule: only one rule is executed among the rules that compose the body, even if more than one are eligible to be executed.

The initial actions are executed before the task body. If final actions are provided, they will be executed after the task body.

ruletask ChooseMovePlayer1
{
   initialaction =
   {
      move = null;
   };

   body = select(?rule)
   {
      String ?task = ?rule.getProperties().getString("task","");
      return ?task.equals("ChooseMovePlayer1");
   }
   ordering = sorted;
   firing = rule;
};