Drools Activation Group
by freejava
Hello Drools Experts,
I have a question on activation group and trying to understand the
mechanism.
I have the following rules in a .drl file :
import function com.test.utils.StringUtil.isEmpty;
import function com.test.utils.Logger.log;
rule "r1"
salience 10
activation-group "fireOnlyOnce"
when
SomeObject($s: someStringKey)
eval(isEmpty($s) // static java method imported as function
then
log("doSomething");
end
rule "r2"
activation-group "fireOnlyOnce"
when
SomeObject($s: someStringKey)
eval(checkWithDB($s) // Make a call to the DB to validate
someStringKeyis valid
then
log("doSomething");
end
In "r1" I am checking for 'someStringKey' is not null or empty. In "r2" , I
am making a call to the DB to check 'someStringKey' is a valid id. During
the debug, I found out that both "r1" and "r2" is fired but only one
consequence is executed depending on the outcome of the r1. I want "r2" to
fire only when "r1" evaluates to false. How can I achieve this in Drools?
Thanks for your time and appreciate your help.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Activation-Group-tp3546607p35466...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months
inconsistent behavior with the eclipse IDE and the Drools compiler
by Hezi Stern
Hi all,
I encountered the following strange inconsistent behavior with the eclipse
IDE and the Drools compiler.
I have the following test rule which should fire if a specific time
condition is present. The time condition is evaluated by a function called
getTimelineDescriptor() which is imported using import function.
rule "ScheduleTime: request for explicit time arrived"
when
ConditionMatrix(descriptors.times.timeline contains
getTimelineDescriptor(EButtonID.TIME_SPECIFIC) ||
descriptors.times.timeline contains
getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME) ||
descriptors.times.timeline contains
getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME),
$srcAlt: srcWorkingAlternative,
)
then
//something...
end
the IDE indicates an error on the conditionMatrix line with the following
description:
Multiple markers at this line
- [ERR 101] Line 123:77 no viable alternative at input '(' in rule
"ScheduleTime: request for explicit time arrived" in pattern ConditionMatrix
- [ERR 102] Line 123:103 mismatched input '||' expecting 'then' in rule
"ScheduleTime: request for explicit time arrived"
- [ERR 101] Line 123:101 no viable alternative at input ')' in rule
"ScheduleTime: request for explicit time arrived" in pattern
getTimelineDescriptor
BUT it compiles ok and runs properly.
When I wrap the function with brackets (as I thought it should be) like this
rule "ScheduleTime: request for explicit time arrived"
when
ConditionMatrix(descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)),
$srcAlt: srcWorkingAlternative,
)
then
//something...
end
the IDE shows no error but the compilation fails with the following error:
16:19:14,734 [ERROR] [LoggerStream]: Unable to Analyse Expression
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)):
[Error: unable to resolve method using strict-mode:
com.delegatecom.rules.ConditionMatrix.contains(com.delegatecom.nlp.api.Timel
ineDescriptor)]
[Near : {... tors.times.timeline contains (getTimelineDescripto ....}]
I am using Drools 5.2 with Helios (Eclipse).
Any ideas why this is so? Although I have a working option it is impossible
to maintain code when there are error indications.
Thanks,
Hezi
14 years, 4 months
guvnor restful api problem
by gcautiero
Hello to everyone,
i'm trying to upload a .drl file using guvnor's restFul service. But im not
able to get a POST call working.
what i'm trying to do is:
make a call first to get a content of .drl file already stored in Guvnon:
here the working code using cxf client (as the example in the guvnor doc):
WebClient c = WebClient.create("http://127.0.0.1:8081/");
String authorizationHeader = "Basic " +
org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes());
c.header("Authorization", authorizationHeader);
String content =
c.path("http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guv...").accept("text/plain").get(String.class);
then i try to upload the content in another asset
Here the code that DOSEN'T work:
Response response =
client.path("http://localhost:8081/guvnor-5.3.0.Final-tomcat-6.0/org.drools.guvnor.Guv...").accept("application/xml").post(content);
for this call i get the following error:
Nov 29, 2011 11:23:12 AM org.apache.catalina.core.StandardWrapperValve
invoke
SEVERE: Servlet.service() for servlet RestAPIServlet threw exception
java.lang.ArrayIndexOutOfBoundsException: 1
at org.drools.repository.remoteapi.RestAPI.post(RestAPI.java:235)
at
org.drools.guvnor.server.files.RestAPIServlet$1.execute(RestAPIServlet.java:56)
at
org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:75)
at
org.drools.guvnor.server.files.RestAPIServlet.doPost(RestAPIServlet.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
at
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Thread.java:662)
someone have a suggestion? or a working example?
tnx
Gianfranco
--
View this message in context: http://drools.46999.n3.nabble.com/guvnor-restful-api-problem-tp3544799p35...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months
Retrieving rule name in "then" clause
by Ronald Albury
Is there a simple way for me to be able to access the rule name in the
'then' clause?
When rules fail I want to pass the rule name into my internal error handler.
Thanks in advance
14 years, 4 months
Fusion : must declare @role(event) for all class hierarchy ?
by Vincent LEGENDRE
Hi all
We are using Fusion to make some simplification and grouping on some events.
We have several classes of events, all derivated from a top-level class .
With fusion version 5.3 (and 5.2 too), we must declare the @role(event) for the top-level class, but also for all its classes hierarchy , ie the role is not inherited by subclasses.
Is it done and purpose ?
Is it a bug ?
Thanks.
14 years, 4 months
Unclear error when rule name missing
by Ronald Albury
I guess I need to learn how to submit bugs. Any help is appreciated.
If you forget the name of the rule, instead of a clear error (like "Rule
name missing") you get a NullPointerException with no indication why.
Thanks
14 years, 4 months
RuleFlow WorkItem check for abort
by cherokee
Hello,
I am newbie to using drools and using version 5.1.1 for my ruleflow test
case.
Testcase:
In the workItemHandler for a workitem, whenever exception occurs I catch the
exception and
set manager.abortWorkItem(workItem.getId());
I have 2 questions:
1) Is there a way in the onExit of workItem i can check the state to
determine if it has been aborted or completed succesfully?
2) When does the "abortWorkItem" method on workItemHandler get called?
Appreciate your time in replying to my queries.
Thanks!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/RuleFlow-WorkItem-che...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 4 months
Re: [rules-users] Guvnor Hates Me
by Ronald Albury
First - I'd like to thank everyone for their help. I am finding Guvnor
less intuitive than I had hoped and I will need your continued patience and
assistance to understand it.
Problem 1:
I added Sample.drl (which contains two rules) from inside Eclipse, and
Guvnor split it into two rules (HelloWorld and GoodBye). I later changed
Sample.drl and when I went to update it thru Eclipse the 'Update' selection
was not highlighted - only the Add was available. So I added it again.
Now in Guvnor I have the two rules from when I first added the file, and
now the Sample.drl file itself. The Sample.drl file has the changes in it
and the two rules do not.
Problem 2:
I modified the Sample.drl file inside Eclipse again and went to update it
in Guvnor. It wouldn't let me update it - I could only Add. So I went
ahead and did an add. I can not find the changes anywhere in Guvnor.
Problem 3:
When I go to validate a rule in Guvnor it complains that it has an error
importing com.scs.test.Message. That is one of the classes in the PoJo jar
file that I have in Guvnor. I wanted the rules to be in com.scs.test.rules
and the Java code to be in com.scs.test. Can someone explain to me where I
have to put the Model, and if the Java classes need to have the same
package as the rules.
I am also having general problems about when to Save things. I originally
thought that when I uploaded something into Guvnor that was enough ... but
it appears that (at least under some conditions) I have to Save as well.
Do I have to Save things I've uploaded from Eclipse too? Guvnor never
seems to have what I think it should have.
14 years, 4 months