<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=240180613-29012009><FONT face=Arial
color=#0000ff size=2>You got it.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=240180613-29012009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=240180613-29012009><FONT face=Arial
color=#0000ff size=2>You won't find this proposal in any pattern books!!
;-)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=240180613-29012009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=240180613-29012009><FONT face=Arial
color=#0000ff size=2>At least you understood the syntax, so you can now
officially consider yourself not a noob.</FONT></SPAN></DIV><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>David
Siefert<BR><B>Sent:</B> 29 January 2009 12:59<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> Re: [rules-users] Working with dates in
rules<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Ah! Sorry, I believe you were saying Day is a fact that I would have to
create for each likely day.... The collect operation is what gathers all
those (Day) facts into a list that is counted. so the rule fires if there is
more than 0 day facts.</DIV>
<DIV> </DIV>
<DIV>My bad!</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>David<BR><BR></DIV>
<DIV class=gmail_quote>On Thu, Jan 29, 2009 at 6:53 AM, David Siefert <SPAN
dir=ltr><<A
href="mailto:siefert.david.mailinglist@gmail.com">siefert.david.mailinglist@gmail.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<DIV>Hey, that was quite clever. Where can I find more about
Day()? I did some research about DateFactory which I can see how dates
get parsed according to the documentation, as well as compared with the
conditional operators (<, >, <=, >=, etc).</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>David<FONT color=#888888><BR><BR></FONT></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>
<DIV class=gmail_quote>On Thu, Jan 29, 2009 at 5:57 AM, Anstis, Michael (M.)
<SPAN dir=ltr><<A href="mailto:manstis1@ford.com"
target=_blank>manstis1@ford.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Hi
David,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Sorry
it was of little help.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>A rule
of thumb is to stay away from "eval" as it kills performance (the patterns
can't be indexed).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>I'm
not sure if Drools can handle Date variables (the docs state it handles
Data literals formatted as "dd-mmm-yyyy" so Cheese( date == "27-Oct-2008")
works).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>I
guess you could look at something like this (gees, this is going to show
how "green" I am with Drools now):-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>rule "yuck"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT color=#0000ff
size=2> when</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT color=#0000ff
size=2> DateFactory($today :
today )</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT color=#0000ff
size=2> $c : CreditCard(
$expires : expirationDate )</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> ArrayList( size >= 0
) from collect( Day( date >= $today, date <= $expires
))<BR> then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New"><FONT color=#0000ff
size=2> //Difference between
"today" and "expiry date" is more than zero
days</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><FONT size=2><FONT color=#0000ff><FONT
face="Courier New"><SPAN>end</SPAN><SPAN></SPAN></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>This
does require the insertion of (possibly) huge amounts of Day facts. Yuck.
There must be a better way (in fact your eval looks soooo much cleaner).
I'm just throwing out ideas. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Good
luck with your adventures with Drools.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2>
<DIV><B>From:</B> <A href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of
</B>David Siefert<BR></DIV><B>Sent:</B> 29 January 2009
11:31<BR><B>To:</B> Rules Users List<BR><B>Subject:</B> Re:
[rules-users] Working with dates in rules<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV>
<DIV></DIV>
<DIV>Not sure--Drools 5 temporal reasoning looks like it would be the
answer. Only problem is that I need a solution now, so I am stuck
with Drools 4.</DIV>
<DIV> </DIV>
<DIV>This did give me some ideas though. I created myself a class
called TemporalReasoner. This has a few methods, namely to roll a
date (so I can tell it x amount of time from now), and then compare it
to another date.</DIV>
<DIV> </DIV>
<DIV>So in my rule, lets say I have a fact CreditCard with property
expiration:Date (speaking uml-ishly for "a property
named 'expiration' of type Date"):</DIV>
<DIV> </DIV>
<DIV><FONT face="courier new,monospace">rule "Fires when expiration less
than today"</FONT></DIV>
<DIV><FONT face="courier new,monospace"> when</FONT></DIV>
<DIV><FONT face="courier new,monospace"> $c:
CreditCard($expires : expirationDate)</FONT></DIV>
<DIV><FONT face="courier new,monospace"> eval(new
TemporalReasoner(Calendar.getInstance()).lessThan($expires))</FONT></DIV>
<DIV><FONT face="courier new,monospace"> then</FONT></DIV>
<DIV><FONT face="courier new,monospace"> // do
something for when credit card is still valid</FONT></DIV>
<DIV><FONT face="courier new,monospace">end</FONT></DIV>
<DIV> </DIV>
<DIV>Now, I'm still generally a noob with BRs, so I'm not sure how this
will affect performance. Any advice?</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>David<BR><BR></DIV>
<DIV class=gmail_quote>On Thu, Jan 29, 2009 at 3:50 AM, Anstis, Michael
(M.) <SPAN dir=ltr><<A href="mailto:manstis1@ford.com"
target=_blank>manstis1@ford.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Hi,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>I
wonder whether Drools 5 "Complex Event Processing Support (Temporal
Reasoning)" might be what you're looking for?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2><A
href="http://blog.athico.com/2008/07/drools-50-m1-new-and-noteworthy.html"
target=_blank>http://blog.athico.com/2008/07/drools-50-m1-new-and-noteworthy.html</A></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>With kind regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Mike</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf
Of </B>David Siefert<BR><B>Sent:</B> 29 January 2009
09:40<BR><B>To:</B> Rules Users List<BR><B>Subject:</B>
[rules-users] Working with dates in rules<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV>
<DIV></DIV>
<DIV>Hi-</DIV>
<DIV> </DIV>
<DIV>I'm wondering how it would be possible to compare a part of a
date in the lhs condition of a rule in a Drool. In other
words, I need to compare a date to see if it is <EM>x</EM> days
from the current date, <EM>n</EM> hours from current time,
etc. Would anyone be kind enough to provide an example?
I'm thinking I may have to implement something of my own to offer
that functionality?</DIV>
<DIV> </DIV>
<DIV>Big thanks,</DIV>
<DIV>David</DIV></DIV></DIV></BLOCKQUOTE></DIV><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><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></DIV><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><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>