Hello,
I was pulled away from my Drools learning
and now I am back. I must have missed the response to my previous inquiry. Is
there anyone that has experienced the scenario described below?
Regards,
Daren
From:
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Daren Chylinski
Sent: Thursday, August 02, 2007
11:22 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools 4.0
StateExampleWithDynamicRules Question
Hello,
I am a new Drools user working my way through the
examples. To test my understanding of how the rules work, I modified the
StateExampleUsingSalience.drl file used in the StateExampleWithDynamicRules
example. The result of my change conflicted with my understanding
of how the rules should work.
I made two modifications in the
StateExampleUsingSalience.drl file. The two modifications (shown below)
are the commenting out of the two lines in the RHS portion of the “B to
D” rule. My understanding of how this would affect the result
was: because the “D” State object never changes state to
“State.FINISHED” the RHS portion of the “D to E” rule
(shown below) would not execute because the first pattern in the LHS would fail
to find a State object in working memory that met the criteria of the
constraint groups defined within it.
My question is: Why does the
“D to E” rule in the StateExampleDynamicRules.drl execute
the statements in the RHS portion of the rule?
From StateExampleUsingSalience.drl: My changes in this
file are the two lines commented out in the RHS portion.
rule "B to
D"
when
State(name == "B", state == State.FINISHED
)
d : State(name == "D", state == State.NOTRUN )
then
//System.out.println(d.getName()
+ " finished" );
//d.setState(
State.FINISHED );
end
From StateExampleDynamicRules.drl: This is the rule
where I expected the RHS portion to NOT get executed because there aren’t
any State objects in working memory that have their name == “D” and
its state == State.FINISHED because the setState( State.FINISHED ) was never
executed on the “D” state object.
rule "D to
E"
when
State(name == "D", state == State.FINISHED
)
e : State(name == "E", state == State.NOTRUN )
then
System.out.println(e.getName() + " finished" );
e.setState( State.FINISHED );
end
After my modifications, the output was:
A finished
B finished
C finished
E finished
I did not expect the “E
finished” message to be printed.
Regards,
Daren
Confidentiality Notice: This e-mail message (including any attached or embedded documents) is intended for the exclusive and confidential use of the individual or entity to which this message is addressed, and unless otherwise expressly indicated, is confidential and privileged information of Rackspace Managed Hosting. Any dissemination, distribution or copying of the enclosed material is prohibited. If you receive this transmission in error, please notify us immediately by e-mail at abuse@rackspace.com, and delete the original message. Your cooperation is appreciated.