Phil,
Take a look at the manual and look for the "forall" LHS conditional element if
you can pass all of your objects individually. Or if you must pass your items
into WM as a List then take a look at the "collect" LHS element examples.
In your example if you wanted to say "All Golfers have red pants" it would look
something like
import com.sample.Golfer;
import java.util.List;
import java.util.ArrayList;
rule "test"
when
$list : List() //<--The list you use insert into working memory
ArrayList( size == $list.size) from collect (Golfer(pantsColor=="red")
from $list)
then
System.out.println("HIT");
End
I didn't run it but you get the idea.
Joe
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of [email protected]
Sent: Monday, February 16, 2009 3:58 PM
To: [email protected]
Subject: Re: [rules-users] foreach in drl file
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 [email protected]:
>
> > 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
> > [email protected]
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> 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
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users