Rule Execution Server API

ilog.rules.factory
Class IlrRuleTaskFactory

java.lang.Object
  extended by ilog.rules.factory.IlrTaskFactory
      extended by ilog.rules.factory.IlrRuleTaskFactory
All Implemented Interfaces:
ilog.rules.factory.IlrRulesetElement, IlrTaskElement, Serializable

public class IlrRuleTaskFactory
extends IlrTaskFactory

A rule-based task definition of the ILOG Rule Language. It provides the settings specific to a rule-based task, such as:

See Also:
IlrRuleTaskFactory, IlrFunctionTaskFactory, IlrFlowTaskFactory, Serialized Form

Constructor Summary
IlrRuleTaskFactory(IlrReflect reflect, IlrPackageFactory pkg, String name)
          Builds a rule-based task by specifying a reflect and a name.
IlrRuleTaskFactory(IlrReflect reflect, String name)
          Deprecated. Use instead IlrRuleTaskFactory(IlrReflect reflect, IlrPackageFactory pkg, String name).
 
Method Summary
 void addGroupInRules(String groupName)
          Adds a group in the rules list.
 void addGroupInScope(String groupName)
          Adds a group to the task scope.
 void addMatchOnClass(IlrClass clazz)
          Adds a class to the list on which the sequential iterator will operate.
 void addPackageInRules(IlrPackageFactory pkgF)
          Adds a package in the rules list.
 void addPackageInScope(IlrPackageFactory pkg)
          Adds a package to the task scope.
 void addRule(String rule)
          Adds a rule to the rule-based task body.
 void addScope(String ruleName)
          Adds a rule, specified by its name, in the task scope.
 void checkRuleTaskConsistency()
          Checks if the rule-based task is correctly defined, which means whether its definition contains incompatible settings or not.
 IlrValue getAgendaFilter()
          Returns the agenda filter defined on the rule-based task.
 IlrFunctionFactory getAgendaFilterFunction()
          Returns the agenda filter defined on the rule-based task.
 int getAlgorithm()
          Returns the algorithm that determines how the rules are fired.
 ArrayList getAllStatements()
          Provides all statements referenced by the task definition.
 ArrayList getAllValues()
          Provides all values referenced by the task definition.
 IlrValue getDomainValue()
          Deprecated. Use instead getScope().
 boolean getDynamicBody()
          Indicates whether the rule-based task has a dynamic body or not.
 int getFiring()
          Returns the firing parameter value defined on the rule-based task.
 int getFiringLimit()
          Returns the firinglimit parameter value defined on the rule-based task.
 IlrValue getIterator()
          Returns the iterator used in a sequential algorithm rule task.
 Vector getMatchOnClasses()
          Returns the vector of object classes on which the iterator will iterate.
 IlrValue getMatchOnValue()
          Returns the object classes on which the iterator will iterate.
 int getOrdering()
          Returns the ordering parameter value defined on the rule-based task.
 Vector getRules()
          Returns the rules that compose the rule-based task body.
 IlrFunctionFactory getRuleSelector()
          Returns the rule-based task body if this one has been defined as a function factory (and not by explicitly listing the rules that compose the body).
 ArrayList getScope()
          Returns the task scope.
 IlrScopeValue getScopeValue()
          Returns the scope value attached to the task.
 boolean hasEmptyBody()
          Indicates whether the task has an empty body or not, that is, if neither a no rules list nor a rule selector has been given to the task.
 boolean removeRule(String rule)
          Removes a rule from the rule-based task body.
 void setAgendaFilter(IlrFunctionFactory agendaFilter)
          Sets the agenda filter to the rule-based task.
 void setAgendaFilter(IlrValue agendaFilter)
          Sets the agenda filter to the rule-based task.
 void setAlgorithm(int algo)
          Sets the algorithm that determines how the rules are fired.
 void setDomainValue(IlrValue value)
          Deprecated. Use instead addScope(String ruleName), addPackageInScope(String pkgName) or addPackageInScope(IlrPackageFactory pkg).
 void setDynamicBody(boolean dynamic)
          Sets the Boolean value that tells whether the rule-based task has a dynamic body or not.
 void setFiring(int firing)
          Sets the value of the firing parameter of the rule-based task.
 void setFiringLimit(int firingLimit)
          Sets the value of the firinglimit parameter of the rule-based task.
 void setIterator(IlrValue iterator)
          Sets the iterator used in a sequential algorithm rule task.
 void setMatchOnValue(IlrValue value)
          Sets as a value the list of ordered classes of the object instances on which the iterator will iterate.
 void setOrdering(int ordering)
          Sets the value of the ordering parameter of the rule-based task.
 void setRuleSelector(IlrFunctionFactory function)
          Sets the rule-based task body.
 void setScopeValue(IlrScopeValue value)
          Sets the scope value attached to the task.
 
