Help on using Drools with embedded objects
by Divya Rajendranath
Hi,
I am planning to use Drools - JBoss Rules Engine. My requirement is to
disburse mails from my application to different groups based on various
criteria. I want to use Drools here.
My object structure is as follows:
class A{
String B = "";
B b;
C c;
}
Hence Obj A has embedded objects within it, and obj B and C further has
embedded objects.
class B {
String X;
Z z;
}
class Z{
String t;
String s;
}
The decision on sending the mails based on the fields in embedded objects of
A. I pass instance of A to Drools
Format of drl file:
package...;
import ..;
rule "Test"
when $a:A(B(Z(s == "testvalue")))
then
$a.setSomething();
update($a);
end
I wanted to know if this (accessing fields in embedded/child object) is
feasible with Drools.
I get an error saying "UNable to compile myfile.drl when i try to fo this.
Could some one look into this issue and let me know the reason for this ?
Thanks
-D
15 years, 8 months
AgendaFilter for StatelessKnowledgeSession
by Michal Bali
Hi,
1) How can an org.drools.runtime.rule.AgendaFilter be set for a
StatelessKnowledgeSession? Is this not supported?
2)Just a question. StatelessSessionResult had a iterateObjects(ObjectFilter
objectfilter) method. This method is not
in StatelessKnowledgeSessionResults. Is this no longer supported ?
Thanking you in advance.
Best Regards,
Michal
15 years, 8 months
Split, mvel
by Femke De Backere
Hi,
I encountered the following error, trying to insert a Split node in my
ruleflow.
[8,0]: [ERR 103] Line 8:0 no viable alternative at input 'testType' in
rule "RuleFlow-Split-masterproef.ruleflows.sedation-4-9"
[16,5]: [ERR 103] Line 16:5 no viable alternative at input 'testType'
in rule "RuleFlow-Split-masterproef.ruleflows.sedation-4-5"
java.lang.IllegalArgumentException: Could not parse knowledge.
at
masterproef
.rulerunner.RuleFlowRunner.createKnowledgeBase(RuleFlowRunner.java:120)
at
masterproef
.rulerunner.RuleFlowRunner.createWorkingMemory(RuleFlowRunner.java:94)
at masterproef.rulerunner.RuleFlowRunner.<init>(RuleFlowRunner.java:81)
at masterproef.rulerunner.RuleFlowRunner.main(RuleFlowRunner.java:72)
The split node contains the folowing code:
Patient( testType : type )
not (testType == 'Korte sedatie')
My Patient-class contains a methode getType().
Does anyone know how I can solve the error?
Thx!
Femke
15 years, 8 months
drools-core.jar
by Salem, Hesham (EXP)
Where do I find drools-core.jar
Hesham Salem
Lockheed Martin UK Limited
Simulation Training and Support
Tel: +44(0) 1252 553408
Fax: +44(0) 1252 553341
2nd Floor Chester House, Farnborough Aerospace Centre
Farnborough, Hants, GU14 6TQ, UK
Email: hesham.salem(a)lmco.com
15 years, 8 months
Agenda events in a Stateless session
by David Boaz
Hi all,
Im developing using drools version 5.0.0.M5. My application uses a stateless
session. I tried to assign an AgendaEventListener to the session, but failed
with a NPE.
This is my code structure:
KnowledgeBase kb =...;
StatelessKnowledgeSession session = kb.newStatelessKnowledgeSession();
session.getAgendaEventListeners().add(new DebugAgendaEventListener());
==>NPE!
java.lang.NullPointerException
at
org.drools.impl.StatelessKnowledgeSessionImpl.getAgendaEventListeners(StatelessKnowledgeSessionImpl.java:123)
Am I doing something wrong, or is it an error in drools?
Thanks, David
--
View this message in context: http://www.nabble.com/Agenda-events-in-a-Stateless-session-tp22305709p223...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 8 months
Creating objects in WHEN clause
by David Boaz
In my application, we often compare the fact's field values against a known
object. For example:
WHEN person(height> new Quantity(2, "m")) // the height is greater than 2
meters.
will DROOLS create a "singleton" Quantity object, or will it create one
object for each fact evaluation?
We consider using anoter approach, using GLOBALS. Then, the Quantity object
will be created applicatively, and passed by the API to the engine.
something like:
GLOBAL Quantity 2meters
WHEN person(height > 2meters)
But this approach is combersom, because the rule author has to define part
of the information in the calling application, and part in the rule.
Do you have a good practice how to handle these situations?
Thanks, David
--
View this message in context: http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 8 months
Smooks and Drools Pipeline
by Dave Macpherson
Hey guys (Drools newbie here)
I'm *attempting* to use the Drools/Smooks pipeline functionality to insert
facts into my knowledgebase and I'm having a little trouble figuring out
exactly how to do this. I've read the API docs for the 5.0.0.M5 and looked
at the test cases but I guess I'm still not quite getting it, so I'm hoping
someone here can point me in the right direction.
I've got an XML file defined basically like this:
<submission>
<facility>
<faccode>xxx</faccode>
</facility>
<lineitem>
<acctcode>xxxx</acctcode>
<amount>999</amount>
<lineitem>
<lineitem>
<acctcode>xxxx</acctcode>
<amount>999</amount>
<lineitem>
<submission>
Within the XML file, there is 1 and only 1 "facility" node and multiple
"lineitem" nodes. I'd like to use the DroolsSmooks pipleline functionality
to use Smooks to insert 1 "facility" fact and multiple "lineitem" facts into
my knowledgbase.
The code I've written to do this is similar to the following (taken from
sample test code I've seen in the Drools source):
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
KnowledgeRuntimeCommand insertStage =
PipelineFactory.newStatefulKnowledgeSessionInsert();
insertStage.setReceiver(executeResultHandler);
Smooks smooks = new Smooks("smooks-config.xml");
Transformer transformer =
PipelineFactory.newSmooksFromSourceTransformer(smooks, "root");
transformer.setReceiver(insertStage);
Pipeline pipeline =
PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession);
pipeline.setReceiver(transformer);
ResultHandlerImpl resultHandler = new ResultHandlerImpl();
pipeline.insert(ResourceFactory.newClassPathResource("submission.xml"),
resultHandler );
While stepping through the above code, the last line returns an NPE. I've
tried playing with the "Transformer transformer - PipeLineFactory." line,
substituting "root" for something else and it goes into an infinite loop.
What is the purpose of the "root" value being set in this line?
Can anyone tell me if I'm even on the right track here, or am I
misunderstanding what the Smooks data loader can do for me?
Regards,
Dave
15 years, 8 months
java.lang.NoClassDefFoundError: org/drools/spi/Consequence
by Ojwang Wilson O
All,
I am getting the error below while passing DroolsAnt build pkg as a
property to RuleAgent. I am using Java 6 update 12.
===================
2009-03-02 16:48:59,363 Stdout ERROR callout.err - RuleAgent(default)
INFO (Mon Mar 02 16:48:59 CST 2009): Configuring package provider :
FileScanner scanning: /home/nxuser/proxy/resource/iaoc/rules/Rules.pkg
java.lang.NoClassDefFoundError: org/drools/spi/Consequence
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at
org.drools.rule.PackageCompilationData$PackageClassLoader.fastFindClass(PackageCompilationData.java:333)
at
org.drools.rule.PackageCompilationData$PackageClassLoader.loadClass(PackageCompilationData.java:353)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at
org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:79)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
==================
Regards
Wilson
15 years, 8 months
query support in Drools 5
by Michal Bali
Hi,
Is there a way to get the QueryResults from a StatefulKnowledgeSession in
Drools 5.0 ?
The old API has a getQueryResults method but I can't find it in the new API.
Thanks,
Best Regards,
Michal
15 years, 8 months