Hi,
I have been able to solve this. Was an issue the way I had written my rule.
Thanks.
Regards,
- Nimesh
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Nimesh Muley
Sent: Monday, November 24, 2008 11:31 AM
To: 'Rules Users List'
Subject: RE: [rules-users] 2 levels of sorting / distribution in Drools (Date +
Proportionate)
Hi,
Oops. A slight typo. The objects in the RHS were "$tranche" and
"$product". I have modified in the mail below.
Regards,
- Nimesh
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Nimesh Muley
Sent: Monday, November 24, 2008 11:24 AM
To: 'Rules Users List'
Subject: [rules-users] 2 levels of sorting / distribution in Drools (Date +
Proportionate)
Hi,
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.
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.
Proportionate --> Proportionate means distribute the items / amount as proportion to
what it contains.
The rule that is mentioned below did not work. There was no issue in implementing sequence
number as second priority.
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.
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.
Is there any way of getting hold of all facts which taking sum of childTrancheValue?
rule "LIFO And Proportionate"
dialect "java"
salience 101
when
$product : Product($productSeq : productSeq, vestedAmt > 0)
$tranche : Tranche(productSeq == $productSeq, $maintrancheSeq : trancheSeq,
$trancheValue : trancheValue > trancheVestedAmt, $trancheCreationDate :
trancheCreationDt)
not Tranche(claimProductSeq == $claimProductSeq, trancheSeq !=
$maintrancheSeq, trancheValue > trancheVestedAmt, trancheCreationDt >
$trancheCreationDate )
and
(
$totalTrancheAmount : Double () from accumulate (
Tranche($childtrancheValue : trancheValue, trancheCreationDt == $trancheCreationDate,
trancheValue > trancheVestedAmt), sum( $childtrancheValue ))
or
eval(true)
)
then
// Vesting should happen based on proportionate if the dates were matched
otherwise based on which amount is greater.
// Proportionate = $trancheValue / $ totalTrancheAmount
vestTranche($product, $tranche);
System.out.println("$totalTrancheAmount : " + $
totalTrancheAmount);
update ($tranche);
update ($product);
end
Thanks.
Regards,
- Nimesh
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~