Methods inherited from class ilog.rules.factory.IlrTaskFactory
getCompletionFlagValue, getFinalActions, getFormalComment, getInitialActions, getName, getPackage, getProperties, getShortName, setCompletionFlagValue, setFinalActions, setFormalComment, setInitialActions, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlrRuleTaskFactory

public IlrRuleTaskFactory(IlrReflect reflect,
                          String name)
Deprecated. Use instead IlrRuleTaskFactory(IlrReflect reflect, IlrPackageFactory pkg, String name).

Builds a rule-based task by specifying a reflect and a name. The task is considered to belong to the default package. The default settings are: The agenda filter is null and the body is empty.

Parameters:
reflect - The reflect object of this rule-based task factory.
name - The name of the rule-based task.

IlrRuleTaskFactory

public IlrRuleTaskFactory(IlrReflect reflect,
                          IlrPackageFactory pkg,
                          String name)
Builds a rule-based task by specifying a reflect and a name. The task belongs to the specified package. If the package is null, the task is considered to belong to the default package. The default settings are: The agenda filter is null and the body is empty.

Parameters:
reflect - The reflect object of this rule-based task factory.
pkg - The package to which the task belongs.
name - The name of the rule-based task.
Method Detail

addPackageInRules

public void addPackageInRules(IlrPackageFactory pkgF)
Adds a package in the rules list. This means that all rules of the package will be part of the task body.

Parameters:
pkgF - The package whose rules are added to the task body.

addGroupInRules

public void addGroupInRules(String groupName)
Adds a group in the rules list. This means that all rules of the group will be part of the task body.

Parameters:
groupName - The name of the group whose rules are added to the task body.

addRule

public void addRule(String rule)
Adds a rule to the rule-based task body.

Parameters:
rule - The name of the added rule.

removeRule

public boolean removeRule(String rule)
Removes a rule from the rule-based task body.

Parameters:
rule - The name of the rule to be removed.
Returns:
true if the rule was a component of the task, false otherwise.

getRules

public Vector getRules()
Returns the rules that compose the rule-based task body. If the task body has been specified by code, the return vector is empty.

Returns:
The names of the rules that compose the rule-based task body.
See Also:
setRuleSelector(IlrFunctionFactory)

setRuleSelector

public void setRuleSelector(IlrFunctionFactory function)
Sets the rule-based task body. The passed function must not be null, and it must return a boolean and take an argument of IlrRule type. In case any of these conditions is not verified, an IllegalArgumentException is thrown. This allows you to compute the final body by calling the function for each rule of the ruleset (the one in which the rule-based task is defined). If the returned value is true, the rule is added in the rule-based task body, otherwise it is not.

Parameters:
function - The function factory that contains the code to compute the rule-based task body.

getRuleSelector

public IlrFunctionFactory getRuleSelector()
Returns the rule-based task body if this one has been defined as a function factory (and not by explicitly listing the rules that compose the body).

Returns:
The task body as a function factory.
See Also:
addRule(String)

setDomainValue

