[rules-users] How check if all the values in a collection match a criteria

Alessandro Di Bella aldibella at gmail.com
Sun May 18 13:04:10 EDT 2008


Hi,

I have these two classes:

ExpenseReport{
   Collection<ExpenseDetails> expenseDetails
} 

ExpenseDetails{   
   ExpenseReport document
   ExpenseType expenseType
}

I am trying to create a rule that fires when all the ExpenseDetails in a
ExpenseReport  are of the same type:

rule "Do Not Process TAX"		 
	when
		$report: ExpenseReport($expenseDetails: expenseDetails)	
		forall (			
			ExpenseDetails(document==$report, expenseType == ExpenseType.TAX)
		)  
	then
		System.out.println("################ It works ##################");
		insertLogical("Bypass Process");
end

For some reasons, it fires regardless that value of
ExpenseDetails.expenseType.

I just started with drools and any help i more than welcome.

Thanks




More information about the rules-users mailing list