[rules-users] check whether a key is present in global Map, i.e. mimicking containsKey() behavior

esstrata esstrata at yahoo.es
Mon Jul 4 09:53:41 EDT 2011


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-global-Map-i-e-mimicking-containsKey-behavior-tp3137610p3137610.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list