Nah thats not gonna work, because I'm using
an ArrayList as a global variable. I'm adding 
and removing ODMAnswers in it and always want to
check if there are 2 ODMAnswers in it, to remove 
them and generate a new one.

Of course I differ them in their properties, just
wanted to keep the problem simple and understandable.

Do you got another option than creating a local 
$list variable?

----- Ursprüngliche Mail -----
Von: "Jeremy Ary" <[email protected]>
An: "Rules Users List" <[email protected]>
Gesendet: Mittwoch, 16. Januar 2013 17:54:32
Betreff: Re: [rules-users] Test for element in an arraylist



I should note that hopefully you can limit this to something like $list : 
ODAList ( ) (a specific extends type of list where you could specify some 
criteria to be more specific with) or can assure that you only have one List in 
play at that time, or you're going to spend some execution going through every 
List in memory to check for these occurrences. 


Jeremy 



On Wed, Jan 16, 2013 at 10:50 AM, Jeremy Ary < [email protected] > wrote: 



Argh...Sorry, wrong key too early...here's the full changes: 


rule "Combine ODMAnswers" 

when 
$list : List( ) 
$a1:ODMAnswer( some check ) from $list $a2:ODMAnswer( assuming something making 
this one different than $a1 ) from $list 
then 
$list.add( new ODMAnswer( ) ); 
$list.remove($a1); 
$list.remove($a2); 
end 






On Wed, Jan 16, 2013 at 10:47 AM, Jeremy Ary < [email protected] > wrote: 




Try this; 


rule "Combine ODMAnswers" 

when 
$a1:ODMAnswer( some check ) 
$a2:ODMAnswer( assuming something making this one different than $a1 ) 



eval(odmList contains $a1 && odmList contains $a2) 
then 
ODMAnswer answer = new ODMAnswer( ); 
odmList.add(answer); 
odmList.remove($a1); 
odmList.remove($a2); 
end 





On Wed, Jan 16, 2013 at 10:41 AM, Bojan Janisch < 
[email protected] > wrote: 



rule "Combine ODMAnswers" 

when 
$a1:ODMAnswer( ) 
$a2:ODMAnswer( ) 

eval(odmList contains $a1 && odmList contains $a2) 
then 
ODMAnswer answer = new ODMAnswer( ); 
odmList.add(answer); 
odmList.remove($a1); 
odmList.remove($a2); 
end 




_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to