[rules-users] Defining fallback rules

Marcus Ilgner marcus.ilgner at gmail.com
Wed Sep 17 11:56:33 EDT 2008


Hi all,

I'm currently puzzled on how to implement a sort of fallback rule. In
my scenario I have a couple of articles and payments related to those
articles. Now I need to distribute royalties to the authors of these
articles. There's a common business logic which says "distribute X
percent for articles of type T, Y percent for articles of type S and Z
percent for all other articles".
At first, my approach was to write the rules like this (omitting a
rule for type 'S' for the sake of brevity):

rule1
activation-group "article1"
salience 100
when
  $article : Article(type == 'T')
  $payment : Payment( article==$article )
then
  account(x%)
end

rule3
activation-group "article1"
salience 0
when
  $article : Article()
  $payment : Payment( article==$article )
then
  account(z%)
end

However, I quickly found out that the use of activation-group will
then only consider all articles of type T and ignore all other
fact-combinations. Retracting payments from the WM is also not
feasible since there may be other rules that should work on them.
I also cannot write the last rule as Article( type != 'T', type != 'S'
etc) since new article types may be added later on and it would not be
manageable to update all previously written rules (which may very well
number in thousands in the future).
Now I'm a bit stuck on this issue and would welcome any hints.

Best regards
Marcus



More information about the rules-users mailing list