Hi,

I am using Drools version 5.0 . I am facing an issue in my LHS that I haven't 
been able to figure out how to resolve :-

The rule looks like this :-

when
    $customerCart : CustomerGrid($c_holdings : cartHoldings, $c_productTypes: 
productTypes, $c_details : customerDetails)
    $productType : java.lang.String() from $c_productTypes
    $productType_total : Double()
                        from accumulate (
                            CustomerHolding(productType == $productType, $value 
: percent) from $c_holdings,
                            sum ($value)
                        )
    $ch : CustomerHolding (productType == $productType, $group : productGroup) 
from $c_holdings
    $productType_reference : CustomerDetail(identifier (== $productType || == 
$group) , $productType_limit : purchaseLimit)
                                                                            
from $c_details
    eval ($productType_limit < Math.abs($productType_total.doubleValue()))
then
                System.out.println("XYZ");
End


The issue is with this line of code
    $ch : CustomerHolding (productType == $productType, $group : productGroup) 
from $c_holdings

This will get executed as many times as there are number of  CustomerHolding 
objects for the given  $productType in the $c_holdings collection.
All I need to do is simply get the Associated $group with the $productType and 
thus should only get executed once.
Any idea how to go about writing this rule ?

Also is there a better way to write this rule ?

Regards,
Akash


--------------------------------------------------------------------------
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or 
views contained herein are not intended to be, and do not constitute, advice 
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and 
Consumer Protection Act. If you have received this communication in error, 
please destroy all electronic and paper copies and notify the sender 
immediately. Mistransmission is not intended to waive confidentiality or 
privilege. Morgan Stanley reserves the right, to the extent permitted under 
applicable law, to monitor electronic communications. This message is subject 
to terms available at the following link: 
http://www.morganstanley.com/disclaimers. If you cannot access these links, 
please notify us by reply message and we will send the contents to you. By 
messaging with Morgan Stanley you consent to the foregoing.
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to