[rules-users] forall over a collection

Edson Tirelli tirelli at post.com
Fri Mar 20 05:46:58 EDT 2009


   Wolfgang is right in its suggestion.

   Just to explain what the problem is, in previous versions of drools,
forall() could not be used with an embedded from. It is fixed in trunk.

   []s
   Edson

2009/3/20 Wolfgang Laun <wolfgang.laun at gmail.com>

> You don't need forall to solve your problem. The following rule prints all
> patient names which don't have problem 4711; omitting the 'not' prints
> those suffering from Colognitis.
>
> rule lookJoe
>     when
>         $patient: Patient()
>         not ( Problem( code == "4711" ) from $patient.problemList )
>     then
>         System.out.println( $patient.getName() );
> end
>
> 'not' implies quantification (or exhaustive search over the domain).
> Without 'not' also searches all Problem entries of the current Patient
> so it would fire again if the patient has a problem stored more than
> once.
>
> -W
>
> 2009/3/20 howard goldberg <goldberg.howard at gmail.com>
>
>> Trying to check whether a patient has a particular problem on their
>> problem list:
>>
>>     when
>>
>>         $patient : Patient()
>>         forall ( Problem( code != "195967001") from $patient.problemList)
>>
>> but I get the following parsing error--
>>
>> [29,41]: [ERR 101] Line 29:41 mismatched input 'FROM' expecting ')' in
>> rule "Dumb no asthma Rule"
>> [29,66]: [ERR 101] Line 29:66 mismatched input ')' expecting '(' in rule
>> "Dumb no asthma Rule" in pattern $patient.problemList
>>
>> What is the correct way to check for this condition?
>>
>> Thanks,
>> Howard
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090320/442885b1/attachment.html 


More information about the rules-users mailing list