[rules-users] Drool 5 memberOf problem

Wolfgang Laun wolfgang.laun at gmail.com
Wed May 18 03:08:51 EDT 2011


You must insert a magic spell string to make this work ;-)

Look at this line:

   String(FactorKeys.PHONE_PACKAGE memberOf ownedProductFactorSet)

It says: "If there is an object of type java.lang.String and..." And so you
must insert a String!

But, of course, you don't need *this *condition. You just want to make sure
that FactorKeys.PHONE_PACKAGE is contained in the global
ownedProductFactorSe.
You should write this as
   eval( ownedProductFactorSet.contains( FactorKeys.PHONE_PACKAGE ) )
Also, this line should be the first line, because it is a constant
condition.

(If you do insert an arbitrary String object, the rule will work, but only
up to version 5.1.1.
5.2.x has a different parser that refuses incorrect constraints.)

-W


On 17 May 2011 19:56, dxande6 <dxande6 at qwest.com> wrote:

> I'm trying to validate that there is a Factor in a collection using the
> global variable ownedProductFactorSet.  I'm having trouble.  I do not get
> an
> error, it just doesn't resolve to true.  I've validated the
> ownedProductFactor set has the Factor
>
> Java class that is contained withing the ownedProductFactorSet:
>
> Factor
>    String key
>    String value
>
> Here is the code in the drl:
>
> global Set ownedProductFactorSet;
>
> rule "Owned Products"
>  ruleflow-group "discount-pricing"
>  lock-on-active true
>  when
>      not Factor(key == FactorKeys.DISCOUNT)
>      String(FactorKeys.PHONE_PACKAGE memberOf ownedProductFactorSet)
>      Factor(key == RulesKeys.WIRELESS)
>
>  then
>      logger(kcontext).info("SUCCESS - *******************************");
>      insert(new Factor(FactorKeys.DISCOUNT)); end
>
> It never gets to the consequence (RHS - "then" part) of this rule.
> If I comment out the following line:
>      String(FactorKeys.PHONE_PACKAGE memberOf ownedProductFactorSet) It
> will work.
>
> Any help with the memberOf keyword is greatly appreciated.
>
> Thanks,
>
> -dxande6
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drool-5-memberOf-problem-tp2953475p2953475.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110518/5df57fe5/attachment.html 


More information about the rules-users mailing list