scope
The scope keyword defines a scope in a rule task.
Purpose
This keyword is used to define a scope in a rule task, that is, a superset of the rules that compose the rule task.
Context
Rule tasks
Syntax
ruletask main { body = select(?rule) { ... }
scope = {packageName1.*, ..., packageNamem.*,
group(groupName1), ..., group(groupNamep),
ruleName1, ..., ruleNamen} }
ruletask main { body = select(?rule) { ... } scope = all; }
Description
You can define a scope with packages or rules. If you specify a package, all the rules of the package are part of the scope. When you choose to define a scope, the final task body cannot contain rules that are not part of the scope. Domains are converted into a scope. You cannot use domains and scope together; otherwise a parsing error is raised.
The all value for a scope means that the scope includes all the rules of the ruleset. This is equivalent to not defining a scope.
If the rule task runs in sequential mode and you have defined a scope, the bytecode generation is performed at parsing time.
Example
In this example, the rule task keeps all the rules defined in the scope (always returns true): pricing.r1 and europe.pricing.r2.
package pricing
{
rule r1
{
when {
...
}
then {
...
}
}
}
package europe.pricing
{
rule r1
{
when {
...
}
then {
...
}
}
rule r2
{
when {
...
}
then {
...
}
}
}
ruletask main
{
scope = { pricing.*, europe.pricing.r2}
body = dynamicselect(?rule) {
return true;
}
}