Rulebase EventListener
by sreenivas555
I am trying to add an event listener on adding a new rule / updating a rule.
Following are the steps. Somehow the listener is not getting called.
any help on this highly appreciable!!!!
Step1: Create an instance of
Extend DefaultRuleBaseEventListener and create an installce.
Mylistener mylistener=new Mylistener()
Sep2: Add to RuleBase instance .
rulesbase.addEventListener(mylistener)
Step3: Start the client. let the client sleep for 3 min.
Step4: Change the rule or Add rule.
This should call the methods in Mylistener. But it is NOT.
--
View this message in context: http://www.nabble.com/Rulebase-EventListener-tp23370433p23370433.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Locating facts via slot values
by Wolfgang Laun
Given a working memory containing a large number of rather static facts
which are from several subclasses (Ape, Bear, Crocodile,...) of some base
class (Animal) and a single fact of class Hunter with a field target of type
Animal, the shooting of an animal might be written with a rule like this:
rule shoot-1
when
?h : Hunter( ?target : target )
?a : Animal()
eval(?target == ?a)
then
?h.shoot( ?a );
retract( ?a );
end
Avoiding eval (which is said to be inefficient), it could also be written as
rule shoot-2
when
?a: Animal()
?h : Hunter( target == ?a )
then
?h.shoot( ?a );
retract( ?a );
end
This, however, places the pattern with many instances up front, which is
(AFAIK) not so good in a Rete implementation.
Which one is to be preferred in Drools?
Ideally, one might want to write
rule shoot-3
when
?h : Hunter( ?target : target )
?a == ?target : Animal() ### not valid DRL
then
?h.shoot( ?a );
retract( ?a );
end
This avoids eval, has the single instance fact up front, but it isn't
available.
-W
16 years, 7 months
Debugging Drools when/then using breakpoints
by lightbulb432
(I can't use Eclipse's debug as "Drools Application" feature because the
Drools application I'm using is embedded within a larger deployed web
application, so I must use breakpoints.)
Where can I set breakpoints in my IDE to know exactly when the when/then
sides of a rule are evaluated? I know that the "then" side of a rule is
executed when DefaultAgenda.fireActivation(Activation) method is run, so
every time that breakpoint is hit I know that a rule's "then" side is about
to be fired.
However, I don't know where to set the breakpoint for the "when" side of the
rule - where is this?
Assuming I have 10 rules in total but in a particular scenario only 1 of
those is actually fired successfully after executing the "when" tests, what
I'd like to see is 10 "when" breakpoints being hit and only 1 "then"
breakpoint being hit.
--
View this message in context: http://www.nabble.com/Debugging-Drools-when-then-using-breakpoints-tp2336...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
JSR-94 API - adding an event listener
by Meny Kobel
Hi,
Does the JSR-94 API includes a method for adding an event listener to the
rule session?
If not any hack I can use?
I'm using drools version 4.0.7.
Thanks
Meny
16 years, 7 months
What does the arrow ("->") mean in a rule file?
by lightbulb432
What does the arrow ("->") mean in a rule file? I've searched on Google,
looked through the Drools documentation, and haven't been able to find out
what it does.
It appears in the autocomplete of my IDE for Drools, and I've seen it in an
example in the JBoss Seam documentation, but am unable to tell what it does:
rule InsertMemberBlog
no-loop
activation-group "permissions"
when
principal: Principal()
memberBlog: MemberBlog(member : member ->
(member.getUsername().equals(principal.getName())))
check: PermissionCheck(target == memberBlog, action == "insert", granted
== false)
then
check.grant();
end;
--
View this message in context: http://www.nabble.com/What-does-the-arrow-%28%22-%3E%22%29-mean-in-a-rule...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Rules question
by Armaghan Mahmud
I'm new to the mailing list so I'll start off by saying hello to everyone.
I've recently started using DROOLS and I seem to have hit a dead end. I'm
trying to pass in an enum and a list into the working memory one at a time
but I would like my rule to first see if it the enum matches a hard coded
enum value. Additionally, I would also like the rule to see if the enum
value that is being passed to the working memory happens to fall in the list
or not. First of all, is it possible to do that in one rule? I've been
trying to do that using "&&" and "contains" keywords but I'm not getting
anywhere. I don't have the code in front of me or I would've pasted it but I
hope you can understand my point. Any help that I can get in this matter
will be greatly appreciated.
Thanks,
Armaghan
16 years, 7 months
CEP functionality
by David Boaz
Dear all,
We posted this question two weeks ago, but with no replies. please forgive
me for posting it again.
In our business, most of the facts have time-stamp attributes. For example,
each laboratory test (a fact) has the time stamp when the sample was taken,
and when the machine produced the result value. In our business-logic, we
often analyze the relation between facts using these attributes.
For example:
1) finding two adjacent labResults with an increasing value
2) checking whether 3 facts are consecutive
3) counting the number of facts fulfilling a specific constraint within a
specific time window.
We were happy to read (in the blog) about the new CEP feature which is about
to be added to drools 5.0.
* Where can we find a more detailed description of CEP functionality in
drools?
* Is it a good idea to use CEP for analyzing historic data (retrieved from
the database)? or is it best for online data.
* Can we use CEP in a stateless session?
* As we understand, CEP attaches to each fact a temporal attribute of the
assertion time. Can we define that a particular attribute (e.g.,
LabResult.samplingDate) will be used as the time stamp? Or, should we assert
the facts by their temporal order, and advance the session-clock
appropriately?
* Can we use CEP to analyze the data in the examples above?
Many thanks for the help, David
--
View this message in context: http://www.nabble.com/CEP-functionality-tp19020709p19020709.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Stateless session and rule flows
by Yoni Mazar
Hi Guys,
We are trying to work with drools with stateless session (Sequential) and to
apply rule flows.
we use the following code:
//define diagnosis and patient here
...
StatelessSession session = ruleBase.newStatelessSession();
//Here we would like to use: session.startProcess("ruleflow id") but this is
a method which belongs to
//StatefullSession only.
session.execute(new Object[] {diagnosis, patient});
How can we do that in steteless mode?
Thanks,
Yoni
--
View this message in context: http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p1786384...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
NullPointerException for Integer null
by techy
Hello,
For following rule, NullPointerException is thrown for null id in 4.x. is
this expected? Please clarify.
Foo{
Integer id;
}
Rule "null check"
foo : Foo(id==null)
then
end
stack trace:
java.lang.NullPointerException
at
org.drools.base.extractors.BaseObjectClassFieldExtractor.getIntValue(BaseObjectClassFieldExtractor.java:95)
at
org.drools.base.ClassFieldExtractor.getIntValue(ClassFieldExtractor.java:197)
at
org.drools.base.evaluators.IntegerFactory$IntegerLessEvaluator.evaluate(IntegerFactory.java:241)
at
org.drools.rule.VariableRestriction.isAllowed(VariableRestriction.java:73)
at org.drools.rule.VariableConstraint.isAllowed(VariableConstraint.java:67)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:160)
--
View this message in context: http://www.nabble.com/NullPointerException-for-Integer-null-tp23286041p23...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months