[jboss-jira] [JBoss JIRA] (DROOLS-173) Collect and accumulate conditions not working together

Mario Fusco (JIRA) jira-events at lists.jboss.org
Wed Nov 13 05:10:05 EST 2013


     [ https://issues.jboss.org/browse/DROOLS-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mario Fusco reassigned DROOLS-173:
----------------------------------

    Assignee: Mario Fusco  (was: Mark Proctor)

    
> Collect and accumulate conditions not working together
> ------------------------------------------------------
>
>                 Key: DROOLS-173
>                 URL: https://issues.jboss.org/browse/DROOLS-173
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 6.0.0.Beta3
>            Reporter: Alvaro Pantoja
>            Assignee: Mario Fusco
>         Attachments: rule-test.log
>
>
> Running this example:
> {code}
> 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
> {code}
> 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:
> {quote}
>     Sum: 160.0
>     Items size: 4
>     Sum: 120.0
>     Items size: 3
> {quote}
> But is:
> {quote}
>     Sum: 160.0
>     Items size: 4
>     Sum: 120.0
>     Items size: 4
>     Sum: 120.0
>     Items size: 3
> {quote}
> Find attached agenda and working memory log snapshot

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list