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

Massinissa BOUZIAD (JIRA) issues at jboss.org
Wed Dec 23 04:02:00 EST 2015


    [ https://issues.jboss.org/browse/DROOLS-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13143739#comment-13143739 ] 

Massinissa BOUZIAD edited comment on DROOLS-173 at 12/23/15 4:01 AM:
---------------------------------------------------------------------

Hi guys,
Anyone can help is welcome.
I try to use the collect function within a rules like that : 
{code:title=My rule not working |borderStyle=solid}
$combinedParts : List(size >= 2)  // >= not work
        from collect(CombinedPart(
            /* here my eligibility checks */
        )
    )
{code}

{code:title=My rule working |borderStyle=solid}
$combinedParts : List(size == 2)  // == work
        from collect(CombinedPart(
            /* here my eligibility checks */
        )
    )
{code}

The operator ">="  seems to not work whereas "==" work and ">" work also.

I got this stack trace wich make me confused : 

{code:title=My stack | borderStyle=solid}

java.lang.NoSuchMethodError: org.mvel2.compiler.BlankLiteral.<init>(Ljava/lang/String;)V
	at ConditionEvaluatore065b53056eb4e34a7d0e895676d67a1.evaluate(Unknown Source)
	at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:248)
	at org.drools.core.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:204)
	at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
	at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:494)
	at org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:384)
	at org.drools.core.reteoo.ObjectTypeNode.propagateAssert(ObjectTypeNode.java:298)
	at org.drools.core.phreak.PropagationEntry$Insert.execute(PropagationEntry.java:93)
	at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:96)
	at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:69)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.flushPropagations(StatefulKnowledgeSessionImpl.java:1993)
	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:128)
	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)
	at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:978)
	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1292)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1294)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1281)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1260)
{code}

Thank you




was (Author: massinissa):
Hi guys,
Anyone can help is welcome.
I try to use the collect function within a rules like that : 
{code:title=My rule not working |borderStyle=solid}
$combinedParts : List(size >= 2)  // >= not work
        from collect(CombinedPart(
            /* here my eligibility checks */
        )
    )
{code}

{code:title=My rule working |borderStyle=solid}
$combinedParts : List(size == 2)  // >= work
        from collect(CombinedPart(
            /* here my eligibility checks */
        )
    )
{code}

The operator ">="  seems to not work whereas "==" work and ">" work also.

I got this stack trace wich make me confused : 

{code:title=My stack | borderStyle=solid}

java.lang.NoSuchMethodError: org.mvel2.compiler.BlankLiteral.<init>(Ljava/lang/String;)V
	at ConditionEvaluatore065b53056eb4e34a7d0e895676d67a1.evaluate(Unknown Source)
	at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:248)
	at org.drools.core.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:204)
	at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
	at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:494)
	at org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:384)
	at org.drools.core.reteoo.ObjectTypeNode.propagateAssert(ObjectTypeNode.java:298)
	at org.drools.core.phreak.PropagationEntry$Insert.execute(PropagationEntry.java:93)
	at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:96)
	at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:69)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.flushPropagations(StatefulKnowledgeSessionImpl.java:1993)
	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:128)
	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)
	at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:978)
	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1292)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1294)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1281)
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1260)
{code}

Thank you



> Collect and accumulate conditions not working together
> ------------------------------------------------------
>
>                 Key: DROOLS-173
>                 URL: https://issues.jboss.org/browse/DROOLS-173
>             Project: Drools
>          Issue Type: Bug
>    Affects Versions: 6.0.0.Beta3
>            Reporter: Alvaro Pantoja
>            Assignee: Mario Fusco
>             Fix For: 6.0.0.Final
>
>         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 was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list