Hi,
This problem needs to be solved conceptually before technically.
Assuming (I can't use Agenda Groups in decision tables).
SUMMARY
-------
Some rules evaluate some logic and pass it to a rule which aggregates the logic
to give the final outcome. Now that requires use of update. (or insert)
Before I get into the details as I usually do; one quick Question:
Q) Are recursion a result of update() or can they be caused by insert()???
because i have an alternative hypothesis using insert() (described in my
solution section)
DETAILS
--------
So exact scenario in 'Rules' is below; and this causes infinite-recursion.
Note: I've solved it but I'm looking for something more sophisticated or clean.
My current solution is written below after the problem is described in rules.
rule "Main"
no-loop true
when
cntct: Contact(initialized==true)
eval(cntct.extendedProperty("Table1_Output",true) ==true)
then
...
end
# setExtendedProperty = hashMap
rule "Rule_1"
no-loop true
when
cntct: Contact(initialized==true)
cfg_tab1: BooleanConfiguration(value!=false, param=="x1")
then
cntct.setExtendedProperty("Table1_Output", false);
...
update(cntct);
end
rule "Rule_2"
no-loop true
when
cntct: Contact(initialized==true)
cfg_tab2: BooleanConfiguration(value!=false, param=="x2")
then
cntct.setExtendedProperty("Table2_Output", false);
...
update(cntct);
end
rule "Rule_3"
no-loop true
when
cntct: Contact(initialized==true)
cfg_tab3: BooleanConfiguration(value!=false, param=="x3")
then
cntct.setExtendedProperty("Table3_Output", false);
...
update(cntct);
end
-----------------------
My solution: take one of the rules:
rule "Rule_3"
no-loop true
when
cntct: Contact(initialized==true)
cfg_tab3: BooleanConfiguration(value!=false, param=="x3")
## Line below filters & restrcits the execution to once only per table ##
eval(cntct.extendedProperty("Table1_Output",true) ==true)
then
cntct.setExtendedProperty("Table3_Output", false);
...
update(cntct);
end
Criticism of my own solution:
1. This solution, will only allow one rule to fire per table (For each rule 1,
there is a table of rules like rule 1, similarly for rule 2 type rules there is
a table if you just play with true and false values in those rules)?
Even with Agenda-Groups; again how do you do an update() once you know the
rules of the agenda have all fired??? Can we program that in the rules itself??
2. Can i use insert instead of update(cntct) and insert another Object into
working memoy and evaluate that as part of a condition to prevent recursion?
I feel adding conditions to control activations and sequence as a path of long
term confusion, so can you please provide a more sophisticated approach or re-
evaluate my approaches to the least?
Thanks,
Arjun