agendafilter

The agendafilter keyword defines an agenda filter in a rule task.

Purpose

This agenda filter is used if the execution algorithm selected for the rule task is RetePlus.

Context

Rule task definitions

Syntax

(1) ruletask ruleTaskName  
    { 
      agendafilter = filter (variableName) 
      { 
          action1 
          ... 
          actionn 
      }
    }; 

(2) ruletask ruleTaskName  
    { 
      agendafilter = value;
    }; 

Description

You can write agenda filters in two different syntaxes:

Syntax (1)

You write the code of the agenda filter within the task definition. This code is similar to an IRL function with an IlrRuleInstance parameter and a Boolean return type. The variableName placeholder represents this IlrRuleInstance object. It can be referenced in the inline code of the agenda filter. Ruleset variables are accessible from the agenda filter code. This agenda filter is applied on each instance of the rules that compose the task body. Any instance for which the agenda filter returns true is executed. The other instances are not.

Syntax (2)

You write the agenda filter as an instance of a class that implements the IlrAgendaFilter interface. This filter is applied on each instance of the rules that compose the task body. The instance for which the agenda filter returns true is executed. The other instances are not.

Example

These two examples illustrate the use of the agendafilter keyword.

Example 1

This example defines a rule task ruletask1 in which the body is composed of all the rules of the ruleset. The agenda filter defined on the rule task filters the rule instances contained in that task. Only the rule instances whose names are contained in the input parameter of the ruleset are executed. The others are not.

ruletask ruletask1
{
   body = select(?rule) {return true;}
   agendafilter = filter(?instance)
   {
      String name = ?instance.ruleName;
      return inputParam.contains(name);
   }
};
Example 2

This example defines another rule task in which the body is composed of all the rules of the ruleset. The agenda filter defined on the task is an instance of the Java™ class MyAgendaFilter, which implements the IlrAgendaFilter interface.

ruletask ruletask1
{
   body = select(?rule) {return true;}
   agendafilter = new MyAgendaFilter();
};