<br>&nbsp;&nbsp; Dan,<br><br>&nbsp;&nbsp; This is a feature that is in our to-do list. Jess calls it &quot;slot specific updates&quot;. We did not had the time yet to implement it though. :(<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">
2008/11/4 Dan Seaver <span dir="ltr">&lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Your understanding is very close to what I&#39;m looking for. I don&#39;t mind having<br>
multiple rule activations in other areas of the ruleset when the Fact is<br>
updated, I just don&#39;t want the current rule, the one with the update<br>
statement, to be reactivated.<br>
<br>
Accumulate plus no-loop works fine for the specific case of updating<br>
amounts, but I&#39;d like to have something generic for more sophisticated logic<br>
that would be implemented in the &quot;then&quot; clause.<br>
<br>
Maybe if there was something that looked specifically at each property of<br>
the update? In this case, the &quot;when&quot; clause is looking at the &quot;name&quot;<br>
property and the &quot;then&quot; clause is updating the &quot;amount&quot; property. As the<br>
&quot;name&quot; is not being changed, then the update wouldn&#39;t reactivate the rule.<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
Greg Barton wrote:<br>
&gt;<br>
&gt; If you have the control fact that handles the &quot;applied == false&quot; condition<br>
&gt; you wouldn&#39;t need to prevent reactivation of the rule. &nbsp;It would be<br>
&gt; handled by the condition.<br>
&gt;<br>
&gt; I&#39;m thinking Edson&#39;s accumulate suggestion would be best, at this point.<br>
&gt;<br>
&gt; If I understand correctly, what you want is this:<br>
&gt;<br>
&gt; 1) One rule Fact/Charge activation per Charge instance, with no<br>
&gt; reactivation when the Fact is updated.<br>
&gt; 2) Other Fact dependent rule activations when the Fact is updated.<br>
&gt;<br>
&gt; The problem with making (1) happen is that you&#39;d still have the matched<br>
&gt; Fact being updated once per Charge, which could lead to reactivation of<br>
&gt; the rules in (2) multiple times, which you may not want. &nbsp;If you use<br>
&gt; accumulate in the Fact/Charge rule, plus no-loop to prevent reactivation,<br>
&gt; you get the best of both worlds: single activation of the Fact/Charge<br>
&gt; rule, with a single update to notify other rules that the Fact has<br>
&gt; changed.<br>
&gt;<br>
&gt; I think what you&#39;re after is some kind of &quot;modify group,&quot; where multiple<br>
&gt; calls to modify are counted as just one, and rules are notified when the<br>
&gt; group is closed out. &nbsp;I&#39;m not sure how that would be implemented, because<br>
&gt; how do you know when the modifications are finished? &nbsp;A low priority rule,<br>
&gt; possibly? &nbsp;Anyway, it doesn&#39;t exist in drools, afaik.<br>
&gt;<br>
&gt; You could do that kind of thing with an additional rule that tests for the<br>
&gt; nonexistence of an unprocessed Charge, then does the update. &nbsp;Adding in<br>
&gt; the control fact for tracking Charges:<br>
&gt;<br>
&gt; rule &quot;Update Amount&quot;<br>
&gt; &nbsp; &nbsp;when<br>
&gt; &nbsp; &nbsp; &nbsp; amountFact : Fact(name == &quot;Amount&quot;)<br>
&gt; &nbsp; &nbsp; &nbsp; $charge : Charge()<br>
&gt; &nbsp; &nbsp; &nbsp; chargeTracker : ChargeTracker(charge == $charge, applied == false)<br>
&gt; &nbsp; &nbsp;then<br>
&gt; &nbsp; &nbsp; &nbsp; Double amount = amountFact.getAmount();<br>
&gt; &nbsp; &nbsp; &nbsp; Double chargeAmount = charge.getAmount();<br>
&gt; &nbsp; &nbsp; &nbsp; amountFact.setAmount(amount + chargeAmount);<br>
&gt; &nbsp; &nbsp; &nbsp; chargeTracker.setApplied(true);<br>
&gt; &nbsp; &nbsp; &nbsp; update(charge);<br>
&gt; end<br>
&gt;<br>
&gt; rule &quot;Close Facts After Charges Applied&quot;<br>
&gt; &nbsp; &nbsp;no-loop false<br>
&gt; &nbsp; &nbsp;when<br>
&gt; &nbsp; &nbsp; &nbsp; amountFact : Fact(name == &quot;Amount&quot;)<br>
&gt; &nbsp; &nbsp; &nbsp; not ChargeTracker(applied == false)<br>
&gt; &nbsp; &nbsp;then<br>
&gt; &nbsp; &nbsp; &nbsp; update(amountFact);<br>
&gt; end<br>
&gt;<br>
&gt; You&#39;d probablt also have to prevent the &quot;Close Facts&quot; rule from firing<br>
&gt; when there&#39;s just no ChargeTrackers in working memory, too.<br>
&gt;<br>
&gt; Give that a try.<br>
&gt;<br>
&gt; --- On Tue, 11/4/08, Dan Seaver &lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; From: Dan Seaver &lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt;<br>
&gt;&gt; Subject: Re: [rules-users] Chart notation, update, and infinite loops<br>
&gt;&gt; To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; Date: Tuesday, November 4, 2008, 1:55 PM<br>
&gt;&gt; Greg,<br>
&gt;&gt; 1) Yes, in this case I&#39;m looking for the cartesian<br>
&gt;&gt; join.<br>
&gt;&gt; 2) No, I can&#39;t add a property to Charge as it&#39;s<br>
&gt;&gt; part of our corp Object<br>
&gt;&gt; Model.<br>
&gt;&gt;<br>
&gt;&gt; However, I could create a third object that manages whether<br>
&gt;&gt; the Charge has<br>
&gt;&gt; been processed which works just fine. Unless there is a<br>
&gt;&gt; simpler strategy /<br>
&gt;&gt; technique, I&#39;ll go with that.<br>
&gt;&gt;<br>
&gt;&gt; Do you know of any way to keep the rule from being put back<br>
&gt;&gt; on the agenda<br>
&gt;&gt; when amountFact is updated? I want other rules to know that<br>
&gt;&gt; it&#39;s been<br>
&gt;&gt; updated, just not the rule that made the change.<br>
&gt;&gt;<br>
&gt;&gt; Dan<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Greg Barton wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; 1) Do you want to apply all Charges in working memory<br>
&gt;&gt; to all &quot;Amount&quot;<br>
&gt;&gt; &gt; Facts? &nbsp;I ask because the rule is a cartesian join<br>
&gt;&gt; (i.e. no relation<br>
&gt;&gt; &gt; between matched objects) and that sometimes performs<br>
&gt;&gt; in ways users don&#39;t<br>
&gt;&gt; &gt; expect. (i.e. all combinations of objects that match<br>
&gt;&gt; the conditions are<br>
&gt;&gt; &gt; affected by the rule)<br>
&gt;&gt; &gt; 2) Can you add a property to the Charge object? &nbsp;Then<br>
&gt;&gt; you could use a<br>
&gt;&gt; &gt; boolean named &quot;applied&quot; to prevent future<br>
&gt;&gt; matches.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Rule &quot;Update Amount&quot;<br>
&gt;&gt; &gt; &nbsp; &nbsp;when<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; amountFact : Fact(name == &quot;Amount&quot;)<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; charge : Charge(applied == false)<br>
&gt;&gt; &gt; &nbsp; &nbsp;then<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; Double amount = amountFact.getAmount();<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; Double chargeAmount = charge.getAmount();<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; amountFact.setAmount(amount + chargeAmount);<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; update(amountFact);<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; charge.setApplied(true);<br>
&gt;&gt; &gt; &nbsp; &nbsp; &nbsp; update(charge);<br>
&gt;&gt; &gt; end<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; If a charge could be applied to multiple Facts you<br>
&gt;&gt; could maintain an<br>
&gt;&gt; &gt; &quot;appliedTo&quot; list of Facts in the Charge, and<br>
&gt;&gt; check that instead of a<br>
&gt;&gt; &gt; simple boolean.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --- On Tue, 11/4/08, Dan Seaver<br>
&gt;&gt; &lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; From: Dan Seaver &lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt;<br>
&gt;&gt; &gt;&gt; Subject: [rules-users] Chart notation, update, and<br>
&gt;&gt; infinite loops<br>
&gt;&gt; &gt;&gt; To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; Date: Tuesday, November 4, 2008, 11:50 AM<br>
&gt;&gt; &gt;&gt; I&#39;m trying to find a good technique for<br>
&gt;&gt; updating<br>
&gt;&gt; &gt;&gt; specific facts in working<br>
&gt;&gt; &gt;&gt; memory. What I&#39;m currently doing is something<br>
&gt;&gt; like<br>
&gt;&gt; &gt;&gt; this:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Rule &quot;Update Amount&quot;<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp;when<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp; &nbsp; amountFact : Fact(name ==<br>
&gt;&gt; &quot;Amount&quot;)<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp; &nbsp; charge : Charge()<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp;then<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp; &nbsp; Double amount = amountFact.getAmount();<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp; &nbsp; Double chargeAmount = charge.getAmount();<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp; &nbsp; amountFact.setAmount(amount + chargeAmount);<br>
&gt;&gt; &gt;&gt; &nbsp; &nbsp; &nbsp; update(amountFact);<br>
&gt;&gt; &gt;&gt; end<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; The update statement causes an infinite loop.<br>
&gt;&gt; &gt;&gt; I tried using no-loop, which works if there is 1<br>
&gt;&gt; charge,<br>
&gt;&gt; &gt;&gt; but not if there<br>
&gt;&gt; &gt;&gt; are more than one.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Any help with solutions or strategies would be<br>
&gt;&gt; much<br>
&gt;&gt; &gt;&gt; appreciated.<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; View this message in context:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; <a href="http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html" target="_blank">http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html</a><br>

&gt;&gt; &gt;&gt; Sent from the drools - user mailing list archive<br>
&gt;&gt; at<br>
&gt;&gt; &gt;&gt; Nabble.com.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; rules-users mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; rules-users mailing list<br>
&gt;&gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context:<br>
&gt;&gt; <a href="http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20329780.html" target="_blank">http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20329780.html</a><br>

&gt;&gt; Sent from the drools - user mailing list archive at<br>
&gt;&gt; Nabble.com.<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
--<br>
</div></div>View this message in context: <a href="http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20334594.html" target="_blank">http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20334594.html</a><br>

<div><div></div><div class="Wj3C7c">Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>