[jboss-jira] [JBoss JIRA] (DROOLS-627) Rule with two accumulate followed by object type selection fail to fire rule

Anantjot Anand (JIRA) issues at jboss.org
Mon Oct 6 21:13:11 EDT 2014


Anantjot Anand created DROOLS-627:
-------------------------------------

             Summary: Rule with two accumulate followed by object type selection fail to fire rule
                 Key: DROOLS-627
                 URL: https://issues.jboss.org/browse/DROOLS-627
             Project: Drools
          Issue Type: Bug
    Affects Versions: 6.2.0.Beta1, 6.1.0.Final
            Reporter: Anantjot Anand
            Assignee: Mark Proctor


A rule with two accumulate function followed by Type(true) select fails to fire the rule.

import java.lang.*;
import java.util.*;
import com.test.unittest.TestTwoAccumulateEval.TypeA;  
import com.test.unittest.TestTwoAccumulateEval.TypeB;  
import com.test.unittest.TestTwoAccumulateEval.TypeC;  
import com.test.unittest.TestTwoAccumulateEval.TypeD;  
import com.test.unittest.TestTwoAccumulateEval.TypeDD;  

rule R0
dialect "java"
when  
   $a : TypeA( )  
   $b : TypeB( parentId == $a.id)  
   $c : TypeC( parentId == $b.id ) 
   $d : TypeD( parentId == $c.id, firings not contains "Rule R0 Fired" ) 
then  
	System.out.println("Rule R0 Fired");
	$d.setValue(1.0);
	$d.getFirings().add("Rule R0 Fired");
	update($d);  
end   

rule R1 
dialect "java"
when  
   $a : TypeA( )  
   $b : TypeB( parentId == $a.id)  
   $c : TypeC( parentId == $b.id, firings not contains "Rule R1 Fired" ) 
   $d : TypeD( parentId == $c.id)
   // Aggregate function [sum] creates a separate context 
	$sumOfAll_1 : Double(doubleValue != Double.MAX_VALUE) from accumulate (
	$a_C1 : TypeA(  ) 
	
	and
	$b_C1 : TypeB( parentId == $a_C1.id)  
    
    and
    $c_C1 : TypeC( parentId == $b_C1.id )
	
	and
	$d_C1 : TypeD( parentId == $c_C1.id , $value_C1 : value , value != 0 ) 
	;sum($value_C1))
    // end of sum aggregation
    
    // Aggregate function [sum] creates a separate context 
	$sumOfAll_2 : Double(doubleValue != Double.MAX_VALUE) from accumulate (
	$a_C2 : TypeA(  ) 
	
	and
	$b_C2 : TypeB( parentId == $a_C2.id)  
    
    and
    $c_C2 : TypeC( parentId == $b_C2.id )
	
	and
	$dd_C2 : TypeDD( parentId == $c_C2.id , $value_C2 : value , value != 0 ) 
	;sum($value_C2))
    // end of sum aggregation

	//eval(($sumOfAll_1 + $sumOfAll_2) > 0)
	//eval returns true however TypeA(true) evaluates to false...removing second aggregate
	//makes TypeA works
	TypeA(eval(($sumOfAll_1 + $sumOfAll_2) > 0))		
then  
	System.out.println("Rule R1 Fired");
	$c.getFirings().add("Rule R1 Fired");
	update($c);  
end



--
This message was sent by Atlassian JIRA
(v6.3.1#6329)


More information about the jboss-jira mailing list