logging
by Thalupula Ravi
Hi,
How can i log that where a rule is executed or not for supplied data? If the
rule fires, in 'then' section i can have a log statement.
How can i log that the rule is not executed??
I need to log in both scenarios.
Thanks,
Ravi Thalupula
--
View this message in context: http://www.nabble.com/logging-tp17779598p17779598.html
Sent from the drools - user mailing list archive at Nabble.com.
18 years
Rule is firing on those objects for which that has already fired
by siddhartha banik
Hi All,
I am using Drools Stateful session with serialized Rule Base & Working
memory for my application. I need to write some rule which will *only* fire
on newly inserted data points in Working Memory. Does Drools support any
such feature which will help me to achieve this ? Any suggestion, how can I
achieve this efficiently?
As sample, I have written a rule bellow:
global RuleSetOutput ruleSetOutput
rule "sample_rule"
when
(p4: DataObject(id == 4, stringValue == "230007014")) and
(p14: DataObject(id == 14, stringValue == "230007004")) and
(p10: DataObject(id == 10, stringValue == "230007005")) and
(p11: DataObject(id == 11, stringValue == "230007006")) and
(p12: DataObject(id == 12, stringValue == "230007007")) and
(p13: DataObject(id == 13, stringValue == "230007008"))
then
String ruleID = "sample_rule";
RuleOutput ruleOutput =
RuleEngineHelper.getRuleOutput(ruleSetOutput, ruleID);
ruleOutput.addDataObject(p13);
ruleOutput.addDataObject(p4);
ruleOutput.addDataObject(p11);
ruleOutput.addDataObject(p14);
ruleOutput.addDataObject(p10);
ruleOutput.addDataObject(p12);
end
For 1st execution, I am inserting 6 matching DataObjects into Working
Memory. Rule is getting fired once & those 6 data points are getting added
into RuleOutput.
But in subsequent rule executions after I insert 6 more matching DataObjects
into Working Memory, Rule is getting fired couple of times & objects from
old executions also getting appended to the current RuleOutput.
How can I avoid this ?
Regards
Siddhartha
18 years
access to in working memory generated objects
by thomas kukofka
Hi,
I want to use rules which shall generate as a consequence a new java object.
The GUI of my application shall display the new generated objekt.
but how can the GUI of my application get informed by the rule engine that
it has generated a new object (Warning)? And how the GUI or any other java
component can access this new generated object from outside?
rule "Value below threshold"
when
FactX ( property < threshold)
then
insert(new Warning( "Under threshold" ) );
end
rule "Value above threshold"
when
FactX ( property >= threshold)
then
insert(new Warning("Threshold exceeded" ) );
end
regards
Thomas
18 years
Running Drools 4 examples
by Ron Kneusel
Greetings!
I am attempting to run the HelloWorld example for Drools 4. I have Eclipse 3.3 setup on Windows with the Drools plugin. I have created a project with the Drools examples and added all the Drools .jar files to the project. Everything compiles. When I initially ran HelloWorldExample.java it appeared that it could not find the HelloWorld.drl file. So, I moved that file into the same directory as HelloWorldExample.java and ran again. This time I am getting an error that the JDT compiler is not found even though it appears that there are JDT jar files in the Eclipse plugins.
I also attempted to run this example under Linux from the command line. In this case I placed all the Drools .jar files into the JRE ext folder and changed the source code to use the Janino compiler by adding:
// Set up for the Janino compiler, not Eclipse
System.setProperty("drools.dialect.java.compiler", "JANINO");
PackageBuilderConfiguration cfg = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)cfg.getDialectConfiguration("java");
This version compiles with javac and runs with java -cp . HelloWorldExample but gives me an error within the compiler while compiling the .drl file:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1938)
at org.drools.base.ClassTypeResolver.importClass(ClassTypeResolver.java:242)
at org.drools.base.ClassTypeResolver.resolveType(ClassTypeResolver.java:158)
at org.drools.rule.builder.dialect.mvel.MVELDialect.addImport(MVELDialect.java:257)
at org.drools.compiler.DialectRegistry.addImport(DialectRegistry.java:98)
at org.drools.compiler.PackageBuilder.mergePackage(PackageBuilder.java:377)
at org.drools.compiler.PackageBuilder.newPackage(PackageBuilder.java:350)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:267)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
at HelloWorldExample.main(HelloWorldExample.java:39)
It is dying on this line:
builder.addPackageFromDrl( source );
My version of HelloWorldExample.java the same as the given example except for the addition of the lines above for Janino. My ultimate goal is to run this all under Linux, I am not an Eclipse user.
Any help getting this working would be greatly appreciated!
Ron
_________________________________________________________________
Introducing Live Search cashback . It's search that pays you back!
http://search.live.com/cashback/?&pkw=form=MIJAAF/publ=HMTGL/crea=introsr...
18 years
Different working memories/rulebases for different application issues?
by thomaskukofka@web.de
Hi,
I'm quite a beginner with Drools and I want to integrate Drools in our
application. The application could use rules for different smaller
issues which use partly different facts as input. My question is if I
should use different rulebases or working memories for each issue or is
on rulesbase contiaining all rules which then refers to different fact
tyes and one session is enough? does it make sense to bundle the rules
for each issue in an own agenda group?
Regards
Thomas
18 years
how to find which condition evaluated to TRUE?
by Marina
Hello,
If I have a complex rule with a few conditions concatenated via AND and OR and NOT, and the rule evaluated to true during the engine run - is there a way to figure out which of the conditions caused the rule to evaluate to true?
In a simple example:
rule "test1"
dialect "java"
when
$data : ContractRulesData (region=='NE' && sum > 250)
then
approverList.add("approver1, approver2, Level1");
System.out.println("test1 is TRUE; result: approver1, approver2, Level1");
end
I tried to add an AgendaListener with the following code to find out which rules have fired:
public void afterActivationFired(AfterActivationFiredEvent event, WorkingMemory workingMemory) {
Activation activation = event.getActivation();
Rule rule = activation.getRule();
GroupElement[] leftElements = rule.getTransformedLhs();
System.out.println("afterActivationFired: rule = " + rule.getName());
System.out.println("Conditions: ");
for (GroupElement left_el: leftElements){
System.out.println(left_el.toString());
}
The output is somewhat cryptic :
afterActivationFired: rule = test1
Conditions:
AND[Pattern type='[ClassObjectType class=com.emptoris.ecm.domain.ContractRulesData]', index='0', offset='0', identifer='[Declaration: type=ValueType = 'Object' identifier=$data]']
So, is there a way to get even more information about the conditions and whether they evaluated to TRUE or FALSE?
Thanks,
Marina
18 years
Changing DSL in BRMS
by Richard Ambridge
Hi,
I have a DSL defined in BRMS
that says for example..
[when]The cat sat on the mat=Object(moose)
and then loads of rules defined that are using that DSL..
Now the business wants to change the words so that the DSL reads
[when]The dog sat on the mat=Object(moose)
That is easy to do, as I just edit the DSL..
but none of the rules change... and there are lots of them... now all
the rules fail validation
How can I search and replace the DSL in the rules?
Cheers
Ric
18 years