[rules-users] Bulk modification

Rodrigo Goncalves rodrigo.goncalves at coffeebeantech.com
Tue Aug 30 21:39:17 EDT 2011


Hi,

How can I modify all objects resulted from a collect operation?

I would like to do something like this: (The following does not work)

rule "test"
  when
	exists (MyClass());
	$l : ArrayList() from collect (MyClass (attribute == false));
	$r : AnotherClass();
  then
	$r.doSomething($l);
	for(Object o : $l) {
		MyClass o2 = (MyClass) o;
		modify(o2) { setAttribute(true); } ;
	}
  end


I do not want to do:
rule "test"
	when
		$o : MyClass(attribute == false)
		$r : AnotherClass()
	then
		$r.doSomething($o);
		modify(o) {setAttribute(true);};
end

because I need to do a bulk operation… Doing it one by one is extremely inefficient in my case.

Thanks!

Rodrigo.		



More information about the rules-users mailing list