Hi everybody,
I followed all the topics about globals and the
fact that they are immutables.
I also understood that once we decide to reason
over globals, it's
time we no more use them and we start to use simple
WM facts.
Now...
I tell you my scenario.
I have got two globals.
A "request" global and a "reply" global. The first
one is a "Request" java instance
and the second one is a "Reply" java instance. They
belong to the Object model
I designed.
My application makes a request to the rule
engine passing it a "request" as global,
and get back a reply from it
receiving a modified "reply" global.
I use a ruleflow to execute the rules.
I think everything would be perfect and smooth if I
had not the need to reason
over the reply during the rule
session....
That's the point!
I do not just need to modify the "reply" global in
order to get the final value outside
the rule engine, but I DO need to reason
over it INSIDE the rule session.
So.... what should I do in order to reason
over the reply INSIDE AND OUTSIDE
the Rule Session?
Should I insert the "reply" global into the
WM?
Let assume I do that, what happen if I pass the
"reply" global to
a drools function which alters the
"reply"?
Imagine a rule as follows and imagine I previously
inserted the "reply" global into the WM:
----
...
global my.object.model.Reply reply
...
rule "addcriminal_2_reply"
when
$p:
Person(job=="criminal")
then
addCriminaltoReply(reply,
$p );
end
----
Will this alteration affect the corresponding
Reply() fact in the WM as well?
Now let see this other rule:
(Same, let imagine i previously inserted:
insert(reply); )
----
global my.object.model.Reply reply
rule "FullFill_replyCode"
when
$r:
Reply(code=="john.wayne") from reply
then
$r.code.name =
john;
$r.code.lastname = wayne;
end
----
If I execute this rule in a ruleflow, do i need to
"update($r)"
in order to get the modified $r value in the
next ruleflow node?
And what happens to the global??? Will it get
modified as well?
I am sure you can help me.
Bye bye.
Massi