-
Bug
-
Resolution: Done
-
Major
-
6.0.0.Beta3
-
None
-
None
Running this example:
import java.util.ArrayList declare Item code: int price: int present: boolean end rule "Init" when then insert(new Item(1,40,false)); insert(new Item(2,40,false)); insert(new Item(3,40,false)); insert(new Item(4,40,false)); end rule "CollectAndAccumulateRule" when //At least two items that aren't presents objList: ArrayList(size>=2) from collect( Item(present==false)) //Total price bigger than 100 price: Number(intValue>=100) from accumulate( Item($w:price, present==false), sum($w)) then System.out.println("Sum: "+price); System.out.println("Items size: "+objList.size()); //Look for the minor price item Item min = null; for(Object obj: objList){ if (min!=null){ min = (min.getPrice()>((Item)obj).getPrice())?(Item)obj:min; } else { min = (Item)obj; } } //And make it a present if (min!=null){ modify(min){setPresent(true)}; } end
Leads to an extra activacion and execution of rule "CollectAndAccumulateRule". It doesn't matter wich order conditions are, as long as there are both "accumulate" and a "collect".
Expected output would be:
Sum: 160.0
Items size: 4
Sum: 120.0
Items size: 3
But is:
Sum: 160.0
Items size: 4
Sum: 120.0
Items size: 4
Sum: 120.0
Items size: 3
Find attached agenda and working memory log snapshot