You need a way to differentiate between policy’s that have been updated and that haven’t been updated.

If you have control of your model then you could add an extra field, either as a flag or containing the new value – if this field is null you know you need to update it.

If you can’t change that part of the model you can introduce a new class PolicyUpdated(Service policy). When you update the policy you insert one of these. You then change your conditions to add “not PolicyUpdated(policy == $policy)” which will then stop you retriggering yourself. Finally you need to tell drools that you have modified Client.

It may be more efficient to actually fetch and insert the policy service objects into the working memory, then you only need to tell drools/your rules that you have updated one small part of your rules rather than getting it to reiterate over all the services every update.

 

Thomas

 

 

From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Wishing Carebear
Sent: 06 July 2011 04:47
To: Rules Users List
Subject: [rules-users] How to update the working memory of a nested object attribute

 

Hi,
My rules update the nested object attributes :eligibilityScore which is used in another rule downstream.

Only the Client object is sent as fact, the nested object is derived using the from keyword (list of services)

rule  "Rule 8 EligibilityRating"
    agenda-group  "EligibilityRating"
    no-loop true
    salience 5
    //dialect  "mvel"
    when
        $client : Client(type == "Preferred")
        $policy : Service(productType == "Vehicle Insurance") from $client.service
    then
        System.out.println(" Rule 8 ER = type == preferred:"+ $policy.getId() + ": -50");
        int eScore = $policy.getEligibilityScore() - 50;
        $policy.setEligibilityScore(eScore); // how to let the downstream rule know that this atribute value is updated without letting this current rule go into infinite loop
end

Any suggestion is greatly appreciated




**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************