[rules-users] 4.x to 5.1.0 Rule migration issue

Michael Anstis michael.anstis at gmail.com
Tue Sep 28 05:23:09 EDT 2010


As an aside, if you can change the rule definitions it'd be preferable to
remove the eval:-

rule "EmailVerificationCheck"
salience 500
when
    $c : RuleContext (paymentMethod == "P_EXPRESS", trustedUser==false)
    $a : RuleAction (action == null || == "VERIFY")
then
   ...
end

isTrustedUser() is a member of RuleContext and you can therefore access it's
boolean properties like any other.

Also, you could split the RHS into different rules too:-

rule "EmailVerificationCheck #1"
salience 500
when
    $c : RuleContext (paymentMethod == "P_EXPRESS", trustedUser==false,
PEmailVerified==false)
    $a : RuleAction (action == null)
then
    modify($a) {
        setAction ("VERIFY");
    }
end

rule "EmailVerificationCheck #2"
salience 500
when
    $c : RuleContext (paymentMethod == "P_EXPRESS", trustedUser==false,
PEmailVerified==false)
    $a : RuleAction (action == "VERIFY")
then
    $a.getRuleNames().add("PEmailVerificationCheck");
    update($a);
end

2010/9/28 Vincent Legendre <vincent.legendre at eurodecision.com>

>  Hi,
>
> The follwing error seems to mean that context is defined twice. May be that
> "context" is a reserved global variable in drools 5.
> Try to remane it in your rule, and check doc for more explanations
>
> com/playspan/rule/Rule_PayPal_EmailVerificationCheck_0Eval0Invoker.java
> (16:48) : *Redefinition of local variable "context"*
>
>
>
> _______________________________________________
> 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/20100928/f737f523/attachment.html 


More information about the rules-users mailing list