It&#39;s pointless to discuss (non-existent) technical solutions without knowing what the problem is.<br><br>So far:<br><ul><li>a set of Document objects should be selected for processing. </li><li>selection can be based on any of the Document properties</li>
<li>the actual property value is contained in an object ConditionMatrix</li></ul>Why should processing of documents selected according to &quot;privateName&quot; combined with those selected according to &quot;legal&quot;?<br>
<br>Otherwise, what is to be gained by &quot;combining&quot;?<br><br>-W<br><br><br><div class="gmail_quote">2011/5/25 Hezi Stern <span dir="ltr">&lt;<a href="mailto:hezis@delegatecom.com">hezis@delegatecom.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Thanks for the reply, I think I was a bit vague with my question (my apologies on this) I will try to elaborate further</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I have several set of rules that filter, each filters a different set of conditions (e.g. User, Date, Country…). </span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">I would like to construct rules that based on conditions in the ConditionMatrix (in my example) I would like to set a specific rule set.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">A wishful thinking approach would be something like:</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Following are 2 filter rules</span></p><p class="MsoNormal">
<span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Rule “filter user”</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);"> </span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">When</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">            $cm:                                      ConditionMatrix(),</span></p><p class="MsoNormal">
<span style="color: rgb(85, 142, 213);"> </span></p><p class="MsoNormal" style="text-indent: 0.5in;"><span style="color: rgb(85, 142, 213);">$document:                       ArrayList() from collect ( Document (user.isPrivateName  == $cm.user.isPrivateName) )</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">                                                                                                                                                                                                                </span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Then</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">                </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">End</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Rule “filter date”</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">When</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">            $cm:                                  ConditionMatrix(),</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);"> </span></p><p class="MsoNormal" style="text-indent: 0.5in;">
<span style="color: rgb(85, 142, 213);">$document:                       ArrayList() from collect ( Document (date.isLegal == $cm.date.isLegal) )</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">                                                                                                                                                                                                                </span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Then</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">                //do something</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">End</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">The actual rule that utilized them would like :</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Rule “I am happy” extends “filter date”</span><span style="font-size: 11pt; color: rgb(31, 73, 125);"></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">When</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">                        $cm:     ConditionMatrix(),</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Then</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">            //Do something</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">End</span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">And a second rule can look like: (note that even if I can extend two rules then there is a conflict on $</span><span style="color: rgb(85, 142, 213);"> </span><span style="font-size: 11pt; color: rgb(31, 73, 125);">document</span><span style="color: rgb(85, 142, 213);">)</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Rule “I am sad” extends “filter date”,  “filter user”</span><span style="font-size: 11pt; color: rgb(31, 73, 125);"></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">When</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">                        $cm:     ConditionMatrix(),</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);"> </span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Then</span></p><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">            //Do something</span></p>
<p class="MsoNormal"><span style="color: rgb(85, 142, 213);">End</span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Hope this clearer now.</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Thanks</span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Hezi</span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;"> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of </b>Wolfgang Laun<br>
<b>Sent:</b> Wednesday, May 25, 2011 6:18 PM<br><b>To:</b> Rules Users List<br><b>Subject:</b> Re: [rules-users] Concatenating rule conditions</span></p><div><div></div><div class="h5"><p class="MsoNormal"> </p><p class="MsoNormal" style="margin-bottom: 12pt;">
Just for the heck of it, here&#39;s two more ways for &quot;comibining&quot; those two rules. (Gee, what a vague specification!)<br><span style="color: rgb(85, 142, 213);"><br># straightforwardly doing both in one<br>rule comb1<br>
when<br>   $cm: ConditionMatrix()<br>   $docs1: ArrayList() from collect( Document( ... ) )<br>   $docs2: ArrayList() from collect( Document( ... ) )<br>then ... end<br><br># abstraction<br>rule comb2<br>when<br>   $cm: ConditionMatrix()<br>
   $filter: Filter()<br>   $docs: ArrayList() from collect( $d: Document() eval( $filter.pass( $cm, $d ) ) )<br>then ... end<br><br>-W<br><br><br></span></p><div><p class="MsoNormal">2011/5/25 Vincent Legendre &lt;<a href="mailto:vincent.legendre@eurodecision.com" target="_blank">vincent.legendre@eurodecision.com</a>&gt;</p>
<div><p class="MsoNormal">Not sure of what you exactly ...<br><br>If you want to combine tests, you can write this : </p><div><div><p class="MsoNormal"><span style="color: rgb(85, 142, 213);">Rule “test filter”</span><br>
<span style="color: rgb(85, 142, 213);">When</span><br><span style="color: rgb(85, 142, 213);">      $cm:  ConditionMatrix()</span></p></div><p class="MsoNormal" style="margin-bottom: 12pt;"><span style="color: rgb(85, 142, 213);">      $document:   ArrayList() from collect ( Document (user.isPrivateName  == $cm.isPrivateName, Payment.isLegal == $cm.isLegal) )                                                              </span><br>
<span style="color: rgb(85, 142, 213);">Then</span><br><span style="color: rgb(85, 142, 213);">                //do something</span><br><span style="color: rgb(85, 142, 213);">End</span></p></div><p class="MsoNormal">If you want to make the filter more dynamic and write only one &quot;collect&quot; rule, I don&#39;t see any out-of-the-box method.<br>
You can add a method in ConditionMatrix that accepts a Document and write this rule :</p><div><p class="MsoNormal"><br><span style="color: rgb(85, 142, 213);">Rule “test filter”</span><br><span style="color: rgb(85, 142, 213);">When</span><br>
<span style="color: rgb(85, 142, 213);">      $cm:  ConditionMatrix()</span></p></div><p class="MsoNormal" style="margin-bottom: 12pt;"><span style="color: rgb(85, 142, 213);">      $document:   ArrayList() from collect ( Document (eval($cm.accept(this)) ) )                                                              </span><br>
<span style="color: rgb(85, 142, 213);">Then</span><br><span style="color: rgb(85, 142, 213);">                //do something</span><br><span style="color: rgb(85, 142, 213);">End</span><br><br>Of course you have to implement the &quot;accept&quot; method in Java (and you can then do several sub-classes for you filters)</p>
</div><p class="MsoNormal" style="margin-bottom: 12pt;"><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></p></div><p class="MsoNormal"> </p></div></div></div></div><br>_______________________________________________<br>

rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>