<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT face=Arial 
color=#0000ff size=2>Beat me to it - work always gets in the way 
;-)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT face=Arial 
color=#0000ff size=2>I was thinking of using return value operator within a 
predicate though:-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2>rule 
XXX<BR>when<BR>&nbsp; &nbsp;obj1 : A( $date1: mydate)<BR>&nbsp; &nbsp;obj2 : 
A(&nbsp;$date2: mydate<SPAN class=194552615-21052007>&nbsp;-&gt; 
($date1.isBefore($date2))&nbsp;</SPAN>)</FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2>then<BR>&nbsp; &nbsp;// 
something<BR>&nbsp; &nbsp;obj1.doSomething();<BR>End</FONT></DIV><FONT 
face=Arial color=#0000ff size=2></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT>
<DIV><SPAN class=194552615-21052007></SPAN><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2>E<SPAN class=194552615-21052007>vals 
should not really be used unless you really do not have any other option. They 
cannot be optimissed in the RETE network and hence will run slower than 
predicates.</SPAN></FONT></DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=194552615-21052007></SPAN></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT><FONT><SPAN 
class=194552615-21052007></SPAN>
<DIV><SPAN class=194552615-21052007></SPAN><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2>W<SPAN class=194552615-21052007>ith 
kind regards,</SPAN></FONT></DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=194552615-21052007></SPAN></FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=194552615-21052007><FONT><FONT><FONT><SPAN 
class=194552615-21052007></SPAN>
<DIV><SPAN class=194552615-21052007></SPAN><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2>M<SPAN 
class=194552615-21052007>ike</SPAN><BR></DIV></FONT></FONT></FONT></FONT></SPAN></DIV><FONT 
face=Arial color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff 
size=2></FONT><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>Shahad 
  Ahmed<BR><B>Sent:</B> 21 May 2007 16:13<BR><B>To:</B> Rules Users 
  List<BR><B>Subject:</B> Re: [rules-users] using homemade Date in 
  Drools<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV>How about a slight modification on Mike's solution:</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2></FONT>&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>
  <DIV>Shahad</DIV>
  <DIV><BR>&nbsp;</DIV>
  <DIV><SPAN class=gmail_quote>On 5/21/07, <B class=gmail_sendername>Maxime 
  Catelin</B> &lt;<A onclick="return top.js.OpenExtLink(window,event,this)" 
  href="mailto:mcatelin@perinfo.com" target=_blank>mcatelin@perinfo.com </A>&gt; 
  wrote:</SPAN> 
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">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 é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 
    onclick="return top.js.OpenExtLink(window,event,this)" 
    href="mailto:rules-users-bounces@lists.jboss.org" 
    target=_blank>rules-users-bounces@lists.jboss.org </A><BR>&gt; [mailto:<A 
    onclick="return top.js.OpenExtLink(window,event,this)" 
    href="mailto:rules-users-bounces@lists.jboss.org" 
    target=_blank>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 onclick="return top.js.OpenExtLink(window,event,this)" 
    href="mailto:rules-users@lists.jboss.org" 
    target=_blank>rules-users@lists.jboss.org</A><BR>&gt; <A 
    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>&gt;<BR>&gt; _______________________________________________ 
    <BR>&gt; rules-users mailing list<BR>&gt; <A 
    onclick="return top.js.OpenExtLink(window,event,this)" 
    href="mailto:rules-users@lists.jboss.org" 
    target=_blank>rules-users@lists.jboss.org</A><BR>&gt; <A 
    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>&gt;<BR>&gt;<BR>&gt;<BR>_______________________________________________<BR>rules-users 
    mailing list<BR><A onclick="return top.js.OpenExtLink(window,event,this)" 
    href="mailto:rules-users@lists.jboss.org" 
    target=_blank>rules-users@lists.jboss.org</A><BR><A 
    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></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>