Reputation:
I have to port some stored procedures into Drools. Since stored procedures follow an imperative programming model, I am finding it tricky to convert them into Drools rules. For example, I could have a series of case statements like this:
case
when <condition 1> then <action 1>
when <condition 2> then <action 2>
when <condition 3> then <action 3>
end
Because there is an ordering implied in the evaluation above, i.e. evaluate condition 1 first, then condition 2, and then condition 3 I am finding it difficult to translate that into Drools. In Drools, I just write the rules without order specified. How can I achieve the ordering implied by the above SQL into Drools rules? Do I have to create a JPBM process and have a rule task for each of the conditions in the above SQL?
Upvotes: 1
Views: 1705
Reputation: 9480
Look up salience
and activation-group
in the manual.
The salience
property gives you a mechanism for defining priority of rules.
The activation-group
property enables you to enforce that only one rule in a particular group is activated.
By combining those, you have something approximating a case/switch statement.
Upvotes: 2