Hi,
I found a possible cause from StatefulKnowledgeSession API:
/Also, it is a good practice to set your globals before inserting your facts
or starting your processes. Rules engines evaluate rules at fact insertion
time, and so, if you are using a global to constraint a fact pattern, and
the global is not set, you may receive a NullPointerException./
I did so and I no longer get the compilation error. However, 'eval'
construction is not working in LHS. I'm shifting to insert items from maps
into WM directly.
Cheers
esstrata wrote:
Hello,
I'm using Drools 5.1.1 in a JavaSE 6 project.
I can't get running a rule where a value obtained from WM is check for
existence as a key of a global Map.
I have a map of the type ProductTextCode -> Product, where keys are String
and values Product
/global Map productMap/
Then in a rule a I want a condition where each String in WM is tested
against map keyset.
/
rule "Product ID not in products map"
dialect "mvel"
when
$pid : String()
=> Here goes the condition <=
then
System.out.println("Invalid product id: " + $pid)
retract ($pid)
end
/
So far I've tried with productMap.containsKey($pid) but a get a MVEL error
as it takes 'containsKey' as a property.
Please help. Thank you.
esstrata wrote:
Hello,
I'm using Drools 5.1.1 in a JavaSE 6 project.
I can't get running a rule where a value obtained from WM is check for
existence as a key of a global Map.
I have a map of the type ProductTextCode -> Product, where keys are String
and values Product
/global Map productMap/
Then in a rule a I want a condition where each String in WM is tested
against map keyset.
/
rule "Product ID not in products map"
dialect "mvel"
when
$pid : String()
=> Here goes the condition <=
then
System.out.println("Invalid product id: " + $pid)
retract ($pid)
end
/
So far I've tried with productMap.containsKey($pid) but a get a MVEL error
as it takes 'containsKey' as a property.
Please help. Thank you.
--
View this message in context:
http://drools.46999.n3.nabble.com/check-whether-a-key-is-present-in-globa...
Sent from the Drools: User forum mailing list archive at
Nabble.com.