drools 6.0.0 examples?
by gallaxhar
I installed eclipse+drools plugin+drools 6.0.0 runtime, now I'm looking for
the drools-examples zip file
this page
<http://docs.jboss.org/drools/release/6.0.0.Final/drools-docs/html/ch19.html>
says,
> Make sure the Drools Eclipse plugin is installed, which needs the
> Graphical Editing Framework (GEF) dependency installed first. Then
> download and extract the drools-examples zip file, which includes an
> already created Eclipse project. Import that project into a new Eclipse
> workspace. The rules all have example classes that execute the rules. If
> you want to try the examples in another project (or another IDE) then you
> will need to set up the dependencies by hand, of course. Many, but not all
> of the examples are documented below, enjoy!
>
> Some examples require Java 1.6 to run.
However I could not find instruction as to how to get this file.
--
View this message in context: http://drools.46999.n3.nabble.com/drools-6-0-0-examples-tp4027976.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 9 months
Marshalling/Unmarshalling of KieSession
by IK81
Dear all,
I've to questions concerning the marshalling and unmarshalling of
KieSessions.
First, is there any detailed documentation on the
ObjectMarshallingStrategy interface? I am quite confused about the
purpose of the write and read methods in the interface. In my
implementation they are never called. Are they deprecated or under which
circumstances are they called by the implementation?
My second question is about the relationship of the KieSession, KieBase
and the KieContainer in case of marshalling/unmarshalling. Assume that I
create a KieSession based on a KieBase that is created from a
KieContainer based on a release X. When marshalling this session, is
there any information marshalled about which release this session is
based upon? I am asking since when I unmarshall the session I want to
ensure to initialize the unmarshaller based on a KieBase with the same
release X as the marshalled version of the session. Do I have to store
this information out of band or what's the recommended way to implement
this?
Thanks,
Ingo
10 years, 9 months
Re: [rules-users] Where is my understanding of Drools global variables wrong?
by milen igrachev
Hello I tried what you proposed, it didn't do the trick. Then i reread the documentation and discovered:
"Globals are not designed to share data between rules and they should never be used for that purpose.
Rules always reason and react to the working memory state, so if you want to pass data from rule to rule,
assert the data as facts into the working memory."
Sadly, I was trying to do just that...
I am sorry for the question in first place.
I want to ask something (just to be sure).
If I want to share data between rules (in my case transitional calculation results, that are missing in my model), the only way to do so is to pass them into some temporary facts?
Thanks again
Best Regards,
Milen
-------- Оригинално писмо --------
От: Wolfgang Laun wolfgang.laun(a)gmail.com
Относно: Re: [rules-users] Where is my understanding of Drools global
variables wrong?
До: Rules Users List
Изпратено на: Понеделник, 2014, Февруари 3 18:09:26 EET
The typical misunderstanding is that a global is a "variable" in the
usual sense of the word. It is not.
When you set a global, you store an object in a map, using the
global's name as a key. Using a global in DRL code perfidiously and
conveniently hides the way the global is made available to the code in
a rule when you use the global's name just like any other variable:
You write the global's name, but you use a local copy.
If you intend to change the global existence of a global you'll have
to use the API that's used to set up a global in the first place: get
the session object, call setGlobal...
Cheers
Wolfgang
On 03/02/2014, milen igrachev igrachev(a)abv.bg > wrote:
> Hello, for the first time I have the need to define a global variables in a
> DRL file, and from what it seems from the documentation it shall be a
> variable visible to all my rules in the
> DRL file. However I don't see what I do wrong, but the modifications made by
> one rule are not visible to the others. Here is illustration of what I
> have:
>
> [Fact model code]
> public class TestPOJO { private int fieldOne; private String
> fieldTwo; public int getFieldOne() {...} public void
> setFieldOne(int fieldOne) {...} public String getFieldTwo() {...}
> public void setFieldTwo(String fieldTwo) {...} }
> [DRL rule code]
> global java.lang.Double myGlobal; rule "Your First Rule" salience 2
>
> when
>
>
>
> TestPOJO(fieldOne > 10)
>
> then
>
>
>
> System.out.println("This is rule #1");
>
>
>
> System.out.println(myGlobal);
>
>
>
> myGlobal = 0.03; end rule "Your Second Rule" salience 1
>
> when
>
>
>
> TestPOJO(fieldTwo == "true")
>
> then
>
>
>
> System.out.println("This is rule #2");
>
>
>
> System.out.println(myGlobal); end
> [Call to Drools]
> TestPOJO myTestFact = new TestPOJO(); myTestFact.setFieldOne(15);
> myTestFact.setFieldTwo("true");
> KieServices ks = KieServices.Factory.get(); KieContainer kContainer =
> ks.getKieClasspathContainer(); KieSession kSession =
> kContainer.newKieSession("ksession-rules");
>
> kSession.insert(myTestFact); kSession.fireAllRules();
> kSession.dispose();
> [Output]
> This is rule #1 null This is rule #2 null
>
>
> [What I expect to have as output] This is rule #1 null This is rule #2
> 0.03
> I used the salience to set rule order to be sure that rule one is executed
> before rule two, but my global value is never updated.
> Can you please tell me where I do wrong? Can my expectations be met somehow,
> I need such type of internal rule variables to calculate temporary
> values and pass them between rules?
>
> Thank you!!!
>
> Best Regards, Milen
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
10 years, 9 months
5.6.0.CR1 gives a NullPointerException in after evaluator
by abr
Hi everyone,
I tried to switch from 5.5.0.Final to 5.6.0.CR1 and got a null pointer
exception in the evaluation of the after evaluator.
(Exact method is:
/org.drools.base.evaluators.AfterEvaluatorDefinition.AfterEvaluator.evaluate(InternalWorkingMemory,
InternalReadAccessor, InternalFactHandle, InternalReadAccessor,
InternalFactHandle)/ )
When debugging, the exception occurs at the very first line of the method,
in:
/ if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) ||
extractor2.isNullValue( workingMemory, handle2.getObject() ) ) {
return false;
}
/
The cause of the exception is that handle1 is null.
The rule where the exception occurs looks like:
/ MyFact(
fromdate before[ 0d ] $min,
( todate == null || todate after[ 0d ] $max ) )
/
When the exception occurs, /MyFact.fromdate/ is not null, /$min/ is not
null, /MyFact.todate/ is null, /$max/ is not null.
In AfterEvaluator.evaluate : /extractor1/ refers to /MyFact.todate/,
/extractor2/ refers to /$max/, /handle1/ is null, /handle2/ refers to the
fact including the attribute to which /$max/ variable is bound to.
Of course, this worked fine in 5.5.0.Final.
I couldn't test this out in Drools 6.0.0.CR5 because I have dependencies to
drools-spring JAR that does not exist anymore in 6.0.0.CR5.
Is it simple to fix this problem?
Thanks in advance.
Best,
Alexis
--
View this message in context: http://drools.46999.n3.nabble.com/5-6-0-CR1-gives-a-NullPointerException-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 9 months
Where is my understanding of Drools global variables wrong?
by milen igrachev
Hello, for the first time I have the need to define a global variables in a DRL file, and from what it seems from the documentation it shall be a variable visible to all my rules in the
DRL file. However I don't see what I do wrong, but the modifications made by one rule are not visible to the others. Here is illustration of what I have:
[Fact model code]
public class TestPOJO { private int fieldOne; private String fieldTwo; public int getFieldOne() {...} public void setFieldOne(int fieldOne) {...} public String getFieldTwo() {...} public void setFieldTwo(String fieldTwo) {...} }
[DRL rule code]
global java.lang.Double myGlobal; rule "Your First Rule" salience 2
when
TestPOJO(fieldOne > 10)
then
System.out.println("This is rule #1");
System.out.println(myGlobal);
myGlobal = 0.03; end rule "Your Second Rule" salience 1
when
TestPOJO(fieldTwo == "true")
then
System.out.println("This is rule #2");
System.out.println(myGlobal); end
[Call to Drools]
TestPOJO myTestFact = new TestPOJO(); myTestFact.setFieldOne(15); myTestFact.setFieldTwo("true");
KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession("ksession-rules");
kSession.insert(myTestFact); kSession.fireAllRules(); kSession.dispose();
[Output]
This is rule #1 null This is rule #2 null
[What I expect to have as output] This is rule #1 null This is rule #2 0.03
I used the salience to set rule order to be sure that rule one is executed before rule two, but my global value is never updated.
Can you please tell me where I do wrong? Can my expectations be met somehow, I need such type of internal rule variables to calculate temporary
values and pass them between rules?
Thank you!!!
Best Regards, Milen
10 years, 9 months