[rules-users] foreach in drl file

Ingomar Otter iotter at mac.com
Mon Feb 16 19:14:55 EST 2009


How about

when
	Time(value==10)   //it's 10 o'clock
         $aFriend: Friend() //any friend in the working memory
then
	//RHS will be fired for each friend if it's 10 o'clock
end

or:

when
	Time(value==10) //is it 10?
	$self:Self()  //get a handle to yourself
	$friend: Friend( name in "Mike", "Tom", "Anna" ) from  
$self.friends  //match your friends named Mike, Tom or Anna.
then
..  //will be fired for each of your friends that are called either  
Mike, Tom or Anna
end

Depending on the actual problem there are a lot of ways of doing this.  
If you provide a 'less artificial' example we may be able to help ;-)

Please study Drools Manual (4.07) chapter 6.5.2, it has nice tiny  
examples.



Cheers,
   Ingomar

Am 17.02.2009 um 00:40 schrieb can_man at gmx.de:

> Thanks for the reply Ingomar.
>
>> 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.
>
> I will try, hopefully it is a bit clearer this time.
>
>
> friends = ['Mike', 'Tom', 'Anna'] // this is the collection I want  
> to itterate over
>
> time = 10
>
>
>
> When my 'friend' is one of 'friends' and time is 10 o'clock then  
> ring my alarm.
>
>
> Hope this shows where I would like the collection to get into play.
>
> Thank you,
> 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





More information about the rules-users mailing list