<div dir="ltr"><br>&nbsp;&nbsp; The easiest solution, given your description of the problem, I think is to add a &quot;processed&quot; flag to Article if possible. So your fallback rule, besides having a lower salience as you already have, would just check for articles that were not processed yet:<br>
<br>rule fallback<br>when<br>&nbsp;&nbsp;&nbsp;&nbsp; Article( processed == false )<br>&nbsp;&nbsp;&nbsp;&nbsp; ...<br>end<br><br>&nbsp;&nbsp; The flag must be set on the consequence of the other rules though, what may not be ideal. <br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">
2008/9/17 Marcus Ilgner <span dir="ltr">&lt;<a href="mailto:marcus.ilgner@gmail.com">marcus.ilgner@gmail.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;">
Hi all,<br>
<br>
I&#39;m currently puzzled on how to implement a sort of fallback rule. In<br>
my scenario I have a couple of articles and payments related to those<br>
articles. Now I need to distribute royalties to the authors of these<br>
articles. There&#39;s a common business logic which says &quot;distribute X<br>
percent for articles of type T, Y percent for articles of type S and Z<br>
percent for all other articles&quot;.<br>
At first, my approach was to write the rules like this (omitting a<br>
rule for type &#39;S&#39; for the sake of brevity):<br>
<br>
rule1<br>
activation-group &quot;article1&quot;<br>
salience 100<br>
when<br>
 &nbsp;$article : Article(type == &#39;T&#39;)<br>
 &nbsp;$payment : Payment( article==$article )<br>
then<br>
 &nbsp;account(x%)<br>
end<br>
<br>
rule3<br>
activation-group &quot;article1&quot;<br>
salience 0<br>
when<br>
 &nbsp;$article : Article()<br>
 &nbsp;$payment : Payment( article==$article )<br>
then<br>
 &nbsp;account(z%)<br>
end<br>
<br>
However, I quickly found out that the use of activation-group will<br>
then only consider all articles of type T and ignore all other<br>
fact-combinations. Retracting payments from the WM is also not<br>
feasible since there may be other rules that should work on them.<br>
I also cannot write the last rule as Article( type != &#39;T&#39;, type != &#39;S&#39;<br>
etc) since new article types may be added later on and it would not be<br>
manageable to update all previously written rules (which may very well<br>
number in thousands in the future).<br>
Now I&#39;m a bit stuck on this issue and would welcome any hints.<br>
<br>
Best regards<br>
Marcus<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>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>