Adding this rule attribute will fire the rule only once. Still, you won&#39;t be able to tell from the two titles which one is the odd-man-out. Also, if there are two or more violations, it won&#39;t show either.<br><br>
rule &quot;check-same&quot;<br>
    activation-group &quot;one-shot&quot;<br>
when<br>
    ...<br><br>Otherwise, duplicate firings for a pair can be eliminated by adding a constraint that reduces activations to a specific order of a pair; for this you&#39;ll need an attribute in your Fact that can be compared with &#39;&lt;&#39;, to wit:<br>
<br>   $p1 : Fact( $n1 : num, $t1 : title, $g1 : groupNames, $p1 : propNames )<br>   $p2 : Fact( num &gt; $n1, $t2 : title,  ( groupNames != $g1 || propNames != $p1 ) )<br><br>As for your question (&quot;comparing sets&quot;), I suggest that you write a simple wrapper class, say, class PropNameSet, with a single attribute Set&lt;String&gt; names. Then you might write rules such as<br>
<br>rule &quot;make set&quot;<br>
    when<br>
        $f1 : Fact( $p1 : propNames )<br>        not PropNameSet()                           // not Set()<br>
    then<br>


        insert( new PropNameSet( $p1 ) );  // insert( $p1 );<br>
    end<br><br>
rule &quot;check-names&quot;<br>
    when<br>        PropNameSet( $names : names )                           // $names : Set()<br>
        $f1 : Fact( $t1 : title, propNames != $names )<br>
    then<br>


        System.out.println( &quot;mismatch &quot; + $t1  );<br>
    end<br>
<br>You could also use the indicated alternative with the raw Set as a fact, but there is a fairly obvious disadvantage: not Set() is a very general condition.<br><br>Note that the PropNameSet will be derived from an arbitrary Fact; thus the mismatch might occur repeatedly, and for the good ones.<br>
<br>-W<br><br><br><br><div class="gmail_quote">2009/5/15 Ian Spence <span dir="ltr">&lt;<a href="mailto:ianspence@gmail.com">ianspence@gmail.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;">
Wolfgang and all,<br><br>Your suggestion did work.  Thank you for that.  I am learning more as I go along.<br><br>I am thinking of another approach now.  To populate working memory with a Set of all names &quot;allNames&quot;; call fireAllRules; then in the DRL, for each Title compare Proprietor names (set) with &quot;allNames&quot;.<br>

<br>How can I compare 2 sets like this in a DRL ?<br><br>Ian Spence<br><br><div class="gmail_quote">2009/5/14 Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.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;">Assuming that your facts are structured as the indentation suggests, I would solve this using a technique you could call &quot;virtual field&quot;. So, if a fact object has fields <br>

   String title<br>   List&lt;PropGroup&gt; pgList<br>
<br>and a PropGroup has fields<br>  String name<br>  List&lt;String&gt; pList<br><br>I would not try to get at the embedded data from the objects contained within List&lt;PropGroup&gt;. Rather, I&#39;d add a couple of getters to your Fact class, each of which would return a Set&lt;String&gt; computed from the contained List&lt;PropGroup&gt;. Then the rule simply becomes<br>


<br>rule &quot;check-same&quot;<br>    when<br>        $p1 : Fact( $t1 : title, $g1 : groupNames, $p1 : propNames )<br>        $p2 : Fact( this != $p1, $t2 : title,  ( groupNames != $g1 || propNames != $p1 ) )<br>    then<br>


        System.out.println( &quot;mismatch &quot; + $t1 + &quot; and &quot; + $t2 );<br>    end<br><br>Notice that this won&#39;t find the odd-man-out; it will fire twice for each unequal pair.<br><br>-W<div><div></div><div class="h5">
<br><br><br><div class="gmail_quote">

2009/5/14 Ian Spence <span dir="ltr">&lt;<a href="mailto:ianspence@gmail.com" target="_blank">ianspence@gmail.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><div></div><div>
<div class="gmail_quote"><div link="blue" vlink="purple" lang="EN-AU"><div><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"></span></font><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Hello all,</span></font>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I am new to Drools…</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I have a scenario</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Each fact object will have the structure:</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">Title</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">   Proprietor Group</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">      Proprietor Name</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">E.g.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">           
2100-100</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                       
J2 ˝ share</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
SMITH, JOHN</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
JONES, FRED</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                       
T ˝ share</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
BROWN, CHARLIE</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">           
2100-101</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                       
J2 ˝ share</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
BROWN, CHARLIE</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
JONES, FRED</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                       
T ˝ share</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
SMITH, JOHN</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">           
2100-102</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                       
T ˝ share</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
BROWN, CHARLIE</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                       
J2 ˝ share</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
JONES, FRED</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">                                   
SMITH, JOHN</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">The group names and the proprietor names must be the same
across each Title.  The scenario above is a valid case. A failed case would
result for Title 2100-100 if we add an extra Proprietor name e.g. WHITE, MARY.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;">I anticipate having one rule to cater for this.  I am
hedging towards the ‘collect’ operator but cannot get a clear
picture on how to implement it.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size: 10pt; font-family: Arial;"><br></span></font></p></div>-- <br></div>


</div>Regards,<br><font color="#888888">Ian Spence<br><br><br>
</font><br></div></div>_______________________________________________<br>
rules-users mailing list<div><br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
</div><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>
<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><br>
<br></div></div></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br><font color="#888888">Ian Spence<br><br><br>
</font><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>