[rules-users] Re: Pattern matching

Jai Vasanth jaivasanth at gmail.com
Fri Feb 8 11:52:36 EST 2008


Very interesting. I tried it too , I dont think its about the '==' because
it seems to be working for eval( reason == 'override'). So it is more to do
with having the eval method call.
Nice find. Not too sure if this is a bug, or if there is a reason why drools
works this way.


Thanks

Jai

On Feb 7, 2008 5:43 PM, ST <super_thunder2 at hotmail.com> wrote:

> I got it working by using the inline eval expression.  The following is
> the
> modified version of the rules.
>
> rule "Remove smaller or non-overriden"
>    dialect "java"
>    when
>        L : Response( $r : value && status != "override" )
>        Response(  value > $r || eval (status.equals("override")) )
>    then
>        System.out.println("Retracting " + L);
>        retract( L );
> end
>
> The Response class has two fields one is value and the other is status.
>  For
> convenience, I added a constructor where the first parameter is the value
> and
> the second is the status.  I have added the following objects into the
> working
> memory for testing.
>
>        final Response response1 = new Response(5,"override");
>        final Response response2 = new Response(6,"not override");
>        final Response response3 = new Response(7,"not override");
>        final Response response4 = new Response(8,"not override");
>        session.insert( response1 );
>        session.insert( response2 );
>        session.insert( response3 );
>        session.insert( response4 );
>
>        session.fireAllRules();
>
> The result shows that the object, Response(5,"override"), is the only one
> left
> after the all activated rules have been evaluated.
>
> I am not sure why "==" does not work in this example.  Is this a known
> bug?
>
>
>
> _______________________________________________
> 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/20080208/97ffefe8/attachment.html 


More information about the rules-users mailing list