public void setDomainValue(IlrValue value)
Deprecated. Use instead addScope(String ruleName), addPackageInScope(String pkgName) or addPackageInScope(IlrPackageFactory pkg).

Sets a domain value to the rule-based task. The value can be set only on a rule-based task with a dynamic body. The domain value must be of type ilog.rules.engine.IlrRule[]. In case any of these conditions is not satisfied, an IllegalArgumentException is thrown. When a domain value is specified, the dynamic body code iterates on the array of rules instead of iterating on the whole ruleset.

Parameters:
value - The value that represents a domain.

getDomainValue

public IlrValue getDomainValue()
Deprecated. Use instead getScope().

Returns the value set as the domain value to the rule-based task.

Returns:
The rule-based task domain value.

setAgendaFilter

public void setAgendaFilter(IlrValue agendaFilter)
Sets the agenda filter to the rule-based task. This filter will be activated when the task is executed. The rules that compose the task body are filtered by the agenda filter, and only the rules that are not filtered are effectively fired. The type of the passed value must be assignable to ilog.rules.engine.IlrAgendaFilter.

Parameters:
agendaFilter - The value that represents the agenda filter object.

getAgendaFilter

public IlrValue getAgendaFilter()
Returns the agenda filter defined on the rule-based task. The agenda filter is an instance of a class implementing the IlrAgendaFilter class.

Returns:
The rule-based task agenda filter.

setAgendaFilter

public void setAgendaFilter(IlrFunctionFactory agendaFilter)
Sets the agenda filter to the rule-based task. This filter will be activated when the task is executed. The rules that compose the task body are filtered by the agenda filter, and only the rules that are not filtered are effectively fired. The passed function factory contains the code of the agenda filter. The function must return a boolean and take as an argument an ilog.rules.engine.IlrRuleInstance. In case any of these conditions is not verified, an IllegalArgumentException is thrown.

Parameters:
agendaFilter - The function that implements the agenda filter.

getAgendaFilterFunction

public IlrFunctionFactory getAgendaFilterFunction()
Returns the agenda filter defined on the rule-based task. It is a function that implements the agenda filter.

Returns:
A function factory that implements the rule-based task agenda filter.

setOrdering

public void setOrdering(int ordering)
Sets the value of the ordering parameter of the rule-based task. This parameter specifies the rule ordering strategy of the task. The possible values are IlrRulesetConstants.Dynamic, IlrRulesetConstants.Literal, or IlrRulesetConstants.Sorted. A wrong value throws an IllegalArgumentException.

Parameters:
ordering - The ordering parameter value.

getOrdering

public int getOrdering()
Returns the ordering parameter value defined on the rule-based task.

Returns:
The value of the task ordering parameter.

setFiring

public void setFiring(int firing)
Sets the value of the firing parameter of the rule-based task. This parameter specifies the rule firing strategy of the task. The possible values are IlrRulesetConstants.Rule or IlrRulesetConstants.AllRules. A wrong value throws an IllegalArgumentException.

Parameters:
firing - The firing parameter value.

getFiring

public int getFiring()
Returns the firing parameter value defined on the rule-based task.

Returns:
The value of the task firing parameter.

setFiringLimit

public void setFiringLimit(int firingLimit)
Sets the value of the firinglimit parameter of the rule-based task. This parameter specifies how many rules will be fired when at the task execution. The firinglimit value must be a positive integer. If this condition is not verified, an IllegalArgumentException is thrown.

Parameters:
firingLimit - The number of rules to be fired.

getFiringLimit

public int getFiringLimit()
Returns the firinglimit parameter value defined on the rule-based task.

Returns:
The value of the task firing parameter.

setIterator

public void setIterator(IlrValue iterator)
Sets the iterator used in a sequential algorithm rule task. This iterator must implement IlrTupleIterator.

Parameters:
iterator - The iterator used to compute the objects on which the rules of the sequential algorithm rule task will match.

getIterator

