<!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">
Effective dates in 4.0.x come from Calendar.getInstance() so unless you
change the time that the java Calendar sees you cannot go back in time.
Trunk, and 5.0 (TBR in Q2/Q3),&nbsp; has a class called TimeMachine which
allows you to set the date.<br>
<br>
If you need control of this, and in 4.0.x, you will not be able to use
the effective date attributes. Instead I recommend you create your own
hashmap ofr effective dates per rule and use the agenda filter to
excludes ones that aren't within the allowed dates.<br>
<br>
Mark<br>
Nimesh Muley wrote:
<blockquote
 cite="mid:1F61BBD66BBDEC4DA0FE2B9AF22336FC2FD7C12837@ind-pne1mbx001.mastek.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName">
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
  <style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:Verdana;
        color:black;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:Verdana;
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Verdana;
        color:navy;
        font-weight:normal;
        font-style:normal;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
  </style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
  </o:SmartTagType>
  <div class="Section1">
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">I was not able to portray the
right picture </span></font><font color="navy" face="Wingdings"><span
 style="font-family: Wingdings; color: navy;">L</span></font><font
 color="navy"><span style="color: navy;">. Here&#8217;s another shot at
clarifying
my situation.<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">Let&#8217;s say we have a commission
rule as follows<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">rule "Commission Calculation <b><span
 style="font-weight: bold;">07-08</span></b>" <o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span
 style="font-weight: bold;">date-effective "01-Apr-2007"<o:p></o:p></span></b></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span
 style="font-weight: bold;">date-expires "30-Mar-2008"<o:p></o:p></span></b></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; when<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">end<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">Now for the next financial year
we define a new rule as
follows<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">rule "Commission Calculation <b><span
 style="font-weight: bold;">08-09</span></b>" <o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span
 style="font-weight: bold;">date-effective "01-Apr-2008"<o:p></o:p></span></b></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span
 style="font-weight: bold;">date-expires "30-Mar-2009"<o:p></o:p></span></b></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; when<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">end<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">Now let&#8217;s say <i><u><span
 style="font-style: italic;">today&#8217;s
date is 15<sup>th</sup> April 2008</span></u></i>. An agent is promoted
today
with <i><u><span style="font-style: italic;">effective date as 1<sup>st</sup>
March
2008</span></u></i>. Hence his commission needs to be recalculated as
per the &#8220;Commission
Calculation <b><span style="font-weight: bold;">07-08</span></b>&#8221; rule
and <b><u><span style="font-weight: bold;">not</span></u></b> the
effective rule as on today i.e.
&#8220;Commission Calculation <b><span style="font-weight: bold;">08-09</span></b>&#8221;.
For rest of the agents commission would be calculated based on the rule
effective today i.e. 15<sup>th</sup> April 2008. Hence a need to pass a
date
during execution of rule based on which the right rule would be chosen.<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">Basically there is no legacy
code as part of my example but
a need to fire the rules that are effective on a date other than the
system
date always.<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">I have seen similar
functionality in other rules engines
too. Can this be done in JBoss Rules? If yes, is TimeMachine the right
way of
doing it?<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">Regards,<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;">- Nimesh<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
 style="font-size: 10pt; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <div>
  <div class="MsoNormal" style="text-align: center;" align="center"><font
 color="black" face="Times New Roman" size="3"><span
 style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; color: windowtext;">
  <hr tabindex="-1" align="center" size="2" width="100%"></span></font></div>
  <p class="MsoNormal"><b><font color="black" face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma; color: windowtext; font-weight: bold;">From:</span></font></b><font
 color="black" face="Tahoma"><span
 style="font-family: Tahoma; color: windowtext;">
<a class="moz-txt-link-abbreviated" href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
[<a class="moz-txt-link-freetext" href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</a>] <b><span
 style="font-weight: bold;">On
Behalf Of </span></b>Scott Reed<br>
  <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, March
05, 2008
8:40 PM<br>
  <b><span style="font-weight: bold;">To:</span></b> Rules Users List<br>
  <b><span style="font-weight: bold;">Subject:</span></b> Re:
[rules-users] Setting
date during execution of rules.</span></font><font color="black"
 face="Times New Roman" size="3"><span
 style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; color: windowtext;"><o:p></o:p></span></font></p>
  </div>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">As I understand it, the problem is that you
have
legacy code that uses the system date in it's calculations and you
cannot fix
that so it will take a date parameter, right? If so, then my
recommendation is
to fix the legacy software if possible since messing with the system
date gives
me the willies. If you can't fix it, then anything that can be called
from Java
to set the system date (e.g.Runtime.exec(...).waitfor()?) should be
callable
from the 'then' part of a rule. Make that call, call your legacy code,
then
make the call to set the date back. But that is so ugly, please don't
tell
anyone I had anything to do with it.<br>
  <br>
  <st1:PersonName w:st="on">Nimesh Muley</st1:PersonName>'s message
