<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        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","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Verdana","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Verdana","sans-serif";
        color:navy;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='color:navy'>Hi,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:navy'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:navy'>Oops. A slight typo. The objects in
the RHS were “$tranche” and “$product”. I have modified in the mail below.<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:navy'><o:p> </o:p></span></p>
<div>
<p class=MsoNormal><span style='color:navy'>Regards,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:navy'>- Nimesh<o:p></o:p></span></p>
</div>
<p class=MsoNormal><span style='color:navy'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-family:"Tahoma","sans-serif"'> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Nimesh Muley<br>
<b>Sent:</b> Monday, November 24, 2008 11:24 AM<br>
<b>To:</b> 'Rules Users List'<br>
<b>Subject:</b> [rules-users] 2 levels of sorting / distribution in Drools
(Date + Proportionate)<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Hi,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I have tried to implement 2 levels (nested) of sorting /
distribution (Date and Proportionate) in Drools and failed :-(. I could not
accomplish when the second level was ‘proportionate’. Let me clear the terms
before I give the example.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>2 level --> The criteria chosen for the first level is
same then only apply the second level criteria. In SQL terms it would be “order
by date, avg price”. The first level was Date.<o:p></o:p></p>
<p class=MsoNormal>Proportionate --> Proportionate means distribute the
items / amount as proportion to what it contains.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The rule that is mentioned below did not work. There was no
issue in implementing sequence number as second priority.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>What happens is that the “$totalTrancheAmount” does not
include the facts (Tranche objects) that were already matched or being matched.
Basically the sum is always of the facts that are ‘yet’ to be matched.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Also what is needed is a fact understanding whether Tranche
got selected as a “proportionate” one or only based on date. For this we can
use if ($totalTrancheAmount > 0) condition on “then” side I suppose.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Is there any way of getting hold of all facts which taking
sum of childTrancheValue?<o:p></o:p></p>
<p class=MsoNormal> <o:p></o:p></p>
<p class=MsoNormal>rule "LIFO And Proportionate"<o:p></o:p></p>
<p class=MsoNormal>dialect "java"<o:p></o:p></p>
<p class=MsoNormal>salience 101<o:p></o:p></p>
<p class=MsoNormal> when<o:p></o:p></p>
<p class=MsoNormal>
$product : Product($productSeq : productSeq, vestedAmt > 0)<o:p></o:p></p>
<p class=MsoNormal>
$tranche : Tranche(productSeq == $productSeq, $maintrancheSeq : trancheSeq,
$trancheValue : trancheValue > trancheVestedAmt, $trancheCreationDate :
trancheCreationDt)<o:p></o:p></p>
<p class=MsoNormal>
not Tranche(claimProductSeq == $claimProductSeq, trancheSeq != $maintrancheSeq,
trancheValue > trancheVestedAmt, trancheCreationDt > $trancheCreationDate
)<o:p></o:p></p>
<p class=MsoNormal>
and<o:p></o:p></p>
<p class=MsoNormal>
(<o:p></o:p></p>
<p class=MsoNormal>
$totalTrancheAmount : Double ()
from accumulate ( Tranche($childtrancheValue : trancheValue, trancheCreationDt
== $trancheCreationDate, trancheValue > trancheVestedAmt), sum(
$childtrancheValue ))<o:p></o:p></p>
<p class=MsoNormal>
or<o:p></o:p></p>
<p class=MsoNormal>
eval(true)<o:p></o:p></p>
<p class=MsoNormal>
)<o:p></o:p></p>
<p class=MsoNormal> then<o:p></o:p></p>
<p class=MsoNormal>
// Vesting should happen based on proportionate if the dates were matched
otherwise based on which amount is greater.<o:p></o:p></p>
<p class=MsoNormal>
// Proportionate = $trancheValue / $ totalTrancheAmount<o:p></o:p></p>
<p class=MsoNormal>
vestTranche($product, $tranche);<o:p></o:p></p>
<p class=MsoNormal>
System.out.println(“$totalTrancheAmount : “ + $ totalTrancheAmount);<o:p></o:p></p>
<p class=MsoNormal>
update ($tranche);<o:p></o:p></p>
<p class=MsoNormal>
update ($product);<o:p></o:p></p>
<p class=MsoNormal>end<o:p></o:p></p>
<p class=MsoNormal>Thanks.<o:p></o:p></p>
<p class=MsoNormal>Regards,<o:p></o:p></p>
<p class=MsoNormal>- Nimesh<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><o:p> </o:p></span></p>
<table class=MsoNormalTable border=0 cellpadding=0 style='background:white'>
<tr>
<td style='padding:.75pt .75pt .75pt .75pt'>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif";
color:black'><br>
MASTEK LTD.<br>
Mastek is 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>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<o:p></o:p></span></p>
</td>
</tr>
</table>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><o:p> </o:p></span></p>
<table class=MsoNormalTable border=0 cellpadding=0 style='background:white'>
<tr>
<td style='padding:.75pt .75pt .75pt .75pt'></td>
</tr>
</table>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p>
</div>
<br><br><table bgcolor=white style="color:black"><tr><td><br>MASTEK LTD.<br>
Mastek is 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></table></body>
</html>