public IlrValue getIterator()
Returns the iterator used in a sequential algorithm rule task.

Returns:
iterator The iterator used to compute the objects on which the rules of the sequential algorithm rule task will match.

setAlgorithm

public void setAlgorithm(int algo)
Sets the algorithm that determines how the rules are fired.

Parameters:
algo - The rule task algorithm.

getAlgorithm

public int getAlgorithm()
Returns the algorithm that determines how the rules are fired.

Returns:
The rule task algorithm.

setMatchOnValue

public void setMatchOnValue(IlrValue value)
Sets as a value the list of ordered classes of the object instances on which the iterator will iterate.

Parameters:
value - The classes as a value used by the iterator.

getMatchOnValue

public IlrValue getMatchOnValue()
Returns the object classes on which the iterator will iterate.

Returns:
The value that represents the classes used by the iterator.

addMatchOnClass

public void addMatchOnClass(IlrClass clazz)
Adds a class to the list on which the sequential iterator will operate. The sequential algorithm needs to know the list of object classes on which the iterator will iterate. This method adds a class in this ordered set. If an iterator has been specified, the class order must correspond to the order of the objects in the tuple computed by the iterator. If no iterator is set to the rule-based task, there is no constraint on the class order.

Parameters:
clazz - The class to add to the vector of classes used by the iterator.

getMatchOnClasses

public Vector getMatchOnClasses()
Returns the vector of object classes on which the iterator will iterate.

Returns:
The vector of classes used by the iterator.

setDynamicBody

public void setDynamicBody(boolean dynamic)
Sets the Boolean value that tells whether the rule-based task has a dynamic body or not. A dynamic body is computed before the task execution, each time the task is executed.

Parameters:
dynamic - The Boolean value that determines whether the rule-based task body will be dynamically computed or not.

getDynamicBody

public boolean getDynamicBody()
Indicates whether the rule-based task has a dynamic body or not.

Returns:
true if the rule-based task body is dynamic, or false otherwise.

addScope

public void addScope(String ruleName)
Adds a rule, specified by its name, in the task scope.

Parameters:
ruleName - The name of the rule to be added in the scope.

addPackageInScope

public void addPackageInScope(IlrPackageFactory pkg)
Adds a package to the task scope.

Parameters:
pkg - The package added to the task scope.

addGroupInScope

public void addGroupInScope(String groupName)
Adds a group to the task scope.

Parameters:
groupName - The group added to the task scope.

getScope

public ArrayList getScope()
Returns the task scope. The scope is composed of packages, package names, group names, or rule names.

Returns:
The scope of the task.

setScopeValue

public void setScopeValue(IlrScopeValue value)
Sets the scope value attached to the task. It creates a value that represents the access to the ?scope value, accessible in the task rule selector.

Parameters:
value - The scope value attached to the task.

getScopeValue

public IlrScopeValue getScopeValue()
Returns the scope value attached to the task.

Returns:
The scope value.

checkRuleTaskConsistency

public void checkRuleTaskConsistency()
Checks if the rule-based task is correctly defined, which means whether its definition contains incompatible settings or not.


hasEmptyBody

public boolean hasEmptyBody()
Indicates whether the task has an empty body or not, that is, if neither a no rules list nor a rule selector has been given to the task.

Specified by:
hasEmptyBody in class IlrTaskFactory
Returns:
true if the task body is empty, or false otherwise.

getAllValues

public ArrayList getAllValues()
Provides all values referenced by the task definition. This method can make a factory exploration by a factory explorer easier. In case the task references no values, the returned list is empty.

Overrides:
getAllValues in class IlrTaskFactory
Returns:
All the values referenced by the task.

getAllStatements

public ArrayList getAllStatements()
Provides all statements referenced by the task definition. This method can make a factory exploration by a factory explorer easier. The returned list contains statements. If the task references no statements, the returned list is empty.

Overrides:
getAllStatements in class IlrTaskFactory
Returns:
All the statements referenced by the task.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2012