Building a high-level editor for DRL-Files
by skasab2s
Hello,
in our company we have written many DRL-Files in the domain of medicine. Now
we want to use the Drools-IDE plugin for Eclipse in order to create a GUI
for editing DRL-Files, so that DRL-files can be edited by doctors with less
programming knowledge and not by the developers anymore. We imagine this as
a stand-alone plugin for Eclipse for graphical editing of DRL-Files (similar
to graphical editors for XML-Files).
As we mentioned above, we want to use the Drools-IDE (RCP) plugin as basis
for our application. Do you know where to start? Any ideas, advices? Is this
feature (or a similar to this feature) already implemented? We looked to
the guided editor for .BRL-files but it is very restrictive (only one rule
can be defined, no globals, etc). Can DSL-writing help us solve our problem?
Many thanks, regards and sorry for the many questions,
skasab2s.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Building-a-high-level...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
Events older than x minutes
by Mike Love
Hi,
I have a requirement to identify events added to a stream that are older
that x minutes. E.g. Event A is added to the stream and when event B is
added then event A is removed, if no event B is added within 5 minutes of
event A being added then perform xyz().
Any assistance would be greatly appreciated.
Regards,
Mike
14 years, 5 months
Avoiding writing redundant rules
by skasab2s
Hello,
in our company we use DRL-files and we have the problem with the fact, that
rules have no 'else'-part. We've read in this forum, that we can simulate
the else-part of a rule by declaring a new rule which has the constraints of
the first rule, but negated. We regard this as some kind of redundancy in
our code , besides our rule-files become twice as large and drools have to
evaluate the (almost) same constraints twice.
We wanted to ask you if it makes sense to declare additional variables in
order to mark if a rule has fired. Something like this:
<code>
declare FirstRuleHasFired
value: boolean
end
...
//Insert an object from type FirstRuleHasFired
...
rule "FirstRule" salience 100
when
Person (name)
then
//do some job
firstRuleHasFired.setValue(true) ;
end
rule "SecondRule" salience 90
when
not(FirstRuleHasFired(value == true))
then
//do some other job
)
..
</code>
Or do you know some other useful tricks to avoid the redundancy I have
written about?
Thanks a lot for every idea and/or advice!
Regards,
skasab2s
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Avoiding-writing-redu...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
Deploying Drools 5.0 project as Axis2 Web Service on Tomcat5.5
by Hans.Dampf
Hello,
I want to deploy a Drools project as a web service. I am using Drools 5.0,
tomcat-5.5.28 and Netbeans 6.9 to deploy the project as an Axis2 web
service. The project just uses a simple decision table and works locally. If
I try to run the service on the tomcat server I get the Runtime Exception
java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.clips.ClipsDialectConfiguration.
I added all Drools libraries to the .aar file. Especially the
drools-clips-5.0.1.jar is deployed, that should contain the missing class.
I also tried to use the JANINO compiler as described here:
http://community.jboss.org/wiki/RulesTomcat/diff?secondVersionNumber=8, but
that didn't solve the problem.
Are there any known conflicts between drools libraries and tomcat libraries
that could cause the error?
Thanks and Regards
Hans Dampf
The code that causes the error:
public BREService(){
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
final DecisionTableConfiguration dtableconfiguration =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtableconfiguration.setInputType( DecisionTableInputType.XLS );
kbuilder.add( ResourceFactory.newClassPathResource("Sample.xls",
Laborwert.class ), ResourceType.DTABLE, dtableconfiguration);
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
}
Error Message:
[ERROR] Exception occurred while trying to invoke service method null
org.apache.axis2.AxisFault: Unable to load dialect
'org.drools.rule.builder.dial
ect.clips.ClipsDialectConfiguration:clips:null'
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at
org.apache.axis2.receivers.AbstractMessageReceiver.makeNewServiceObje
ct(AbstractMessageReceiver.java:251)
at
org.apache.axis2.receivers.AbstractMessageReceiver.getTheImplementati
onObject(AbstractMessageReceiver.java:283)
at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic
(RPCMessageReceiver.java:71)
at
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusines
sLogic(AbstractInOutMessageReceiver.java:40)
at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe
ssageReceiver.java:100)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq
uest(HTTPTransportUtils.java:275)
at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1
33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:172)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:174)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:873)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:689)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools
.rule.builder.dialect.clips.ClipsDialectConfiguration:clips:null'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBui
lderConfiguration.java:274)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigura
tionMap(PackageBuilderConfiguration.java:259)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderCo
nfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilder
Configuration.java:148)
at
org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuil
derConfiguration(KnowledgeBuilderProviderImpl.java:21)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfigu
ration(KnowledgeBuilderFactory.java:68)
at bre.BREService.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
org.apache.axis2.receivers.AbstractMessageReceiver$8.run(AbstractMess
ageReceiver.java:242)
at
org.apache.axis2.java.security.AccessController.doPrivileged(AccessCo
ntroller.java:132)
at
org.apache.axis2.receivers.AbstractMessageReceiver.makeNewServiceObje
ct(AbstractMessageReceiver.java:239)
... 23 more
Caused by: java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.cli
ps.ClipsDialectConfiguration
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1386)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1232)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBui
lderConfiguration.java:268)
... 38 more
[ERROR] Unable to load dialect
'org.drools.rule.builder.dialect.clips.ClipsDiale
ctConfiguration:clips:null'
org.apache.axis2.AxisFault: Unable to load dialect
'org.drools.rule.builder.dial
ect.clips.ClipsDialectConfiguration:clips:null'
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at
org.apache.axis2.receivers.AbstractMessageReceiver.makeNewServiceObje
ct(AbstractMessageReceiver.java:251)
at
org.apache.axis2.receivers.AbstractMessageReceiver.getTheImplementati
onObject(AbstractMessageReceiver.java:283)
at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic
(RPCMessageReceiver.java:71)
at
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusines
sLogic(AbstractInOutMessageReceiver.java:40)
at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe
ssageReceiver.java:100)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq
uest(HTTPTransportUtils.java:275)
at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1
33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:172)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:174)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:873)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:689)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools
.rule.builder.dialect.clips.ClipsDialectConfiguration:clips:null'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBui
lderConfiguration.java:274)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigura
tionMap(PackageBuilderConfiguration.java:259)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderCo
nfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilder
Configuration.java:148)
at
org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuil
derConfiguration(KnowledgeBuilderProviderImpl.java:21)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfigu
ration(KnowledgeBuilderFactory.java:68)
at bre.BREService.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
org.apache.axis2.receivers.AbstractMessageReceiver$8.run(AbstractMess
ageReceiver.java:242)
at
org.apache.axis2.java.security.AccessController.doPrivileged(AccessCo
ntroller.java:132)
at
org.apache.axis2.receivers.AbstractMessageReceiver.makeNewServiceObje
ct(AbstractMessageReceiver.java:239)
... 23 more
Caused by: java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.cli
ps.ClipsDialectConfiguration
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1386)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1232)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBui
lderConfiguration.java:268)
... 38 more
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Deploying-Drools-5-0-...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
lock-on-active, why keeps evaluating?
by mmarmol
He guys, I am using the meta-data lock-on-active on some rules and is working
great, but i have seen rules with lock-on-active = true are been eveluated
everytime the facts are modified even after they have been fired. Why is
that? I dont see the point of evaluating a rule with lock-on-active true
when it has already fired, it wont fire again. There is a way to resolve
this? or to implement something to avoid reevaluation? I am using drools
5.1.0M2 with a StatefulKnowledgeSession.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/lock-on-active-why-ke...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
Getting the Fact type for Declared Types
by Srinath Perera
Hi All,
I have declared type (rules are given below), and I want to access it
through kbase.getFactType(...) see below.
===== Rule =============
package sample1
import java.util.Date
declare Person
name : String
dateOfBirth : Date
address : String
end
============ Code =================
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newFileResource("src/ruleset1.drl"),
ResourceType.DRL );
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
// get the declared FactType
FactType personType = kbase.getFactType( "sample1", "Person" );
============================================
But personType returned by kbase.getFactType(..) is null. Could anyone
know can give me a hand?
--Srinath
--
============================
Srinath Perera, Ph.D.
WSO2 Inc. http://wso2.com
Blog: http://srinathsview.blogspot.com/
14 years, 5 months
How to configure conditional elements (IN, FROM) in Guvnor and more
by Patricia Bogoevici
Hi,
I am evaluating Drools Guvnor for our application, and I am stuck with a few things. I appreciate a lot, if someone can help me, or give me some hints.
1) How can I configure Guvnor, BRL Guided Editor, to allow for IN conditional element?
By default, when I create a new package, and then create a new BRL rule, I have these options for a text Fact field:
- equal
- not equal
- matches
- sounds
I do have the IN conditional element for the Decision Table rule - "is contained in the a (comma separated) list".
2) How can I configure Guvnor, Decision table, to use the FROM condition element?
I have a fact, Fact1, that contains a list of Fact2. The condition I need to configure in the Decision Table, is to iterate the collection of Fact2 objects that is on the Fact1, and apply constraints on Fact2 fields.
3) How can I insert a list of facts when testing a rule? My test case is the following:
I have a Fact1, which contains a list of Fact2. And the rule, is expecting to get Fact1, with a list of Fact2 inside.
When I create the Fact1, and add the collection field, it shows the option to create a guided list where I can specify a literal value, or a variable. But there is nowhere to create a Fact2 with its fields. I did inserted 2 separate Fact2 objects, but how I can link these 2 objects to the collection of the Fact1?
Thanks in advance,
Patricia
14 years, 5 months
Static Imports
by Meeraj Kunnumpurath
Hi,
Are static imports as shown below allowed in rule files? It is giving me a
parse exception.
package mypackage;
dialect "mvel"
import mypackage.CreditTransferTransactionInformation10;
import static mypackage.ValidationHelper.invalidate;
global java.util.Set accountNumbers;
rule "Check debtor account number is not null"
salience -1
when
$c : CreditTransferTransactionInformation10 ( eval(
dbtrAcct.?id.?othr.?id == null ) )
then
invalidate($c, "PG003", "Account number is absent");
drools.halt();
end
Ta
Meeraj
14 years, 5 months
Persistence with Drools 5.1.0.M2
by Rory Farrell
Hi, I'm trying to get persistence working in Drools 5.1.0.M2. I read
through the documentation and the drools-user forum posts and made some
progress but I'm stuck at:
SEVERE: Error in named query: ProcessInstancesWaitingForEvent
org.hibernate.QueryException: cannot dereference scalar collection
element: name [select processInstanceInfo.processInstanceId from
org.drools.persistence.processinstance.ProcessInstanceInfo
processInstanceInfo where :type in (processInstanceInfo.eventTypes.name)]
Here are the steps I've followed so far:
1. Read the documentation and cut and pasted the code to run and persist
a small sample ruleflow. I got the following exception:
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or
@ManyToMany targeting an unmapped class:
org.drools.persistence.processinstance.ProcessInstanceInfo.variables[org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo]
2. Read through the forum and added the following lines to the
persistence.xml file:
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
I got the following exception:
Caused by: java.lang.IllegalArgumentException: Named query not found:
ProcessInstancesWaitingForEvent
3. Read through the forum again and the only thing I found was a post
saying to make sure that the orm.xml with the named query was in the
META-INF directory in the drools-persistence-jpa.jar. I checked and the
orm.xml with the named query was in the
drools-persistence-jpa-5.1.0.M2.jar. I tried copying the orm.xml into a
META-INF directory in my classpath and I got the following exception:
SEVERE: Error in named query: ProcessInstancesWaitingForEvent
org.hibernate.QueryException: cannot dereference scalar collection
element: name [select processInstanceInfo.processInstanceId from
org.drools.persistence.processinstance.ProcessInstanceInfo
processInstanceInfo where :type in (processInstanceInfo.eventTypes.name)]
I'm stuck at this point. It looks like the orm.xml is not in sync with
the Drools 5.1.0.M2 code. I'm sure that someone must have this working.
If so, could you post the orm.xml file that you are using or give me a
pointer as to where I might be going wrong?
Regards,
Rory
14 years, 5 months