Hmm, now that you mentioned, I see that our parser is limiting the
forall() CE, not allowing nested "from" CEs. This is something we should
fix, since the limitation is purely a parser limitation.
Anyway, for your case, the workaround is simply to use the "raw"
forall-equivalence: not( A() and not( B() ) ). So try this:
rule "Do Not Process TAX" when
$report: ExpenseReport($expenseDetails: expenseDetails)
not ( $ed : ExpenseDetails() from $expenseDetails and
not ( ExpenseDetails( this == $ed, expenseType ==
ExpenseType.TAX ) from $expenseDetails )
)
then
System.out.println("################ It works
##################");
insertLogical("Bypass Process");
end
This is just more verbose than the forall, but it is exactly the same.
Once the parser is fixed, you will be able to simply write:
rule "Do Not Process TAX" when
$report: ExpenseReport($expenseDetails: expenseDetails)
forall ( ExpenseDetails( expenseType == ExpenseType.TAX )
from $expenseDetails )
then
System.out.println("################ It works
##################");
insertLogical("Bypass Process");
end
BTW, may I ask you please to open a JIRA so we don't forget to fix this
for 5.0?
Thanks,
Edson
2008/5/18 Alessandro Di Bella <aldibella(a)gmail.com>:
Hi,
I have these two classes:
ExpenseReport{
Collection<ExpenseDetails> expenseDetails
}
ExpenseDetails{ ExpenseReport document
ExpenseType expenseType
}
I am trying to create a rule that fires when all the ExpenseDetails in a
ExpenseReport are of the same type:
rule "Do Not Process TAX" when
$report: ExpenseReport($expenseDetails: expenseDetails)
forall (
ExpenseDetails(document==$report, expenseType ==
ExpenseType.TAX)
) then
System.out.println("################ It works
##################");
insertLogical("Bypass Process");
end
For some reasons, it fires regardless that value of
ExpenseDetails.expenseType.
I just started with drools and any help i more than welcome.
Thanks
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com