<!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>&nbsp;</DIV>
<DIV><FONT color=#0000ff><FONT size=2><FONT face="Courier New">rule 
chkobj<BR>when<BR><SPAN class=886131616-01112007>&nbsp;&nbsp;&nbsp; $o : 
</SPAN>MyClass(<SPAN class=886131616-01112007> </SPAN>id == "1"<SPAN 
class=886131616-01112007>,&nbsp;</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>&nbsp;&nbsp;&nbsp; //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>&nbsp;&nbsp;&nbsp; 
$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>&nbsp;&nbsp; Shaz,<BR><BR>&nbsp;&nbsp; We strongly advise you 
  to move to 4.0.3, but this is not related to your problem. <BR>&nbsp;&nbsp; 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>&nbsp;&nbsp; []s<BR>&nbsp;&nbsp; Edson<BR><BR><BR>
  <DIV><SPAN class=gmail_quote>2007/11/1, Shaz Tumulak &lt;<A 
  href="mailto:shauii@yahoo.com">shauii@yahoo.com</A>&gt;:</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String 
    id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String 
    name;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyClass(String 
    id, String 
    name){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
    href="http://this.id">this.id</A> = 
    id;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A 
    href="http://this.name">this.name</A> = 
    name;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getter, 
    setter methods 
    <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<BR>}<BR><BR>MyClass 
    obj = new MyClass("1"", "name");<BR><BR>TreeMap&lt;String, MyClass&gt; 
    mapOfObj = new TreeMap&lt;String, MyClass&gt;();<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;obj : 
    MyClass(mapOfObj["keyOfObj"].id == 
    "1");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval(obj.getName() 
    == "name");<BR>________________________________________<BR><BR>I'm getting 
    this error: 
    org.drools.RuntimeDroolsException:<BR>java.lang.NullPointerException<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Denis,<BR>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;If 
    you are using latest build from trunk (I'm not sure it already works<BR>&gt; 
    in MR3), you can use a simplified MVEL syntax:<BR>&gt;<BR>&gt; when 
    <BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Person( address["business"].phone == 
    "99999999" )<BR>&gt; then<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; ...<BR>&gt; 
    end<BR>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Although, the above will be 
    converted into an inline-eval. Not as bad<BR>&gt; as <BR>&gt; a top level 
    eval, but still more costly then using regular 
    fields.<BR>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;[]s<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Edson<BR>&gt;<BR>&gt; 
    2007/7/19, Ryan, Dennis (Dennis) &lt;<A 
    href="mailto:dennisryan@avaya.com">dennisryan@avaya.com 
    </A>&gt;:<BR>&gt;&gt;<BR>&gt;&gt;&nbsp;&nbsp;We are using Maps (HashMaps) in 
    our rules and the only way we have found<BR>&gt;&gt; to access keys and 
    values in the Map in the "when" clauses is thru use on<BR>&gt;&gt; eval() 
    which I know is a big no-no by rules purists. Is there a better <BR>&gt;&gt; 
    way,<BR>&gt;&gt; maybe some shorthand I'm not familiar with to deal with 
    Maps in the when<BR>&gt;&gt; 
    clause?<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt; 
    Thanks,<BR>&gt;&gt;<BR>&gt;&gt; Dennis<BR>&gt;&gt; <BR>&gt;&gt; 
    _______________________________________________<BR>&gt;&gt; rules-users 
    mailing list<BR>&gt;&gt; <A 
    href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR>&gt;&gt; 
    <A 
    href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A><BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;<BR>&gt;<BR>&gt; 
    --<BR>&gt;&nbsp;&nbsp; Edson Tirelli<BR>&gt;&nbsp;&nbsp; Software Engineer - 
    JBoss Rules Core Developer<BR>&gt;&nbsp;&nbsp; Office: +55 11 3529-6000 
    <BR>&gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<BR>&gt;&nbsp;&nbsp; JBoss, a 
    division of Red Hat @ <A 
    href="http://www.jboss.com">www.jboss.com</A><BR>&gt;<BR>&gt; 
    _______________________________________________<BR>&gt; rules-users mailing 
    list <BR>&gt; <A 
    href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR>&gt; 
    <A 
    href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A><BR>&gt; 
    <BR>&gt;<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>&nbsp;&nbsp;Edson Tirelli <BR>&nbsp;&nbsp;Software 
  Engineer - JBoss Rules Core Developer<BR>&nbsp;&nbsp;Office: +55 11 
  3529-6000<BR>&nbsp;&nbsp;Mobile: +55 11 9287-5646<BR>&nbsp;&nbsp;JBoss, a 
  division of Red Hat @ <A href="http://www.jboss.com">www.jboss.com</A> 
</BLOCKQUOTE></BODY></HTML>