[rules-users] Question about Drools accessing a global HashMap and comparing it to an object value
Greg Barton
greg_barton at yahoo.com
Thu Jan 27 16:38:05 EST 2011
Not a bug in drools, but a bug in my brain. :) The first term in a condition element must come from the object, and objCode was bound in the previous object. I didn't test that rule before posting, so my bad.
GreG
On Jan 27, 2011, at 15:15, mviens <mike at viens.com> wrote:
>
> Hi Greg,
>
> Thank you for the reply. I converted the rules back to being processed in
> singular mode versus through an ArrayList as you recommended. I am curious
> about the reason though -- is it a performance issue or does it just make it
> more difficult to work with within the rule?
>
> I tried your recommendation of the rule, but it caused an error:
>
> rule "Check for valid code"
> when
> obj : MyObj(objState : state, objCode : code)
> codes : State2Code(state == objState && objCode not memberOf codes)
> then
> obj.addError("Code is not valid for the State");
> end
>
> BuildError: Unable to create Field Extractor for 'objCode' of
> '[ClassObjectType class=com.abc.xyz.StateFips]' in rule 'Check for valid
> Code'
>
>
> When I changed the rule to this, the error is gone and it worked just fine.
>
> rule "Check for valid code"
> when
> obj : MyObj(objState : state, objCode : code)
> codes : State2Code(state == objState && codes not contains objCode)
> then
> obj.addError("Code is not valid for the State");
> end
>
> Do you have any thoughts on why the first rule does not work but the second
> one does? Is it a bug? The only difference between the rule I have and the
> one you suggested was using a comma versus ==. I tried with the comma, but
> the error remained. I am using Drools 5.1.1.
>
> Mike V.
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-Drools-accessing-a-global-HashMap-and-comparing-it-to-an-object-value-tp2334346p2364040.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list