<div><br></div>   Hi, <div><br></div><div>   Thanks for the very comprehensive description. We did a lot of fixes related to syntax problems and map support in the last few weeks. In particular, I believe the problems reported in your first item are all solved. </div>
<div><br></div><div>   Can you please test with the latest snapshot? Don&#39;t forget to update your MVEL jar as well.</div><div><br></div><div><a href="https://hudson.jboss.org/jenkins/view/Drools%20jBPM/job/drools/lastSuccessfulBuild/artifact/drools-distribution/target/">https://hudson.jboss.org/jenkins/view/Drools%20jBPM/job/drools/lastSuccessfulBuild/artifact/drools-distribution/target/</a> </div>
<div><br></div><div>   For the second item, it may or may not be fixed. If you can check with the latest snapshot and open a JIRA in case it is not working, I will fix it and include in the 5.3.final release.</div><div><br>
</div><div>   Thanks,</div><div>     Edson<br><br><div class="gmail_quote">2011/10/7 zstlaw <span dir="ltr">&lt;<a href="mailto:zstlawre@akamai.com">zstlawre@akamai.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I have a large pool of errors I would like help with but I am breaking them<br>
up by topic since they are so different in nature.  I have made fairly<br>
simple examples to start.<br>
<br>
Environment : Using drools 5.2.0.Final on Linux using the openjdk 6 JDK.<br>
<br>
First are some bugs in Map access when using a local variable or a object<br>
variable as key.  This is a very simple case which gets more complicated in<br>
my next example in this email.  The rule file will not compile despite<br>
appearing logically valid to me.<br>
<br>
/* simple example class */<br>
package com.sample;<br>
import java.util.Date;<br>
import java.util.HashMap;<br>
import java.util.Map;<br>
public class Mailbox {<br>
        static public final String TEST_EMAIL = &quot;<a href="mailto:me@test.com">me@test.com</a>&quot;;<br>
        public Map&amp;lt;String, Date&amp;gt; recentContacts = new HashMap&amp;lt;String,<br>
Date&amp;gt;();<br>
        public Mailbox() {<br>
                owneremail = TEST_EMAIL;<br>
<br>
                // create contact for self<br>
                recentContacts.put(owneremail, new Date());<br>
        }<br>
<br>
        public Map&amp;lt;String, Date&amp;gt; getRecentContacts() {<br>
                return recentContacts;<br>
        }<br>
}<br>
<br>
/* simple rule file */<br>
// this rule is nonsensical but attempts hashmap access via many means to<br>
find out why<br>
// behavior was inconsistant.  Each commented line will cause file to not<br>
compile when uncommented.<br>
// the uncommented lines are present to show what does work.<br>
package com.sample<br>
import java.util.Date;<br>
import java.util.Map;<br>
import com.sample.Mailbox;<br>
rule &quot;check recentContacts hash mvel&quot;<br>
dialect &quot;mvel&quot;<br>
    when<br>
        $m : Mailbox(<br>
                        // Each commented line will result in the file no longer compiling<br>
if uncommented<br>
                        $me : owneremail,<br>
                        recentContacts[Mailbox.TEST_EMAIL] != null,<br>
                        recentContacts[&quot;<a href="mailto:me@test.com">me@test.com</a>&quot;] != null,<br>
//                      recentContacts[owneremail] != null, // HAS ERROR because it checks<br>
HashMap for owneremail<br>
                        recentContacts[$me] != null,<br>
                        $d1 : recentContacts[Mailbox.TEST_EMAIL],<br>
                        $d2 : recentContacts[&quot;<a href="mailto:me@test.com">me@test.com</a>&quot;],<br>
//                      $d3 : recentContacts[$me], // HAS ERROR only when doing variable<br>
assignment<br>
                        recentContacts.get(owneremail) != null,<br>
                        recentContacts.get($me) != null,<br>
//                      $d4: recentContacts.get($me), // HAS ERROR only if doing variable<br>
assignment<br>
                        $d5 : getRecentContacts(),<br>
                        $d6 : getRecentContacts().size,<br>
                        0 &lt; 1<br>
        )<br>
    then<br>
        System.out.println( &quot;recentContacts were accessible&quot; );<br>
