[rules-users] How to Iterate list in drools

Esteban Aliverti esteban.aliverti at gmail.com
Fri Jul 30 11:03:58 EDT 2010


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" <dinp87 at 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 : (ArrayList<String>) $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 : (ArrayList<String>) $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 at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100730/ed1060d2/attachment.html 


More information about the rules-users mailing list