<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I am probably still misunderstanding, but it seems that the effective
and expires dates are constants that can be used in the left hand side
of the rules:<br>
rule "Commission Calculation 07-08"<br>
when<br>
$agent: Agent( promotedDate >= "01-Apr-2007",<br>
promotedDate <=
"30-Mar-2008")<br>
$sale: Sale( agent = $agent, $amount: amount )<br>
....<br>
then<br>
$agent.addCommission( $sale, $amount, .09); // .09 is
the commission rate for this rule<br>
....<br>
end<br>
<br>
<br>
Now for the next financial year we define a new rule as follows<br>
<br>
rule "Commission Calculation 08-09"<br>
when<br>
$agent: Agent( promotedDate >= "01-Apr-2008",<br>
promotedDate <=
"30-Mar-2009")<br>
$sale: Sale( agent = $agent, $amount: amount )<br>
....<br>
then<br>
$agent.addCommission( $sale, $amount, .06); // .06 is
the commission rate for this rule<br>
end<br>
<br>
Nimesh Muley's message received 3/6/2008 1:00 AM:
<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’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> </o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
style="font-size: 10pt; color: navy;">Let’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;"> <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;"> <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;"> 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;"> ....<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
style="font-size: 10pt; color: navy;"> 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;"> ....<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> </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;"> <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;"> <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;"> 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;"> ....<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
style="font-size: 10pt; color: navy;"> 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;"> ....<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> </o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Verdana" size="2"><span
style="font-size: 10pt; color: navy;">Now let’s say <i><u><span
style="font-style: italic;">today’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 “Commission
Calculation <b><span style="font-weight: bold;">07-08</span></b>” rule
and <b><u><span style="font-weight: bold;">not</span></u></b> the
effective rule as on today i.e.
“Commission Calculation <b><span style="font-weight: bold;">08-09</span></b>”.
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> </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> </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> </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> </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: "Times New Roman"; 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: "Times New Roman"; 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> </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> </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’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
‘back-dated’ 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> </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’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> </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> </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;"> <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: "Times New Roman";">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: "Times New Roman";"><o:p> </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: "Times New Roman"; color: windowtext;"><o:p> </o:p></span></font></p>
</div>
<br>
<br>
<table style="color: black;" bgcolor="white">
<tbody>
<tr>
<td><br>
MASTEK LTD.<br>
Making a valuable difference<br>
Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.<br>
In the US, we're called MAJESCOMASTEK<br>
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended
recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and 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>
</body>
</html>