[rules-users] Question about Metadata for Rules

tservas tservas at web.de
Sun May 18 07:58:46 EDT 2008


Hello everybody,

I have a simple question about annotations for rules. Is it possible to add
metadata
to a rule in the following or in a similar way?

------------------------------------------------------------------------------------------------
@CostumAnnotation(ruleType=RuleType.GOOD, otherInformation="This rule ist
very important since ...")
rule "A rule with metadata"
when
    eval(true)
then
   
System.out.println(drools.getRule().getAnnotation(CostumAnnotation.class).toString());
end
------------------------------------------------------------------------------------------------
The annotatons should also be accesible within my java program otherwise it
wouldn't be very useful at all. So for example I should be able to do the
following

Package[] packages = ruleBase.getPackages();
for (Package pack : packages) {
    Rule[] rules = pack.getRules();
    for (Rule rule : rules) {
        rule.getAnnotation(CostumAnnotation.class).toString();
    }
} 

Why would I like to have such meta information along with my rules in one
file? ... here it comes ...

The result of firing all my rules is a list of all rules (whether they have
been fired or not)
with certain meta information.
On the lhs of each rule I append an entry to that list with all the meta
information. Depending
on the inserted facts only a subset of all my rules fires and only a few
rules will add entries to
the list. My problem is that I want the rules that havn't been fired to
appear in the list with all
the meta information.

A possible but not feasible solution would be to double all my rules. For
each rule I could
add second rule that fires if the original rule doesn't fire and this newly
added rule inserts the
entry in the list with all the meta information. Doubling the number of
rules makes editing rules
error prone and tedious.

Another strategy could be to put all the meta information in a separate
file. Via the rule name
all meta information could be uniquely assigned to one rule. This strategy
is also not very appealing
since I have a lot of rules and editing rules again becomes error prone and
tedious, since I have to
keep the metadata file in sync.

The by far best solution I can think of is to allow annotaions in the drl
file as shown above.

Any hints or suggestions about the stated problem are highly appreciated. 

Thanks in advance

-- 
View this message in context: http://www.nabble.com/Question-about-Metadata-for-Rules-tp17301548p17301548.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list