[rules-users] How to Iterate list in drools

2010-07-30 Thread Dinesh kumar

Hi,

I am facing problems in iterating a list in guvnor.

I tried the following code and it worked.

import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when
ClaimRegistration($ailmentList : ailmentListFromScreen)
then
for(String ailment : (ArrayListString) $ailmentList){
System.out.println(ailment  +ailment);
}
System.out.println(then);
end


But my requirement is to iterate the list in the when block and process
something based on the data in the list.

It should be something like 

import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when

ClaimRegistration($ailmentList : ailmentListFromScreen)
for(String ailment : (ArrayListString) $ailmentList){
System.out.println(ailment  +ailment);
// My condition needs to be evaluated here
}
then

System.out.println(then);

end


Need help on this issue. Is this possible in Drools? 
kindly advice.

Regards,
Dinesh

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Iterate-list-in-drools-tp1008987p1008987.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to Iterate list in drools

2010-07-30 Thread Esteban Aliverti
You might be looking for accumulate or collect patterns. You will find all
the information you need in the manual.

Best,

El jul 30, 2010 11:22 a.m., Dinesh kumar din...@gmail.com escribió:


Hi,

I am facing problems in iterating a list in guvnor.

I tried the following code and it worked.

import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when
ClaimRegistration($ailmentList : ailmentListFromScreen)
then
for(String ailment : (ArrayListString) $ailmentList){
   System.out.println(ailment  +ailment);
}
System.out.println(then);
end


But my requirement is to iterate the list in the when block and process
something based on the data in the list.

It should be something like

import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when

ClaimRegistration($ailmentList : ailmentListFromScreen)
for(String ailment : (ArrayListString) $ailmentList){
   System.out.println(ailment  +ailment);
   // My condition needs to be evaluated here
}
then

System.out.println(then);

end


Need help on this issue. Is this possible in Drools?
kindly advice.

Regards,
Dinesh

--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Iterate-list-in-drools-tp1008987p1008987.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users