received
3/5/2008 1:25 AM: <o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">Hi,<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;"><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">Is there a way to set the date while
executing the
rules? The effective dates would be checked against this date instead
of
today&#8217;s date. By default the effective dates would be checked with
System
date. But in some cases we would need to execute the rules in a
&#8216;back-dated&#8217; mode.<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;"><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">Use case.<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">Let&#8217;s say in insurance industry there are
commission calculation rules for an agent. On these rules the effective
dates
are appropriate (as per their needs). Now when an agent is promoted and
his/her
promotion date is couple of months back then we would want to calculate
the
commission once again with the date as 2 months back.<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;"><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">The nearest I could see is TimeMachine, as
this is
being used during execution of rules. Although I could not find a way
to set
the TimeMachine in release 4.0.4.<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;"><u1:p>&nbsp;</u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">Has anyone tried something like this before?<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">&nbsp;<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">Regards,<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">- Nimesh<u1:p></u1:p><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="black" face="Verdana" size="2"><span
 style="font-size: 10pt;">"The first 90% of a project takes 90% of the
time, the last 10% takes the other 90% of the time" - Murphy's Law<o:p></o:p></span></font></p>
  <p class="MsoNormal" style="margin-bottom: 12pt;"><font color="black"
 face="Times New Roman" size="3"><span
 style="font-size: 12pt; font-family: &quot;Times New Roman&quot;;">While
so very true, this is not Murphy's Law, which I think of as "Whatever
can
go wrong, probably will." (see <a moz-do-not-send="true"
 href="http://en.wikipedia.org/wiki/Murphy%27s_law">http://en.wikipedia.org/wiki/Murphy%27s_law</a>)<br>
Your rule here is called the 90-90 rule: <a moz-do-not-send="true"
 href="http://en.wikipedia.org/wiki/Ninety-ninety_rule">http://en.wikipedia.org/wiki/Ninety-ninety_rule</a><br>
  <br>
  <o:p></o:p></span></font></p>
  <table class="MsoNormalTable"
 style="background: white none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"
 bgcolor="white" border="0" cellpadding="0">
    <tbody>
      <tr>
        <td style="padding: 0.75pt;">
        <p class="MsoNormal"><font color="black" face="Times New Roman"
 size="3"><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;;"><o:p>&nbsp;</o:p></span></font></p>
        </td>
      </tr>
    </tbody>
  </table>
  <p class="MsoNormal"><font color="black" face="Times New Roman"
 size="3"><span
 style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; color: windowtext;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
  <br>
  <br>
  <table style="color: black;" bgcolor="white">
    <tbody>
      <tr>
        <td><br>
MASTEK&nbsp;LTD.<br>
Making&nbsp;a&nbsp;valuable&nbsp;difference<br>
Mastek&nbsp;in&nbsp;NASSCOM's&nbsp;'India&nbsp;Top&nbsp;20'&nbsp;Software&nbsp;Service&nbsp;Exporters&nbsp;List.<br>
In&nbsp;the&nbsp;US,&nbsp;we're&nbsp;called&nbsp;MAJESCOMASTEK<br>
        <br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
Opinions&nbsp;expressed&nbsp;in&nbsp;this&nbsp;e-mail&nbsp;are&nbsp;those&nbsp;of&nbsp;the&nbsp;individual&nbsp;and&nbsp;not&nbsp;that&nbsp;of&nbsp;Mastek&nbsp;Limited,&nbsp;unless&nbsp;specifically&nbsp;indicated&nbsp;to&nbsp;that&nbsp;effect.&nbsp;Mastek&nbsp;Limited&nbsp;does&nbsp;not&nbsp;accept&nbsp;any&nbsp;responsibility&nbsp;or&nbsp;liability&nbsp;for&nbsp;it.&nbsp;This&nbsp;e-mail&nbsp;and&nbsp;attachments&nbsp;(if&nbsp;any)&nbsp;transmitted&nbsp;with&nbsp;it&nbsp;are&nbsp;confidential&nbsp;and/or&nbsp;privileged&nbsp;and&nbsp;solely&nbsp;for&nbsp;the&nbsp;use&nbsp;of&nbsp;the&nbsp;intended&nbsp;person&nbsp;or&nbsp;entity&nbsp;to&nbsp;which&nbsp;it&nbsp;is&nbsp;addressed.&nbsp;Any&nbsp;review,&nbsp;re-transmission,&nbsp;dissemination&nbsp;or&nbsp;other&nbsp;use&nbsp;of&nbsp;or&nbsp;taking&nbsp;of&nbsp;any&nbsp;action&nbsp;in&nbsp;reliance&nbsp;upon&nbsp;this&nbsp;information&nbsp;by&nbsp;persons&nbsp;or&nbsp;entities&nbsp;other&nbsp;than&nbsp;the&nbsp;intended&nbsp;
recipient&nbsp;is&nbsp;prohibited.&nbsp;This&nbsp;e-mail&nbsp;and&nbsp;its&nbsp;attachments&nbsp;have&nbsp;been&nbsp;scanned&nbsp;for&nbsp;the&nbsp;presence&nbsp;of&nbsp;computer&nbsp;viruses.&nbsp;It&nbsp;is&nbsp;the&nbsp;responsibility&nbsp;of&nbsp;the&nbsp;recipient&nbsp;to&nbsp;run&nbsp;the&nbsp;virus&nbsp;check&nbsp;on&nbsp;e-mails&nbsp;and&nbsp;attachments&nbsp;before&nbsp;opening&nbsp;them.&nbsp;If&nbsp;you&nbsp;have&nbsp;received&nbsp;this&nbsp;e-mail&nbsp;in&nbsp;error,&nbsp;kindly&nbsp;delete&nbsp;this&nbsp;e-mail&nbsp;from&nbsp;desktop&nbsp;and&nbsp;server.<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
        </td>
      </tr>
    </tbody>
  </table>
  <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>