<!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=450283511-29012009><FONT face=Arial 
color=#0000ff size=2>Hi David,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2>Sorry it was of little help.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><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 class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><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 class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><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 class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face="Courier New" 
color=#0000ff size=2>rule "yuck"</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT 
face="Courier New"><FONT color=#0000ff size=2>&nbsp;&nbsp;&nbsp; 
when</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT 
face="Courier New"><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DateFactory($today : 
today&nbsp;)</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT 
face="Courier New"><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $c : CreditCard( $expires : 
expirationDate )</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face="Courier New" 
color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ArrayList( size 
&gt;= 0 ) from collect( Day(&nbsp;date&nbsp;&gt;= $today, date &lt;= $expires 
))<BR>&nbsp;&nbsp;&nbsp; then</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT 
face="Courier New"><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //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 class=450283511-29012009>end</SPAN><SPAN 
class=450283511-29012009></DIV></SPAN></FONT></FONT></FONT>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><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 class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2>Good luck with your adventures with 
Drools.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=450283511-29012009><FONT face=Arial 
color=#0000ff size=2>Mike</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 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>Not sure--Drools 5 temporal reasoning looks like it would be the 
  answer.&nbsp; Only problem is that I need a solution now, so I am stuck with 
  Drools 4.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>This did give me some ideas though.&nbsp; I created myself a class called 
  TemporalReasoner.&nbsp; 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>&nbsp;</DIV>
  <DIV>So in my rule, lets say I have a fact CreditCard with property 
  expiration:Date (speaking uml-ishly for "a property named&nbsp;'expiration' of 
  type Date"):</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face="courier new,monospace">rule "Fires when expiration less than 
  today"</FONT></DIV>
  <DIV><FONT face="courier new,monospace">&nbsp; when</FONT></DIV>
  <DIV><FONT face="courier new,monospace">&nbsp;&nbsp;&nbsp; $c: 
  CreditCard($expires : expirationDate)</FONT></DIV>
  <DIV><FONT face="courier new,monospace">&nbsp;&nbsp;&nbsp; eval(new 
  TemporalReasoner(Calendar.getInstance()).lessThan($expires))</FONT></DIV>
  <DIV><FONT face="courier new,monospace">&nbsp; then</FONT></DIV>
  <DIV><FONT face="courier new,monospace">&nbsp;&nbsp;&nbsp; // do something for 
  when credit card is still valid</FONT></DIV>
  <DIV><FONT face="courier new,monospace">end</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Now, I'm still generally a noob with BRs, so I'm not sure how this will 
  affect performance.&nbsp; Any advice?</DIV>
  <DIV>&nbsp;</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>&lt;<A 
  href="mailto:manstis1@ford.com">manstis1@ford.com</A>&gt;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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 class=Wj3C7c>
      <DIV></DIV>
      <DIV>Hi-</DIV>
      <DIV>&nbsp;</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.&nbsp; In other words, I need to 
      compare a date to see if it is&nbsp;<EM>x</EM> days from the current 
      date,&nbsp;<EM>n</EM> hours from current time, etc.&nbsp; Would anyone be 
      kind enough to provide an example?&nbsp; I'm thinking I may have to 
      implement something of my own to offer that functionality?</DIV>
      <DIV>&nbsp;</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">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></BLOCKQUOTE></BODY></HTML>