[rules-users] Drools Bug: Custom Operator with Maps results in Mvel Error

Uday Kodukula ukodukula at synacor.com
Thu Oct 28 22:49:08 EDT 2010


Hello,

I'm not sure if this is a bug, but I'd like to check with the Drools experts
to see if it is. 

I noticed this when creating my custom operator, which doesn't appear to
recognize values from Maps, but works fine with non Map based values.

I have created a custom comparison operator which takes in a parameter to
determine how to execute the comparison logic.

So for example, I am able to do the following:

      id udaycompare[gt] 1

where id is an integer. So for the sake of clarity this is equivalent to "id
> 1". 

Now, when I try to extract an integer from a HashMap called myMap, who has
an integer value for the key "someKey", I get an error raised by MVEL:

      myMap["someKey"] udaycompare[gt] 1

Error thrown:

Unable to determine the used declarations.
[Error: unknown class or illegal statement: org.mvel2.ParserContext at 1d87b85]
[Near : {... myMap["someKey"] udaycompare  ....}]
                                                                ^
It appears that Mvel doesn't like getting values from HashMap when working
with custom operators. I also tried an alternate way of getting that key
from the map as follows:

      myMap.someKey udaycompare[gt] 1

but i still get the same error.

Any thoughts would be greatly appreciated.

Thanks,
Uday
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Bug-Custom-Operator-with-Maps-results-in-Mvel-Error-tp1790252p1790252.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list