<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText>Hi Wolfgang,<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Thanks for your response.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Here is the rule that I had written for the file.&nbsp; <o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoNormal style='text-autospace:none'><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>rule</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;Id != value&quot;</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>when</span></b><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plc : DailyPLC(Id!=</span><span style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;1794&quot;</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp; </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>then</span></b><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(</span><span style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot;Incorrect ID &quot;</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> + plc.getId()+ </span><span style='font-size:10.0pt;font-family:"Courier New";color:green'>&quot; at row : &quot;</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> + plc.getRowNumber());</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><b><span style='font-size:10.0pt;font-family:"Courier New";color:#960000'>end</span></b><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Any pointers shall be really very helpful. &nbsp;<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Regards,<o:p></o:p></p><p class=MsoPlainText>Amal<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>-----Original Message-----<br>From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Wolfgang Laun<br>Sent: Tuesday, June 12, 2012 3:57 PM<br>To: Rules Users List<br>Subject: Re: [rules-users] Firing the rules in a sequence for all the items in an ArrayList.</p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Your question can't be answered without the rules. - If your Java code does what you say it does, then it should be OK.<o:p></o:p></p><p class=MsoPlainText>-W<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>On 12/06/2012, Amal Gupta &lt;<a href="mailto:Amal_Gupta@infosys.com"><span style='color:windowtext;text-decoration:none'>Amal_Gupta@infosys.com</span></a>&gt; wrote:<o:p></o:p></p><p class=MsoPlainText>&gt; Hello,<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; I am new to Java and Drools and have a doubt regarding the sequence of <o:p></o:p></p><p class=MsoPlainText>&gt; rules' execution as stated below :-<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Scenario:- I have a scenario wherein I have to apply multiple rules on <o:p></o:p></p><p class=MsoPlainText>&gt; multiple columns coming in a file. To simulate that I created a 2-D <o:p></o:p></p><p class=MsoPlainText>&gt; array as follows<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; String[][] data =&nbsp; {<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&quot;1791&quot;,&quot;8459625&quot;,&quot;78458745&quot;,&quot;20120610&quot;,&quot;20120610&quot;<o:p></o:p></p><p class=MsoPlainText>&gt; },<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&quot;1792&quot;,&quot;8459623&quot;,&quot;78458745&quot;,&quot;20120610&quot;,&quot;20120610&quot;<o:p></o:p></p><p class=MsoPlainText>&gt; },<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&quot;1793&quot;,&quot;8459624&quot;,&quot;78458745&quot;,&quot;20120610&quot;,&quot;20120610&quot;<o:p></o:p></p><p class=MsoPlainText>&gt; },<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; {&quot;17944&quot;,&quot;8459626&quot;,&quot;78458745&quot;,&quot;20120610&quot;,&quot;20120610&quot;}<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Here each column of corresponds to a member for the following class<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; public class DailyPLC {<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String Id;&nbsp;&nbsp;&nbsp; // This value will correspond to data[i][0]<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String productCode; // This value will correspond to <o:p></o:p></p><p class=MsoPlainText>&gt; data[i][1]<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String customerCode; // This value will correspond to <o:p></o:p></p><p class=MsoPlainText>&gt; data[i][2]<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String date1; // This value will correspond to data[i][3]<o:p></o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String date2; // This value will correspond to <o:p></o:p></p><p class=MsoPlainText>&gt; data[i][4]<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private int rowNumber; // The row number to keep a track of row <o:p></o:p></p><p class=MsoPlainText>&gt; for which the record exists<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*Getters and Setters defined for each of them*/ }<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; I have to perform checks on each of the columns, and the intent is to <o:p></o:p></p><p class=MsoPlainText>&gt; create all the rules that I need for the entire array and save it in a <o:p></o:p></p><p class=MsoPlainText>&gt; single drl file. Also, at the execution time, all the rules should be <o:p></o:p></p><p class=MsoPlainText>&gt; applied - either at once or sequentially - to all the rows of the data.<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Approach:-&nbsp; I tried the following<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Created an ArrayList<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; ArrayList&lt;DailyPLC&gt; alPLCArrayList = new ArrayList&lt;DailyPLC&gt;();<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iterated over the data and stored each row into a field of the<o:p></o:p></p><p class=MsoPlainText>&gt; object of DailyPLC class.<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For every iteration, added the object into the array list.<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; alPLCArrayList.add(plcToday);&nbsp; // The plcToday is the object of the <o:p></o:p></p><p class=MsoPlainText>&gt; DailyPLC class<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; 4.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; When executing the rules, I am adding all the items of the<o:p></o:p></p><p class=MsoPlainText>&gt; ArrayList one by one and adding into the Knowledge Session.<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; for(DailyPLC d : alPLCArrayList)<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.insert(d);<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Problem Faced :- The problem that I faced is that when I do <o:p></o:p></p><p class=MsoPlainText>&gt; FireAllRules, the rule only validates the last record. The intent is <o:p></o:p></p><p class=MsoPlainText>&gt; that it should traverse the list and give a result for all the members of the list.<o:p></o:p></p><p class=MsoPlainText>&gt; Have I missed something here?<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Please assist.&nbsp; Let me know in case you need any more information<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; Thanks in Advance,<o:p></o:p></p><p class=MsoPlainText>&gt; Amal Gupta<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; **************** CAUTION - Disclaimer ***************** This e-mail <o:p></o:p></p><p class=MsoPlainText>&gt; contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; for the use of the addressee(s). If you are not the intended <o:p></o:p></p><p class=MsoPlainText>&gt; recipient, please notify the sender by e-mail and delete the original <o:p></o:p></p><p class=MsoPlainText>&gt; message. Further, you are not to copy, disclose, or distribute this <o:p></o:p></p><p class=MsoPlainText>&gt; e-mail or its contents to any other person and any such actions are <o:p></o:p></p><p class=MsoPlainText>&gt; unlawful. This e-mail may contain viruses. Infosys has taken every <o:p></o:p></p><p class=MsoPlainText>&gt; reasonable precaution to minimize this risk, but is not liable for any <o:p></o:p></p><p class=MsoPlainText>&gt; damage you may sustain as a result of any virus in this e-mail. You <o:p></o:p></p><p class=MsoPlainText>&gt; should carry out your own virus checks before opening the e-mail or <o:p></o:p></p><p class=MsoPlainText>&gt; attachment. Infosys reserves the right to monitor and review the <o:p></o:p></p><p class=MsoPlainText>&gt; content of all messages sent to or from this e-mail address. Messages <o:p></o:p></p><p class=MsoPlainText>&gt; sent to or from this e-mail address may be stored on the Infosys <o:p></o:p></p><p class=MsoPlainText>&gt; e-mail system.<o:p></o:p></p><p class=MsoPlainText>&gt; ***INFOSYS******** End of Disclaimer ********INFOSYS***<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>_______________________________________________<o:p></o:p></p><p class=MsoPlainText>rules-users mailing list<o:p></o:p></p><p class=MsoPlainText><a href="mailto:rules-users@lists.jboss.org"><span style='color:windowtext;text-decoration:none'>rules-users@lists.jboss.org</span></a><o:p></o:p></p><p class=MsoPlainText><a href="https://lists.jboss.org/mailman/listinfo/rules-users"><span style='color:windowtext;text-decoration:none'>https://lists.jboss.org/mailman/listinfo/rules-users</span></a><o:p></o:p></p></div></body></html>