OK, unless I'm missing something else you should be able to do something like this:-

rule "setup superset - Rule 1"
   when
   then
        Element ss = new Element("Super set - Rule 1", 1, 2, 3);
        insert(ss);
end

rule "rule 1"
    when
        $f : Fact()
        Element(name="Super set - Rule 1", $f.numbers subsetOf numbers)
    then
        //Do something
end

This uses Wolfgang's Element Class from his example creating custom operators and assumes Fact exposes a "numbers" property which returns a Collection. This remains untested but I have no reason to doubt Wolfgang.

With kind regards,

Mike


       

2010/10/13 Kumar Pandey <kumar.pandey@gmail.com>
Well the problem is in forming the DRL  :)
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.


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.

Here's my unit test DRL. Note, I have a isNotSubset method in my fact object and I'm getting the list from rule and doing a check. 

package com.test
import com.rule.OfferFact;
global java.util.List list

rule rule_not_sub_set
when
   $context : Fact()
   eval($context.isNotSubset("SINGER","DANCER", "DOCTOR"))
then
   list.add(drools.getRule().getName());
end


2010/10/13 Michael Anstis <michael.anstis@gmail.com>
Not as clear as I'd hoped; can you provide an actual rule DRL?

2010/10/13 Kumar Pandey <kumar.pandey@gmail.com>

Michael
  Here are some examples
  
Rule1  has "str1", "Str2", "Str3"

Rule2 has "str2", "Str3", "Str5", "Str6", "Str7"
 
Rule3 has "str1", "Str3", "Str6"

etc.

With fact1 that has  "str1", "Str3" , since this is subset of values in Rule1 and Rule3, they should not fire but Rule2 should fire

With fact2 that has "str2", "Str6", "Str7", Rule 2 should not fire and Rule1 and Rule3 should fire. 

Hope this is clear.

Thanks
Kumar

2010/10/13 Michael Anstis <michael.anstis@gmail.com>
Thanks, please provide a specific example rule too.

Don't forget to keep your posts to the mailing list for the good of the community.


On 12 October 2010 22:18, Kumar Pandey <kumar.pandey@gmail.com> wrote:
Michale
  Thanks for the response.
Here's the link for the thread .


and the original about matching strings in two arrays.


My use case is that I could have hundreds of rule and each rule could have its own set of strings.
A fact object is run through these rules to see which ones are fired.
One of the condition to check is that the a list in the fact is not a subset of list in the rule. 
That is fire the rule only if list in fact is not a subset of list in rule.
 
Thanks
Kumar


On Tue, Oct 12, 2010 at 12:38 PM, Michael Anstis <michael.anstis@gmail.com> wrote:
OK, I admit I don't have the original thread anymore.

If I am not wrong (which is always a possibility) for Wolfgang's operator to work you'd need to externalise the superset from the rule into WorkingMemory. You could have a rule with higher salience construct the superset WM fact.

If you don't mind re-posting or providing a link to the complete thread (on Nabble or somewhere) I'll happily try to help further.

On 12 October 2010 17:23, <kumar.pandey@gmail.com> wrote:
<quote author='Michael Anstis-2'>

Wolfgang gave a great solution.
</quote>
Don't know if I'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'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.





_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users