<!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> </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> </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> obj1 : A( $date1: mydate)<BR> obj2 :
A( $date2: mydate<SPAN class=194552615-21052007> ->
($date1.isBefore($date2)) </SPAN>)</FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2>then<BR> //
something<BR> 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> </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> </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> </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> </DIV>
<DIV>rule XXX<BR>when<BR> obj1 : A( $date1: mydate)<BR>
obj2 : A( $date2: mydate)</DIV>
<DIV> eval($date1.isBefore($date2)) <BR>then<BR> //
something<BR> 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. </DIV>
<DIV> </DIV>
<DIV>Regards</DIV>
<DIV>Shahad</DIV>
<DIV><BR> </DIV>
<DIV><SPAN class=gmail_quote>On 5/21/07, <B class=gmail_sendername>Maxime
Catelin</B> <<A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:mcatelin@perinfo.com" target=_blank>mcatelin@perinfo.com </A>>
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, on
our<BR>Date class and all the classes that have Date
members. 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. 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> obj : A( $date : mydate) <BR>
not A( $date.isBefore(mydate)) // does not work but that what i was
thinking<BR>then<BR> // something<BR>
obj.doSomething();<BR>end<BR><BR><BR><BR>Anstis, Michael (M.) a écrit
:<BR>> The simplest way could be to have your Date expose a "Time" type
member <BR>> (like java.util.Date.getTime()) that represents the number
of<BR>> seconds\milliseconds etc since a given point in time ("your
absolute<BR>> zero" for example; being day * month * year * H * M * s *
ms). This <BR>> could then be used as a simple predicate
condition:-<BR>><BR>> rule XXX<BR>>
when<BR>> obj1 : A( $time :
myTime)<BR>> obj2 : A( myTime < $time
)<BR>> then<BR>> //
something<BR>> obj.doSomething();<BR>>
End<BR>><BR>> Thanks,<BR>><BR>> Mike<BR>><BR>>
-----Original Message-----<BR>> 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>> [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>> Sent: 21 May 2007 14:34<BR>> To: Rules Users
List<BR>> Subject: [rules-users] using homemade Date in Drools
<BR>><BR>> Hi,<BR>><BR>> We are using a lot of Dates in our
application but we use a homemade <BR>> Date class for
that. Therefore, we cannot use > and < provided by<BR>>
Drools. I looked through the mailing list but could not find any
<BR>> examples using Dates in Drools other than in the
documentation. What <BR>> interested me in particular in the
documentation was "If more control is<BR>><BR>> required, use the
predicate constraint." <BR>><BR>> Could someone give some examples of
using predicate constraint with <BR>> dates?<BR>><BR>> Something I
would like to do, for example, is the following :<BR>><BR>> If there
is an obj1 of class A with field of type Date d1 and another <BR>> obj2
of class A with field Date d2, where d1 is before d2, obj2 should <BR>>
be used to fire something.<BR>><BR>> rule XXX<BR>>
when<BR>> obj : A( $date :
mydate)<BR>> // do not know how to use constraint
on date here. <BR>> then<BR>> //
something<BR>> obj.doSomething();<BR>>
end<BR>><BR>> Thanks for your input.<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>><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>><BR>><BR>><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>