accumulate is indeed complex; the simpler collect might be applicable as well in this case.
rule all45_A when forall ( Equipment( parent == 0, $id : id ) Alarm( cause == 45, source == $id ) ) $alarms : ArrayList() from collect( Alarm( cause == 45, $source : source ) ) then for( Object o: $alarms ){ retract( o ); // or anything else with (Alarm)o } insert( new SummaryAlarm( 45 ) ); end Another solution would be by using 2 rules: rule all45_B1 when forall ( Equipment( parent == 0, $id : id ) Alarm( cause == 45, source == $id ) ) then insert( new SummaryAlarm( 45 ) ); end rule all45_B2 when SummaryAlarm( $cause : cause ) $a : Alarm( cause == $cause, $source : source ) Equipment( parent == 0, id == $source) then retract( $a ); // or anything else with $a end -W On Thu, Jul 16, 2009 at 10:55 AM, Gab Aldian<aldian...@gmail.com> wrote: > I finally suceeded to get what I wanted using the keyword accumulate > which is really very poweful as said in the doc. Here is the rule: > http://drools.pastebin.com/m4f938e40 > > It is a little bit complex, but it perfectly works. The only > observation I have is that it seems drools compatible jdk is < 1.5, > since I tryed to declare my linkedlist this way: LinkedList<Alarm>(), > but got warnings about the unexpected '<'. One other thing, the > "implicit and" does not work in the accumulate, you have to put it > clearly. > > Now I have something giving me the list I need, all should be easy I > think. Do you have any observation on the way I did it? > > Cheers > > Aldian > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > http://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list rules-users@lists.jboss.org http://lists.jboss.org/mailman/listinfo/rules-users