All simple field constraints (the expressions you write between commas in a pattern) must follow the same<br>syntactic pattern, which is<br><br>  [ &lt;variable&gt; &#39;:&#39; ] &lt;fieldname&gt; &lt;restriction&gt;<br><br>
This means that you may use a binding (e.g. &quot;$foo :&quot;), but the next thing must be a field name from the<br>fact class. The &lt;restriction&gt; can have many forms; one of them is a name denoting an operator<br>followed by the other operand, where you have a little more freedom, e.g., by using a bound variable<br>
or an access to a field or other forms.<br><br>Hence, not being able to reverse the operands of subsetOf is not a compiler bug; it is a (perhaps<br>regrettable) consequence of the overall structure of constraints.<br><br>
Thus, if you need an operator supersetOf (which is to subsetOf just like &gt;= is to &lt;=) you&#39;ll have<br>to define it, too. This is simple, since it is practically the same as subsetOf, with some operand<br>swapping down in the works.<br>
<br>Cheers<br>Wolfgang<br><br><br><br><div class="gmail_quote">2010/10/14 Kumar Pandey <span dir="ltr">&lt;<a href="mailto:kumar.pandey@gmail.com">kumar.pandey@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;">
Thanks for this tip. <div>This works but only if the second rule&#39;s  $f.numbers is on the RHS and numbers is on the LHS of the subsetOf operator.<div>i.e <span style="font-family: &#39;courier new&#39;,monospace;"> Element(name=&quot;Super set - Rule 1&quot;, </span><span style="font-family: &#39;courier new&#39;,monospace;">numbers</span><span style="font-family: &#39;courier new&#39;,monospace;"> subsetOf </span><span style="font-family: &#39;courier new&#39;,monospace;">$f.</span><span style="font-family: &#39;courier new&#39;,monospace;">numbers</span><span style="font-family: &#39;courier new&#39;,monospace;">)</span></div>

<div><div><div><br></div><div>Which is what I want in my case (to check if values in the fact is subset of values in the rule).</div><div><br></div><div>If I wanted it the other way round though the compiler seems to disapprove.</div>

<div><br></div><div>I get a compiler error like so --</div><div><br></div><div><div><div>java.lang.RuntimeException: Unable to compile rule</div><div>Unable to determine the used declarations.</div><div>[Error: unknown class or illegal statement: org.mvel2.ParserContext@1aed5f9]</div>

<div>[Near : {... <span style="font-family: &#39;courier new&#39;,monospace;">$f.</span><span style="font-family: &#39;courier new&#39;,monospace;">numbers</span> subsetOf dat ....}]</div></div><div>                                      </div>

<div><div>If you try the Wolfgang&#39;s example and in the rule swap check like so - <span style="font-family: monospace; font-size: 17px; white-space: pre-wrap;">s1 disjoint numbers </span></div><div>
<br></div><div><span style="font-family: &#39;Times New Roman&#39;; font-size: medium;"><pre style="font-size: 1.3em; background-color: rgb(255, 204, 204); padding-left: 25px;">e2: Element( this != e1, n2 : name, s1 disjoint numbers )</pre>

</span></div><div>then you get error like so </div><div><br></div><div><div>Unable to create Field Extractor for &#39;s1&#39; of &#39;[ClassObjectType class=com.test.context.Element]&#39; in rule &#39;find disjoint pairs&#39; : [Rule name=&#39;find disjoint pairs&#39;]</div>

</div><div><br></div><div>Sounds like a compiler bug as the operation should be commutative right?</div><div><br></div><div><br></div><div>Thanks</div><div><div><div></div><div class="h5">Kumar<br><div class="gmail_quote">
2010/10/13 Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com" target="_blank">michael.anstis@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;">
OK, unless I&#39;m missing something else you should be able to do something like this:-<br><br><span style="font-family: courier new,monospace;">rule &quot;setup superset - Rule 1&quot;</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">   when</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   then</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">        Element ss = new Element(&quot;Super set - Rule 1&quot;, 1, 2, 3);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        insert(ss);<br>



</span><span style="font-family: courier new,monospace;">end</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">rule &quot;rule 1&quot;</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">    when</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        $f : Fact()</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">
        Element(name=&quot;Super set - Rule 1&quot;, </span><span style="font-family: courier new,monospace;">$f.</span><span style="font-family: courier new,monospace;">numbers subsetOf </span><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">numbers)</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">    then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        //Do something</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">end</span><br><br>This uses Wolfgang&#39;s Element Class from his example creating custom operators and assumes Fact exposes a &quot;numbers&quot; property which returns a Collection. This remains untested but I have no reason to doubt Wolfgang.<br>



<br>With kind regards,<br><br>Mike<div><div></div><div><br><br><br>        <br><br><div class="gmail_quote">2010/10/13 Kumar Pandey <span dir="ltr">&lt;<a href="mailto:kumar.pandey@gmail.com" target="_blank">kumar.pandey@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;">
Well the problem is in forming the DRL  :)<div>My use case is each rule represents an item with its specific property. Fact is a user property and I want to filter the items for this user based on the users incoming property as facts.</div>




<div><br></div><div><br></div><div>I have been able to get it working like so but eval is not optimum for Rete. I was hoping for a better solution that would utilize the Rete optimization.</div><div><br></div><div>Here&#39;s my unit test DRL. Note, I have a isNotSubset method in my fact object and I&#39;m getting the list from rule and doing a check. </div>




<div><br><div><div>package com.test</div><div>import com.rule.OfferFact;</div><div>global java.util.List list</div><div><br></div><div>rule rule_not_sub_set</div><div>when</div><div>   $context : Fact()</div><div>   eval($context.isNotSubset(&quot;SINGER&quot;,&quot;DANCER&quot;, &quot;DOCTOR&quot;))</div>




<div>then</div><div>   list.add(drools.getRule().getName());</div><div>end</div></div><div><div></div><div><div><br><br><div class="gmail_quote">2010/10/13 Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com" target="_blank">michael.anstis@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;">Not as clear as I&#39;d hoped; can you provide an actual rule DRL?<br><br><div class="gmail_quote">



2010/10/13 Kumar Pandey <span dir="ltr">&lt;<a href="mailto:kumar.pandey@gmail.com" target="_blank">kumar.pandey@gmail.com</a>&gt;</span><div>
<div></div><div><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Michael<div>  Here are some examples</div><div>  </div><div>Rule1  has &quot;str1&quot;, &quot;Str2&quot;, &quot;Str3&quot;</div>





<div><br></div><div>Rule2 has &quot;str2&quot;, &quot;Str3&quot;, &quot;Str5&quot;, &quot;Str6&quot;, &quot;Str7&quot;</div>
<div> </div><div>Rule3 has &quot;str1&quot;, &quot;Str3&quot;, &quot;Str6&quot;</div><div><br></div><div>etc.</div><div><br></div><div>With fact1 that has  &quot;str1&quot;, &quot;Str3&quot; , since this is subset of values in Rule1 and Rule3, they should not fire but Rule2 should fire</div>






<div><br></div><div>With fact2 that has &quot;str2&quot;, &quot;Str6&quot;, &quot;Str7&quot;, Rule 2 should not fire and Rule1 and Rule3 should fire. </div><div><br></div><div>Hope this is clear.</div><div><br></div><div>






Thanks</div><div>Kumar<br><br><div class="gmail_quote">2010/10/13 Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com" target="_blank">michael.anstis@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>
Thanks, please provide a specific example rule too.<div><br></div><div>Don&#39;t forget to keep your posts to the mailing list for the good of the community.<div><div></div><div><br><br><div class="gmail_quote">
On 12 October 2010 22:18, Kumar Pandey <span dir="ltr">&lt;<a href="mailto:kumar.pandey@gmail.com" target="_blank">kumar.pandey@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Michale<div>  Thanks for the response.</div><div>Here&#39;s the link for the thread .</div>

<div><br></div><div><a href="http://drools-java-rules-engine.46999.n3.nabble.com/Check-if-fact-is-subset-of-items-in-the-rule-td1680013.html#a1680013" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Check-if-fact-is-subset-of-items-in-the-rule-td1680013.html#a1680013</a></div>








<div><br></div><div>and the original about matching strings in two arrays.</div><div><a href="http://drools-java-rules-engine.46999.n3.nabble.com/Matching-strings-in-two-arrays-td1602511.html#a1602511" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Matching-strings-in-two-arrays-td1602511.html#a1602511</a></div>








<div><br></div><div><br></div><div>My use case is that I could have hundreds of rule and each rule could have its own set of strings.</div><div>A fact object is run through these rules to see which ones are fired.</div><div>








One of the condition to check is that the a list in the fact is not a subset of list in the rule. </div><div>That is fire the rule only if list in fact is not a subset of list in rule.</div><div> </div><div>Thanks</div><div>








Kumar</div><div><br><br><div class="gmail_quote">On Tue, Oct 12, 2010 at 12:38 PM, Michael Anstis <span dir="ltr">&lt;<a href="mailto:michael.anstis@gmail.com" target="_blank">michael.anstis@gmail.com</a>&gt;</span> wrote:<br>







<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
OK, I admit I don&#39;t have the original thread anymore.<br><br>If I am not wrong (which is always a possibility) for Wolfgang&#39;s operator to work you&#39;d need to externalise the superset from the rule into WorkingMemory. You could have a rule with higher salience construct the superset WM fact.<br>









<br>If you don&#39;t mind re-posting or providing a link to the complete thread (on Nabble or somewhere) I&#39;ll happily try to help further.<br><br><div class="gmail_quote">On 12 October 2010 17:23,  <span dir="ltr">&lt;<a href="mailto:kumar.pandey@gmail.com" target="_blank">kumar.pandey@gmail.com</a>&gt;</span> wrote:<br>










<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&lt;quote author=&#39;Michael Anstis-2&#39;&gt;<div><br>
Wolfgang gave a great solution.<br></div>
&lt;/quote&gt;<br>
Don&#39;t know if I&#39;m missing something obvious here.  I have a superset in the rule itself. Each rule has a superset list. In this case how would I use Wolfgang&#39;s solution. Its comparing through two arrays in runtime. I have not been able to construct an array construct with specific values in the rule itself.<br>











</blockquote></div><br>
</blockquote></div><br><br>
</div>
</blockquote></div><br></div></div></div>
<br></div></div>_______________________________________________<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></blockquote></div><br><br clear="all"><br>
</div>
<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></blockquote></div></div></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></blockquote></div><br><br>
</div></div></div></div>
<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></blockquote></div><br>
</div></div><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></blockquote></div><br><br clear="all"><br></div></div>-- <br>Kumar Pandey<br><a href="http://www.linkedin.com/in/kumarpandey" target="_blank">http://www.linkedin.com/in/kumarpandey</a><br>
</div></div>
</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>