<br> Shaz,<br><br> We strongly advise you to move to 4.0.3, but this is not related to your problem. <br> I think you are misunderstanding something. Why are you using the global map to store your fact? Simply insert it into the working memory and it will work fine.
<br><br> []s<br> Edson<br><br><br><div><span class="gmail_quote">2007/11/1, Shaz Tumulak <<a href="mailto:shauii@yahoo.com">shauii@yahoo.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi,<br><br>I can't seem to make this syntax work in Drools 4.0.2. Pls. see my sample<br>code below.<br>________________________________________<br>class MyClass {<br> String id;<br> String name;<br><br>
MyClass(String id, String name){<br> <a href="http://this.id">this.id</a> = id;<br> <a href="http://this.name">this.name</a> = name;<br> }<br> :<br> getter, setter methods
<br> :<br>}<br><br>MyClass obj = new MyClass("1"", "name");<br><br>TreeMap<String, MyClass> mapOfObj = new TreeMap<String, MyClass>();<br>mapOfObj.put("keyOfObj", obj);
<br>________________________________________<br><br>DRL file<br>-------<br><br>global java.util.TreeMap mapOfObj;<br><br>rule chkobj<br>when<br> obj : MyClass(mapOfObj["keyOfObj"].id == "1");<br>
eval(obj.getName() == "name");<br>________________________________________<br><br>I'm getting this error: org.drools.RuntimeDroolsException:<br>java.lang.NullPointerException<br> at
<br>org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:76)<br><br>Is my syntax correct and has someone used this in 4.0.2 or should I move on<br>to Drools 4.0.3? Thanks in advance.<br><br>Regards,<br><br>shaz<br><br>
<br>Edson Tirelli-3 wrote:<br>><br>> Denis,<br>><br>> If you are using latest build from trunk (I'm not sure it already works<br>> in MR3), you can use a simplified MVEL syntax:<br>><br>> when
<br>> Person( address["business"].phone == "99999999" )<br>> then<br>> ...<br>> end<br>><br>> Although, the above will be converted into an inline-eval. Not as bad<br>> as
<br>> a top level eval, but still more costly then using regular fields.<br>><br>> []s<br>> Edson<br>><br>> 2007/7/19, Ryan, Dennis (Dennis) <<a href="mailto:dennisryan@avaya.com">dennisryan@avaya.com
</a>>:<br>>><br>>> We are using Maps (HashMaps) in our rules and the only way we have found<br>>> to access keys and values in the Map in the "when" clauses is thru use on<br>>> eval() which I know is a big no-no by rules purists. Is there a better
<br>>> way,<br>>> maybe some shorthand I'm not familiar with to deal with Maps in the when<br>>> clause?<br>>><br>>><br>>><br>>> Thanks,<br>>><br>>> Dennis<br>>>
<br>>> _______________________________________________<br>>> rules-users mailing list<br>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>><br>>><br>><br>><br>> --<br>> Edson Tirelli<br>> Software Engineer - JBoss Rules Core Developer<br>> Office: +55 11 3529-6000
<br>> Mobile: +55 11 9287-5646<br>> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>><br>> _______________________________________________<br>> rules-users mailing list
<br>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>
<br>><br><a href="mailto:shauii@yahoo.com">shauii@yahoo.com</a><br>--<br>View this message in context: <a href="http://www.nabble.com/Accessing-maps-%28hashmaps%29-keys-and-values-in-rules-tf4112197.html#a13524477">http://www.nabble.com/Accessing-maps-%28hashmaps%29-keys-and-values-in-rules-tf4112197.html#a13524477
</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">
rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli
<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>