end<br>
<br>
<br>
<br>
Any suggestions?  Not being able to access objects in a hash is problematic.<br>
And it gets worse if objects are not base java classes as I find even static<br>
enums getting handled erratically when used as keys.  Some time I need to<br>
use the full name but using a method I can use different expression and have<br>
it work.  Moving to next problem now this is my real problem.  Please note<br>
that I was not initially usign an inner static enum but moved it there to<br>
make example a single file.<br>
<br>
/* more complicated version of class */<br>
package com.sample;<br>
import java.util.ArrayList;<br>
import java.util.Date;<br>
import java.util.HashMap;<br>
import java.util.List;<br>
import java.util.Map;<br>
<br>
public class Mailbox {<br>
        // taken straight form example code<br>
        static public class Message {<br>
            public static final int HELLO = 0;<br>
            public static final int GOODBYE = 1;<br>
<br>
            private String message;<br>
            private int status;<br>
<br>
            public String getMessage() {<br>
                return this.message;<br>
            }<br>
<br>
            public void setMessage(String message) {<br>
                this.message = message;<br>
            }<br>
<br>
            public int getStatus() {<br>
                return this.status;<br>
            }<br>
<br>
            public void setStatus(int status) {<br>
                this.status = status;<br>
            }<br>
        }<br>
<br>
        static public enum FolderType {INBOX, SENT, TRASH};<br>
        static public final String TEST_EMAIL = &quot;<a href="mailto:me@test.com">me@test.com</a>&quot;;<br>
<br>
        private Map&amp;lt;FolderType, List&amp;lt;Message&amp;gt;&gt; folders = new<br>
HashMap&amp;lt;FolderType, List&amp;lt;Message&amp;gt;&gt;();<br>
        public Map&amp;lt;String, Date&amp;gt; recentContacts = new HashMap&amp;lt;String,<br>
Date&amp;gt;();<br>
        private String owneremail;<br>
<br>
        public Mailbox(String username) {<br>
                owneremail = username;<br>
<br>
                // create contact for self<br>
                recentContacts.put(owneremail, new Date());<br>
<br>
                // create default folders<br>
                folders.put(FolderType.SENT, new ArrayList&lt;Message&gt;());<br>
                folders.put(FolderType.TRASH, new ArrayList&lt;Message&gt;());<br>
                folders.put(FolderType.INBOX, new ArrayList&lt;Message&gt;());<br>
        }<br>
<br>
        /** parameterized accessor */<br>
        public List&lt;Message&gt; getFolder(FolderType t) {<br>
                return folders.get(t);<br>
        }<br>
<br>
        public Map&amp;lt;FolderType, List&amp;lt;Message&amp;gt;&gt; getFolders() {<br>
                return folders;<br>
        }<br>
<br>
        public Map&amp;lt;String, Date&amp;gt; getRecentContacts() {<br>
                return recentContacts;<br>
        }<br>
<br>
        public String getOwneremail() {<br>
                return owneremail;<br>
        }<br>
}<br>
<br>
/* more complicated rule */<br>
package com.sample<br>
import java.util.Date;<br>
import java.util.HashMap;<br>
import java.util.List;<br>
import java.util.Map;<br>
import com.sample.Mailbox;<br>
import com.sample.Mailbox.FolderType;<br>
import com.sample.Mailbox.Message;<br>
<br>
<br>
rule &quot;check folders hash mvel&quot;<br>
dialect &quot;mvel&quot;<br>
    when<br>
        $m : Mailbox(<br>
                        // Each commented line will result in the file no longer compiling<br>
                        $type1 : FolderType.INBOX,<br>
                        $type2 : com.sample.Mailbox$FolderType.INBOX,<br>
                        $work1 : getFolder(null),<br>
                        $work2 : getFolder(com.sample.Mailbox$FolderType.INBOX),<br>
                        $work3 : getFolder(com.sample.Mailbox$FolderType.INBOX).size,<br>
//                      getFolder(FolderType.INBOX), // HAS ERROR - unable to resolve<br>
using strict mode<br>
                        getFolder($type1) != null,<br>
//                      $err1 : getFolder($type1), // again HAS ERROR only when doing<br>
variable assignment<br>
                        getFolder($type2) != null,<br>
//                      $err2 : getFolder($type2), // again HAS ERROR only when doing<br>
variable assignment<br>
                        getFolder($type1).size() &gt; 0,<br>
                        getFolder($type1).isEmpty(),<br>
//                      $err3 : folders[FolderType.INBOX], // HAS ERROR<br>
//                      $err4 : folders[com.sample.Mailbox.FolderType.INBOX], // HAS<br>
ERROR - bad path syntax obviously<br>
//                      $err5 : folders[com.sample.Mailbox$FolderType.INBOX], // HAS<br>
ERROR<br>
//                      folders[$type1]!=null, // HAS ERROR<br>
//                      folders[$type2]!=null, // HAS ERROR<br>
                        $work6 : folders,<br>
                        $work7 : folders.size,<br>
                        folders.containsKey(com.sample.Mailbox$FolderType.INBOX),<br>
                        folders.containsKey($type2),<br>
                        !folders.isEmpty,<br>
//                      $err6: folders.size(),  // HAS ERROR<br>
//                      $err7: folders.isEmpty(),  // HAS ERROR<br>
//                      folders.get(FolderType.INBOX)!=null, // HAS ERROR<br>
//                      folders.get(com.sample.Mailbox.FolderType.INBOX)!=null, // HAS<br>
ERROR - bad path syntax obviously<br>
//                      folders.get(com.sample.Mailbox$FolderType.INBOX)!=null, // HAS<br>
ERROR<br>
//                      folders.get($type1)!=null, // HAS ERROR<br>
//                      folders.get($type2)!=null, // HAS ERROR<br>
                        $work8 : getFolders(),<br>
                        $work9 : getFolders().size,<br>
//                      getFolders().size(), // HAS ERROR<br>
                        0 &lt; 1<br>
        )<br>
    then<br>
        System.out.println( &quot;folders were accessible&quot; );<br>
end<br>
<br>
Now you can see my real problem.  Dealing with a hash of enum to other<br>
object I get a lot of odd behavior on hash keying depending on how I make<br>
each call and while I really need to store the result to do many comparisons<br>
I can not unless I hardcode the parameter by which I am accessing the data<br>
which would profoundly weaken the rules I am writing.<br>
<br>
While I could register every object in the hash the problem then becomes the<br>
profusion of meta objects and the management of them especially given the<br>
memory leaks not fixed until 5.3.Final is released.<br>
<br>
Thank you for any assistance!<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Map-errors-and-quirks-tp3404106p3404106.html" target="_blank">http://drools.46999.n3.nabble.com/Map-errors-and-quirks-tp3404106p3404106.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>