not at the moment - there have been some thoughts along those lines
though - that it may be useful to have them.
personally I find the @ syntax in java horrible, but hey, thats just me ;)
The rule attributes in a sense are attributes already - it woudl be a
matter of extending that to be user defined values that you can use at
runtime or however you need to.
On Sun, May 18, 2008 at 7:41 PM, tservas <tservas(a)web.de> wrote:
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-tp17300617p173006...
Sent from the drools - dev mailing list archive at
Nabble.com.
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
--
Michael D Neale
home:
www.michaelneale.net
blog:
michaelneale.blogspot.com