<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" 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 = ""><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16735" name=GENERATOR>
<STYLE>@font-face {
        font-family: Cambria Math;
}
@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@font-face {
        font-family: Verdana;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Verdana","sans-serif"
}
LI.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Verdana","sans-serif"
}
DIV.MsoNormal {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Verdana","sans-serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: "Verdana","sans-serif"; mso-style-type: personal
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: "Verdana","sans-serif"; mso-style-type: personal
}
SPAN.EmailStyle19 {
        COLOR: navy; FONT-FAMILY: "Verdana","sans-serif"; mso-style-type: personal-reply
}
..MsoChpDefault {
        FONT-SIZE: 10pt; mso-style-type: export-only
}
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 vLink=purple link=blue>
<DIV><SPAN class=257341514-24112008><FONT face=Verdana color=#000080 size=2>The
solution, if posted to the group, may help others avoid similar
mistakes.</FONT></SPAN></DIV>
<DIV><SPAN class=257341514-24112008><FONT face=Verdana color=#000080 size=2>If
possible, can you please post your solution?</FONT></SPAN></DIV>
<DIV><SPAN class=257341514-24112008><FONT face=Verdana color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=257341514-24112008><FONT face=Verdana color=#000080
size=2>Thanks</FONT></SPAN></DIV>
<DIV><SPAN class=257341514-24112008><FONT face=Verdana color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=257341514-24112008><FONT face=Verdana color=#000080
size=2>Aj</FONT></SPAN></DIV>
<DIV><FONT face=Verdana color=#000080 size=2></FONT> </DIV><FONT
face=Verdana color=#000080 size=2></FONT><BR><!--eMS5.0.5.D18M.11Y.2008-->
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
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 8:19 AM<BR><B>To:</B> 'Rules
Users List'<BR><B>Subject:</B> RE: [rules-users] 2 levels of sorting /
distribution in Drools (Date + Proportionate)<BR><BR></FONT></DIV>
<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">I have been able to solve this.
Was an issue the way I had written my rule.<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">Thanks.<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-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<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:31 AM<BR><B>To:</B> 'Rules
Users List'<BR><B>Subject:</B> RE: [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><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-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<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: 12pt"><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"><o:p> </o:p></SPAN></P>
<TABLE class=MsoNormalTable style="BACKGROUND: white" cellPadding=0
border=0><TBODY>
<TR>
<TD
style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt">
<P class=MsoNormal><SPAN
style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'"><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></TBODY></TABLE>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"><o:p> </o:p></SPAN></P>
<TABLE class=MsoNormalTable style="BACKGROUND: white" cellPadding=0
border=0><TBODY>
<TR>
<TD
style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt"></TD></TR></TBODY></TABLE>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"><o:p> </o:p></SPAN></P>
<TABLE class=MsoNormalTable style="BACKGROUND: white" cellPadding=0
border=0><TBODY>
<TR>
<TD
style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt">
<P class=MsoNormal><SPAN
style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 'Times New Roman','serif'"><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></TBODY></TABLE>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"><o:p> </o:p></SPAN></P>
<TABLE class=MsoNormalTable style="BACKGROUND: white" cellPadding=0
border=0><TBODY>
<TR>
<TD
style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt"></TD></TR></TBODY></TABLE>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"><o:p> </o:p></SPAN></P></DIV><BR><BR>
<TABLE style="COLOR: black" bgColor=white>
<TBODY>
<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></TBODY></TABLE></BLOCKQUOTE></BODY></HTML>