[rules-users] object creation
Anstis, Michael (M.)
manstis1 at ford.com
Thu Aug 21 11:00:07 EDT 2008
You could use a global as OutputObject instead of a Fact.
If you want to use properties of OutputObject in a LHS pattern you'll
need to use "from" but this is not indexed and so using the two rules
with a fact approach might give better performance in this case.
________________________________
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of thomas kukofka
Sent: 21 August 2008 15:03
To: Rules Users List
Subject: [rules-users] object creation
Hello,
I have a rule which creates an object in the consequence part
and updates this object each time teh rule is executed. So the object
has to be created only the first time.
So I always need two rules, one init rule which creates the
object if it doesn't exist yet and one if it already exists and it
should only be updated:
rule "init rule"
when
"condition"
AND
not OutputObject()
then
OutputObject oo = new OutputObject();
insert(oo);
rule "update rule"
when
"condition"
AND
oo: OutputObject()
then
#do something with the object
update(oo);
But is it really neccessary to write an extra rule only to
create the output-fact initially? Is it possible/good style to make this
in one single rule?
Appreciate your help.
Regards
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080821/722ec4b4/attachment.html
More information about the rules-users
mailing list