For the sake of clarification: Are you saying that there is, or should be, some magic which would make a constraint like<br>   Map ( this[&quot;departureDate&quot;] == &quot;07-Jan-2009&quot; )<br>behave as a comparison between two java.util.Date values if the LHS Object is of this type? And also if it is a GregorianCalendar object?<br>
<br>Since even you are &quot;not sure&quot; regarding MVEL: What is the definite reference for MVEL in Drools? I have a vague recollection of reading somewhere that not all of MVEL is available...<br><br>-W<br><br><br><div class="gmail_quote">
2009/11/8 Edson Tirelli <span dir="ltr">&lt;<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>     Ok, without discussing the merits of using (or not) maps, the reason you are having problems with dates is that the &quot;string-based&quot; date is syntax sugar in Drools parser/compiler. Although, when you create expressions using nested accessors or [] for collection/map element access, drools wraps the whole thing into an &quot;eval&quot; and delegates to MVEL. We do some transformations to bridge the gap between drools operators and mvel operators, but I don&#39;t think drools has anything to &quot;transform&quot; the string-based date into something mvel understands.<br>

<br>     Having said that, we should probably add this functionality to the &quot;MVELDumper&quot; class for better integration. Would you please open a jira for that? Also, patches are welcome in case someone would like to help. This is an isolated part of the code and easy to understand.<br>

<br>    Meanwhile, best you can do is avoid the use of this Map syntax + string-based dates, or write your expressions directly in a way the mvel understands (not sure mvel has a special syntax for dates).<br> <br>    Same explanation for the NPE.<br>

<br>    Edson<br><br><div class="gmail_quote">2009/11/8 Leonardo Gomes <span dir="ltr">&lt;<a href="mailto:leonardo.f.gomes@gmail.com" target="_blank">leonardo.f.gomes@gmail.com</a>&gt;</span><div><div></div><div class="h5">
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Wolfgang,<br>
<br>
Here&#39;s the context:<br>
<br>
We&#39;re replacing a very basic home-made rule engine with drools. Today,<br>
fact data can be added dynamically b/c for all rules our fact is<br>
nothing more than a Map and we can register new fact data through an<br>
UI where you say what&#39;s the key and what&#39;s the type of the value.<br>
Rules can also be created dynamically and operate against those newly<br>
created attributes of my fact.<br>
<br>
Incoming requests are key / value structures and we have a service<br>
that will look at the list of registered fact data and try to find<br>
that information in the incoming request by looking for the keys and<br>
getting the corresponding values, then populating the Map I just<br>
talked about which will be injected in the working memory for<br>
evaluation against our rules.<br>
<br>
That&#39;s why, in Drools, I need to have my rules accessing data from a<br>
Map. By using MVEL, as I said, it works fine with strings, integers<br>
and list of strings, but I&#39;m having problems with dates and would like<br>
some advice on that case.<br>
<br>
Here&#39;s another example of things that work:<br>
<br>
rule &quot;test rule&quot;<br>
        when<br>
<div>                Map ( this[&quot;airportCode&quot;] == &quot;GIG&quot;<br>
                        , this[&quot;numberOfPassengers&quot;] &gt; 1<br>
</div>                        , this[&quot;class&quot;] in (&quot;BUSINESS&quot;, &quot;FIRST CLASS&quot;) )<br>
        then<br>
                m.addMessage(&quot;rule matched&quot;);<br>
end<br>
<br>
And here&#39;s where I have problems,<br>
<br>
Map ( this[&quot;departureDate&quot;] ) == &quot;07-Jan-2009&quot; )<br>
<br>
<br>
Thanks a lot,<br>
Leo.<br>
<div><div></div><div><br>
<br>
<br>
On Sun, Nov 8, 2009 at 10:56 AM, Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt; wrote:<br>
&gt; On Sat, Nov 7, 2009 at 6:00 PM, Leonardo Gomes &lt;<a href="mailto:leonardo.f.gomes@gmail.com" target="_blank">leonardo.f.gomes@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m feeding my working memory with Maps (unfortunately, this is a<br>
&gt;&gt; requirement and I can&#39;t use beans).<br>
&gt;&gt;<br>
&gt;<br>
&gt; Before people start racking their brains to overcome all the resulting<br>
&gt; difficulties: Could you please explain what this requirement is meant to<br>
&gt; achieve?<br>
&gt; -W<br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; To access the values in this maps I use the following MVEL expression :<br>
&gt;&gt;<br>
&gt;&gt;                Map ( this[&quot;airportCode&quot;] == &quot;GIG&quot;<br>
&gt;&gt;                        , this[&quot;numberOfPassengers&quot;] &gt; &quot;1&quot;<br>
&gt;&gt;                        , this[&quot;class&quot;] memberOf (&quot;BUSINESS&quot;, &quot;FIRST&quot;) )<br>
&gt;&gt;<br>
&gt;&gt; And it works fine, except for dates where I get a ClassCastException,<br>
&gt;&gt; even tough I&#39;m using the right pattern:<br>
&gt;&gt;<br>
&gt;&gt; Map ( this[&quot;departureDate&quot;] &gt; &quot;07-Nov-2009&quot; )   --- fails<br>
&gt;&gt;<br>
&gt;&gt; Is there anything I need to do to make the dynamic cast of dates work,<br>
&gt;&gt; in this particular case?<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt;<br>
&gt;&gt; Morever, I get NPEs if there&#39;s no value for a given key. For example,<br>
&gt;&gt; the expression Map ( this [&quot;name&quot;] == &#39;Leonardo&#39; ) would fail if<br>
&gt;&gt; there&#39;s no entry with &quot;name&quot; as the key.<br>
&gt;&gt;<br>
&gt;&gt; Any help is welcome!<br>
&gt;&gt;<br>
&gt;&gt; Thanks in advance,<br>
&gt;&gt; Leo.<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</div></div></blockquote></div></div></div><font color="#888888"><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>

</font><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>
<br></blockquote></div><br>