<!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 > and <.<br>
<br>
Mark<br>
Edson Tirelli wrote:
<blockquote
cite="mid:e6dd5ba30705210852k14792a1dx782ed4c3a20cccbf@mail.gmail.com"
type="cite"><br>
Yes, Shahad's suggestion shall work, but answering your first
question, a predicate would be like:<br>
<br>
<div>rule XXX<br>
when<br>
obj1 : A( $date1: mydate)<br>
obj2 : A( $date2: mydate -> ( $date1.isBefore($date2) ) )
</div>
then<br>
// something<br>
obj1.doSomething();<br>
End<br>
<br>
Remember that predicates and evals use plain java code inside it. <br>
<br>
[]s<br>
Edson<br>
<br>
<br>
<div><span class="gmail_quote">2007/5/21, Shahad Ahmed <
<a moz-do-not-send="true" href="mailto:shahad.ahmed2@gmail.com">shahad.ahmed2@gmail.com</a>>:</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> </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>
<span class="sg">
<div>Shahad</div>
</span>
<div><span class="e" id="q_112af3ba0ee5b1c0_2">
<div><br>
</div>
<div><span class="gmail_quote">On 5/21/07, <b
class="gmail_sendername">Maxime Catelin</b> <<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>> 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, 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 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>
> [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>
> 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 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>
><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>
><br>
><br>
><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>
Edson Tirelli<br>
Software Engineer - JBoss Rules Core Developer<br>
Office: +55 11 3529-6000<br>
Mobile: +55 11 9287-5646<br>
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>