Hello,
Silly newbie question. I'm trying to write my first rule set to handle
permissions and I'm running into a problem where Drools is not executing
the 'then' clause of all my rules, even though they all resolve to true.
Here's my sample file:
rule "Docs1"
activation-group "permissions"
no-loop true
when
Resources( $resList : resourceList )
$res : Resource(name=="CUSTOMER", allowed==false) from
$resList
then
System.out.println("Foo");
end
rule "Docs2"
activation-group "permissions"
no-loop true
when
Resources( $resList : resourceList )
$res : Resource(name=="INVOICES", allowed==false) from
$resList
then
System.out.println("Wow");
end
I'm using a StatelessKnowledgeSession something like this:
ArrayList ruleObjs = new ArrayList();
ruleObjs.add(resources);
kbase.newStatelessKnowledgeSession().execute(ruleObjs);
So here's my problem. Both of the rules above resolve to true. But only
"Wow" is output to the console. If I comment out the Docs2 rule entirely
then "Foo" is output to the console (proving it also resolves true).
Why wouldn't I get "Wow" and "Foo" output to the console (in no
particular
order) when both are run?
To see whether both rules are actually being evaluated I also tried
creating a simple message function that prints something to the console
and returning true. Then I eval() my function as the last line of the when
clause in Docs1. "Wow" from Docs2 is output as before, as is my
function's message (proving that Docs1 was evaluated and resolved
truthfully), but... Docs1 'then' clause is not executed and Foo is not
output. Why?
This scenario holds true if I have lots of rules. Only the 'then' clause
of last one resolved true is executed even though there may have been
several other rules that resolved true.
Thanks in advance for any ideas or help!
Best regards,
Greg
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
This e-mail message, including attachments, may contain confidential,
proprietary, or export controlled information.
Any unauthorized disclosure, distribution, or other use is prohibited,
unless expressly authorized.
If you receive this e-mail in error, please notify the sender, and delete
all copies of the original message from your systems.