<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Why not just make your class implement Comparable, and then it will
work with &gt; and &lt;.<br>
<br>
Mark<br>
Edson Tirelli wrote:
<blockquote
 cite="mid:e6dd5ba30705210852k14792a1dx782ed4c3a20cccbf@mail.gmail.com"
 type="cite"><br>
&nbsp;&nbsp; Yes, Shahad's suggestion shall work, but answering your first
question, a predicate would be like:<br>
  <br>
  <div>rule XXX<br>
when<br>
&nbsp; &nbsp;obj1 : A( $date1: mydate)<br>
&nbsp; &nbsp;obj2 : A(&nbsp;$date2: mydate -&gt; ( $date1.isBefore($date2) ) )
  </div>
then<br>
&nbsp; &nbsp;// something<br>
&nbsp; &nbsp;obj1.doSomething();<br>
End<br>
  <br>
&nbsp;&nbsp; Remember that predicates and evals use plain java code inside it. <br>
  <br>
&nbsp;&nbsp; []s<br>
&nbsp;&nbsp; Edson<br>
  <br>
  <br>
  <div><span class="gmail_quote">2007/5/21, Shahad Ahmed &lt;
  <a moz-do-not-send="true" href="mailto:shahad.ahmed2@gmail.com">shahad.ahmed2@gmail.com</a>&gt;:</span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div>How about a slight modification on Mike's solution:
    </div>
    <div>&nbsp;</div>
    <div>rule XXX<br>
when<br>
&nbsp; &nbsp;obj1 : A( $date1: mydate)<br>
&nbsp; &nbsp;obj2 : A(&nbsp;$date2: mydate)</div>
    <div>&nbsp;&nbsp; eval($date1.isBefore($date2)) <br>
then<br>
&nbsp; &nbsp;// something<br>
&nbsp; &nbsp;obj1.doSomething();<br>
End<br>
    <br>
I think eval allows you access to the methods in your custom Date class
so you can call isBefore in there after binding $date1 and $date 2 to
any custom date objects. I still new to Drools, so this may not be
correct.&nbsp;
    </div>
    <div>&nbsp;</div>
    <div>Regards</div>
    <span class="sg">
    <div>Shahad</div>
    </span>
    <div><span class="e" id="q_112af3ba0ee5b1c0_2">
    <div><br>
&nbsp;</div>
    <div><span class="gmail_quote">On 5/21/07, <b
 class="gmail_sendername">Maxime Catelin</b> &lt;<a
 moz-do-not-send="true" href="mailto:mcatelin@perinfo.com"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mcatelin@perinfo.com
    </a>&gt; wrote:</span>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">Thanks
for your input. That seems to involve some modifications,&nbsp;&nbsp;on our<br>
Date class and all the classes that have Date members.&nbsp;&nbsp;That's not <br>
exactly what i thought of doing but maybe that's the only way.<br>
      <br>
What I meant was to to find a way to compare those dates eventually<br>
using the date methods we have (isAfter() or isBefore() for exemple)
and <br>
to "keep" only the object with the latest date.&nbsp;&nbsp;So if there are several<br>
A objects in the working memory, we will only fire the one with the<br>
latest date.<br>
      <br>
rule XXX<br>
      <br>
when<br>
&nbsp;&nbsp; obj : A( $date : mydate) <br>
&nbsp;&nbsp; not A( $date.isBefore(mydate)) // does not work but that what i was
thinking<br>
then<br>
&nbsp;&nbsp; // something<br>
&nbsp;&nbsp; obj.doSomething();<br>
end<br>
      <br>
      <br>
      <br>
Anstis, Michael (M.) a &eacute;crit :<br>
&gt; The simplest way could be to have your Date expose a "Time" type
member <br>
&gt; (like java.util.Date.getTime()) that represents the number of<br>
&gt; seconds\milliseconds etc since a given point in time ("your
absolute<br>
&gt; zero" for example; being day * month * year * H * M * s * ms).
This <br>
&gt; could then be used as a simple predicate condition:-<br>
&gt;<br>
&gt; rule XXX<br>
&gt; when<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; obj1 : A( $time : myTime)<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; obj2 : A( myTime &lt; $time )<br>
&gt; then<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; // something<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; obj.doSomething();<br>
&gt; End<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Mike<br>
&gt;<br>
&gt; -----Original Message-----<br>
&gt; From: <a moz-do-not-send="true"
 href="mailto:rules-users-bounces@lists.jboss.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
rules-users-bounces@lists.jboss.org </a><br>
&gt; [mailto:<a moz-do-not-send="true"
 href="mailto:rules-users-bounces@lists.jboss.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">rules-users-bounces@lists.jboss.org</a>
] On Behalf Of Maxime Catelin
      <br>
&gt; Sent: 21 May 2007 14:34<br>
&gt; To: Rules Users List<br>
&gt; Subject: [rules-users] using homemade Date in Drools <br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; We are using a lot of Dates in our application but we use a
homemade
      <br>
&gt; Date class for that.&nbsp;&nbsp;Therefore, we cannot use &gt; and &lt;
provided by<br>
&gt; Drools.&nbsp;&nbsp;I looked through the mailing list but could not find any <br>
&gt; examples using Dates in Drools other than in the
documentation.&nbsp;&nbsp;What
      <br>
&gt; interested me in particular in the documentation was "If more
control is<br>
&gt;<br>
&gt; required, use the predicate constraint." <br>
&gt;<br>
&gt; Could someone give some examples of using predicate constraint
with
      <br>
&gt; dates?<br>
&gt;<br>
&gt; Something I would like to do, for example, is the following :<br>
&gt;<br>
&gt; If there is an obj1 of class A with field of type Date d1 and
another <br>
&gt; obj2 of class A with field Date d2, where d1 is before d2, obj2
should
      <br>
&gt; be used to fire something.<br>
&gt;<br>
&gt; rule XXX<br>
&gt; when<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; obj : A( $date : mydate)<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; // do not know how to use constraint on date here. <br>
&gt; then<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; // something<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; obj.doSomething();<br>
&gt; end<br>
&gt;<br>
&gt; Thanks for your input.<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
rules-users@lists.jboss.org</a><br>
&gt; <a moz-do-not-send="true"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users
      </a><br>
&gt;<br>
&gt; _______________________________________________ <br>
&gt; rules-users mailing list<br>
&gt; <a moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
rules-users@lists.jboss.org</a><br>
&gt; <a moz-do-not-send="true"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users
      </a><br>
&gt;<br>
&gt;<br>
&gt;<br>
_______________________________________________<br>
rules-users mailing list<br>
      <a moz-do-not-send="true"
 href="mailto:rules-users@lists.jboss.org" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org</a><br>
      <a moz-do-not-send="true"
 href="https://lists.jboss.org/mailman/listinfo/rules-users"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users
      </a><br>
    </blockquote>
    </div>
    <br>
    </span></div>
    <br>
_______________________________________________<br>
rules-users mailing list<br>
    <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org
    </a><br>
    <a moz-do-not-send="true"
 onclick="return top.js.OpenExtLink(window,event,this)"
 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>
  <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 moz-do-not-send="true"
 href="http://www.jboss.com">
www.jboss.com</a>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>