Question about Metadata for Rules
by tservas
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-tp17301548p173015...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 7 months
Eclipse: No RuleTable's were found in spreadsheet.
by baldeagle42@web.de
Hello,
I have just converted an existing Java Project to a Drools Project in Eclipse (v3.3). Now I get the error message "No RuleTable's were found in spreadsheet." for my existing XLS spreadsheets.
Is there a possibility to switch off this check? Or is there really a second project required to put all the rule stuff inside?
Kind regards
Michael
______________________________________________________
Bis 50 MB Dateianhänge? Kein Problem!
http://freemail.web.de/club/landingpage.htm/?mc=025556
17 years, 7 months
Re: [rules-users] Matching on instanceof without eval?
by Christine
On Fri, May 23, 2008 15:47, Barry Kaplan wrote:
>
> I would like to match on the class of a field. I know I can use
> "eval(option instanceof OptionInstrument)",
Is what you do like
when option : Option (
option instanceof OptionInstrument,
......
)
?
why not
when option : OptionInstrument (
.....
)
?
Christine
17 years, 7 months
absent features in JSR-94 compliant drools
by Prem Kumar L
Hi All,
I would like to know the features in drools that can't be used when
using the JSR-94 compliant jars.
Any pointers would be much appreciated.
*The context:*
I am developing a rule engine for JCAPS/OpenESB. I need to figure out
the drools features that can't be used through the JAR-94 API. Based on
this finding, I can decide whether I have to develop a drools specific
rule engine or a JSR-94 compliant one.
Thanks
Prem
17 years, 7 months
Activation number
by Ming Fang
Are activation numbers supposed to be unique?
I am sometimes getting duplicated numbers.
--Ming
17 years, 7 months
Timeline for JBRMS
by Richard Ambridge
Are there any schedules for BRMS V2? Several items look like they will
solve some of our requirements.
Many thanks,
Ric
17 years, 7 months
Re:JUnit testing
by J. Michael Dean
>
Thanks. Sorry for few details as this has been a several message
question. I have created a Drools plugin that contains EITHER the
maximum number of jars and dependencies (i.e. ALL), or the minimum
(i.e. those needed for compiler option only processing DRL files), or
adding the entire Drools distribution to my Java extensions folder in
OS X, and in all instances, I get an error loading dialects. The
enigma for me is that all of these plugin options enable me to make a
stand alone RCP application that works fine.
Here is the test unit code:
@BeforeClass
public static void setUp() throws Exception {
Reader source;
PackageBuilderConfiguration pkgConfig = new
PackageBuilderConfiguration();
JavaDialectConfiguration javaDialectConf =
(JavaDialectConfiguration) pkgConfig.getDialectConfiguration("java");
javaDialectConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
final PackageBuilder builder = new PackageBuilder(pkgConfig);
boolean exists = (new File("rules/GlucoseDroolRules00.drl")).exists();
if (exists) {
builder.addPackageFromDrl(new FileReader(
"rules/GlucoseDroolRules00.drl"));
System.out.println("Found the file!");
} else {
System.out.println("Cannot locate the file - will try as resource");
source = new InputStreamReader(AllDroolsRulesTests.class
.getResourceAsStream("rules/GlucoseDroolRules00.drl"));
builder.addPackageFromDrl(source);
}
if (builder.hasErrors()) {
System.out.println(builder.getErrors().toString());
}
Package pkg = builder.getPackage();
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
}
It crashes in the line trying to instantiate the package
configuration. If I eliminate the lines that configure the package,
and invoke the package building without an argument (the default),
then the crash occurs in that line. The crash trace:
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
at
org
.drools
.compiler
.PackageBuilderConfiguration
.addDialect(PackageBuilderConfiguration.java:152)
at
org
.drools
.compiler
.PackageBuilderConfiguration
.buildDialectConfigurationMap(PackageBuilderConfiguration.java:140)
at
org
.drools
.compiler
.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:117)
at
org
.drools
.compiler
.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:94)
at
droolsRules.tests.AllDroolsRulesTests.setUp(AllDroolsRulesTests.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org
.eclipse
.jdt
.internal
.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org
.eclipse
.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org
.eclipse
.jdt
.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org
.eclipse
.jdt
.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org
.eclipse
.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org
.eclipse
.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)
Caused by: java.lang.NullPointerException
at
org
.drools
.compiler
.PackageBuilderConfiguration
.addDialect(PackageBuilderConfiguration.java:146)
... 18 more
This trace is identical in all instances. I have looked at the source
code and it appears that the Drools code is looking for the drools
configuration file, and I am not sure if this is included in the
classpath when running JUnit. However, the minimal and maximal plugin
configurations make an RCP run perfectly as a standalone application.
This is Eclipse 3.3 fall version, Mac OXX Leopard (but have run on
Tiger and same error, so not a new Apple bug), Drools 4.03, and JUnit 4.
Thanks.
> ------------------------------
>
> Message: 8
> Date: Tue, 4 Dec 2007 06:50:15 -0800 (PST)
> From: "John J. Franey" <jjfraney(a)gmail.com>
> Subject: Re: [rules-users] JUnit testing
> To: rules-users(a)lists.jboss.org
> Message-ID: <14151759.post(a)talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
>
>
> J Michael Dean wrote:
>>
>> I am having problems figuring out how to do JUnit 4 unit tests with
>> Drools and am wondering what I am missing.
>>
>
> I'm successfully using junit4 to test rules. I build a rules
> package from
> my rules file, create a stateful session, insert facts, fire all
> rules, run
> queries, and finally, perform junit asserts on the results.
>
> I can't tell you what you are missing, unless you say what you have.
>
> Regards,
> John
>
>
> --
> View this message in context: http://www.nabble.com/JUnit-testing-tf4930259.html#a14151759
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> End of rules-users Digest, Vol 13, Issue 6
> ******************************************
17 years, 7 months
Re: [rules-users] Nested Rules
by Christine
On Thu, May 22, 2008 11:30, Vishal Deshmukh wrote:
> Can i write nested rules like
Sure.
rule "rule 1 "
when
condition is true
then
set property in some object
rule "rule 2 "
when
property in some object has been set
then
action
However, if you need "nested rules", you probably need to rethink the way
you use rules. It would be easier to write
rule 1
if condition for rule 1 is true
and condition for rule 2 is true
then
action for rule 2.
end
the way the rule engine works makes this work exactly as you intended: it
checks condition 1, and only if true, it checks condition 2.
As a general design consideration, you want to combine as little
conditions as possible. Suppose you have ten parameters, and you have all
your rules test all paameters. In that case. you're better off hard coding
the procedure.
If you come up with the right set of rules that test only one or two of
the parameters and still produce the desired behavior, then you make
efficient use of the rule engine. I suggest you do some reading on how
rule engines work, it helps you design better rulebases. Don't go into
detail about the Rete algorithm in the Drools documentation, but rather
find some more general guide. I don't know one off the top of my head,
when I find one I'll post it.
dagdag
Christine
17 years, 7 months
https package url
by Cabou, Carl
Hi all,
I use the Business Rules Server to deploy rules packages and I use the
URL feature to consume them. It works fine but I am concern about
security in rules requests.
I've seen in the documentation that we can use SSL for BRMS login
security but what about url requests to rules packages ??
Regards,
Carl
17 years, 7 months