Hi,

thanks for your help, I created the JIRA as requested (http://jira.jboss.org/jira/browse/JBRULES-1611).

The workaround you suggest works only partially, if any of the ExpenseDetails is of type ExpenseType.TAX it will fire the rule.

What I would like to do is to fire the rule only if all ExpenseDetails in the same report are of type ExpenseType.TAX.

Any help is more than welcome.

Thanks

Alessandro

Edson Tirelli wrote:

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 <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:

    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
    [email protected] <mailto:[email protected]>
    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 <http://www.jboss.com>


------------------------------------------------------------------------

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to