[rules-users] Re: Pattern matching

ST super_thunder2 at hotmail.com
Thu Feb 7 20:43:51 EST 2008


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?






More information about the rules-users mailing list