<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=886131616-01112007><FONT face=Arial
color=#0000ff size=2>By way of example (if you misunderstand how the rule engine
should be used):-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=886131616-01112007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV><FONT color=#0000ff><FONT size=2><FONT face="Courier New">rule
chkobj<BR>when<BR><SPAN class=886131616-01112007> $o :
</SPAN>MyClass(<SPAN class=886131616-01112007> </SPAN>id == "1"<SPAN
class=886131616-01112007>, </SPAN><SPAN
class=886131616-01112007>n</SPAN>ame == "name"<SPAN class=886131616-01112007>
)</SPAN></FONT></FONT></FONT></DIV>
<DIV><SPAN class=886131616-01112007></SPAN><SPAN
class=886131616-01112007></SPAN><FONT color=#0000ff size=2><FONT
face="Courier New">t<SPAN
class=886131616-01112007>hen</SPAN></FONT></FONT></DIV>
<DIV><FONT><SPAN class=886131616-01112007></SPAN><FONT color=#0000ff><FONT
face="Courier New" size=2><SPAN class=886131616-01112007> //Do
something else</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT><FONT><SPAN class=886131616-01112007></SPAN><FONT color=#0000ff><FONT
face="Courier New" size=2><SPAN class=886131616-01112007>
$o.doSomething();</SPAN></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT><FONT><FONT><FONT><FONT><FONT><SPAN
class=886131616-01112007></SPAN><SPAN class=886131616-01112007></SPAN><FONT
face="Courier New" color=#0000ff size=2>e<SPAN
class=886131616-01112007>nd</SPAN></FONT></FONT></FONT></FONT></FONT></FONT></FONT></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Edson
Tirelli<BR><B>Sent:</B> 01 November 2007 15:48<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> Re: [rules-users] Accessing maps (hashmaps) keys and
values in rules<BR></FONT><BR></DIV>
<DIV></DIV><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="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><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>
</BLOCKQUOTE></BODY></HTML>