[rules-users] foreach in drl file

Ingomar Otter iotter at mac.com
Mon Feb 16 18:24:04 EST 2009


Phl,
I am still not quite there.
 >, I would like a foreach which itterates through a list in my java  
class, e.g. "Golfer", and addes the conditions in the collection to my  
rule with "ANDs"
So the condition is where?

What I would be looking for is a plain text description of the rule, ie.
"find all  serial numbers of all Golfer objects that have ..."  Or  
something like that.
Prose is usually a fairly good starting point for transcribing into  
rules/drl.

Afaik "foreach" loop  / iterations is not supported in the LHS  per  
se. They are also not needed as the pattern matcher will just do the  
right thing.
The same result can be achieved in a 'proper' declarative  way,  
(whatever that means ;-) ). Therefore the question about the "what".

--I



Am 16.02.2009 um 23:58 schrieb can_man at gmx.de:

> Hello,
>
>
>> maybe you can tell us what you are trying to do? Are you talking  
>> about
>> the RHS?
>>
>> --Ingomar
>
> thank you for your reply. I would like to use a template drl file  
> together with a java class. Both the LHS and RHS should contain  
> variables, where the LHS should itterate over a collection in the  
> "when" part.
>
> So for example, in the golf example, I would like a foreach which  
> itterates through a list in my java class, e.g. "Golfer", and addes  
> the conditions in the collection to my rule with "ANDs".
>
> rule "find solution"
>    when
>        // cut
>
>        Golfer(
>
>        @foreach{item : products}
>        - @{item.serialNumber}
>        @end{}
>
>        )
>
> 	then
>           // do something
> end
>
> My problem is that I don't really know how to write the foreach  
> syntax.
> Hope this is clear.
>
> Thank you.
> Phil
>
>> Am 16.02.2009 um 23:15 schrieb can_man at gmx.de:
>>
>>> Hello,
>>>
>>> I would like to itterate over a list in a drl template file, I
>>> looked at http://mvel.codehaus.org/MVEL+2.0+Orb+Tags
>>>
>>> @foreach{item : products}
>>> - @{item.serialNumber}
>>> @end{}
>>>
>>> but I just can't get the syntax right. Could someone please post an
>>> example drl file with a foreach.
>>>
>>> Thank you very much.
>>> Phil
>>> -- 
>>> Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
>>> für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?
>>> ac=OM.AD.PD003K11308T4569a
>>> _______________________________________________
>>> 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
>
> -- 
> Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
> für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/? 
> ac=OM.AD.PD003K11308T4569a
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users





More information about the rules-users mailing list