Is it possible to retrieve rule name in the then clause of drool rule?
rule "A"
when
---
then
// something that outputs "A"
Thanks.
Well, the answer is we can't call a Rule from another Rule. Drools matches the Rules with incoming data/facts, and if the data satisfies the Rule condition, it stores the data in an Agenda. It might be possible for the same data or facts to be matched by different rules, so it stores matching facts in an Agenda.
Rule Definition − It consists of the Rule Name, the condition, and the Consequence. Drools keywords are rule, when, then, and end. In the above example, the rule names are “Hello World” and “GoodBye”. The when part is the condition in both the rules and the then part is the consequence.
List list = dpojo. getAnswers(); for( Object obj: list ){ String s = (String)obj; if( s. length() > 0 ){ ... } }
DRL (Drools Rule Language) rules are business rules that you define directly in . drl text files. These DRL files are the source in which all other rule assets in Business Central are ultimately rendered.
Yes, in then clause you may use expression:
drools.getRule().getName()
As Cyril said, you can get the rule name in the then clause by calling drools.getRule().getName() of the drools rule.
Just a little more info, you can check the getName() method in Rule Interface in the following api: http://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/definition/rule/Rule.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With