I would like to generate a template that can output rules, as explained in Drools expert user guide at chapter 5.2 (<a href="http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e6212">http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e6212</a>).<div>
My parameters are 2 lists of strings. In some case the list is to be outputted as a &quot;multi restriction&quot;, and that is no problem. </div><div>But, from one of this lists, i need also to generate a collection of strings to then reason over.</div>
<div>As an example, suppose the list1 contains 3 productIds, &quot;A&quot;,&quot;B&quot;,&quot;C&quot;, and the list2 contains &quot;X&quot; and &quot;Y&quot;.</div><div>In the generated rule, i need to check, for example, that: </div>
<div><ul><li>if a product with id &#39;X&#39; or &#39;Y&#39; exists (this part is easy), </li></ul></div><div>and </div><div><ul><li>a tuple composed of products from the other list(one &quot;A&quot;, one &quot;B&quot;, one &quot;C&quot;) that individually satisfy some condition exists (this is tough for me)</li>
</ul>then i will execute my code.</div><div><br>I think the generated rule should be something like:</div><div><br></div><div>when</div><div>    $target: Product (id in (&quot;X&quot;,&quot;Y&quot;))</div><div>    $list: ArrayList() from ????  #arrayList should contain the parameter values &quot;A&quot;,&quot;B&quot;,&quot;C&quot;</div>
<div>    forall ( $id: String() from $list</div><div>             Product (id == $id, ....here some condition...)</div><div>    )</div><div>then</div><div>   .....</div><div><br></div><div>The difficult part is to generate the ArrayList dynamically, i don&#39;t know how to accomplish that...</div>
<div>Any ideas? Is there a better approach than templates, to generate a rule like this?</div><div>Do you have a suggestion on how the rule could be rewritten to avoid the use of the ArrayList?</div><div>Thank you in advance</div>
<div>Giovanni</div><div><br></div>