Thanks for the response. This clears things up greatly. I
guess what I am struggling with at this point is the best approach to applying
the rules. I looked over the Conway example I began to use the DSL editor. This
seems to be a "best approach" to defining the rules but still left me puzzled
about the implementation. Should I create a wrapper class around my pojo's that
I can implement business methods on to make applying the rules easier? Or should
I load all the objects into working memory as you stated to represent a
"relational model"? I can see pros and cons for both approaches and I can't seem
to settle on which one would be best.
Chris,
There is quite a few
messages in the list archives about the "issues" of using nested objects.
Best way is always to work with a "relational model" and assert
all your objects to the working memory. One example would be:
rule
R1
when
$o : Order( requestStatus ==
RequestStatus.ACCEPT )
Message( state ==
MessageState.RELEASING, order == $o )
then
// do
something
end
Having said that, if you don't think
it is justifiable to assert all objects into working memory because of just a
few rules, you can also use the "from" CE:
rule
R2
when
$m : Message( state == MessageState.RELEASING
)
Order( requestStatus == RequestStatus.ACCEPT ) from
$m.getOrder()
then
// do
something
end
Finally, version 4.0 final will allow
you to write the rule the way you wrote:
rule
R3
when
$m : Message( state == MessageState.RELEASING,
order.requestStatus == RequestStatus.ACCEPT )
then
// do something
end
But it is important to note that the above will automatically generate an
embedded eval() for you, that is exactly the same as doing:
rule
R4
when
$m : Message( state == MessageState.RELEASING,
eval( order.getRequestStatus() == RequestStatus.ACCEPT ) )
then
// do something
end
And eval result needs to be constant over time.
BTW,
syntaxes used in R1, R2 and R4 are already supported in MR2/trunk. Syntax used
in R3 above will be available in Drools 4.0 final release.
[]s
Edson
2007/6/6, Chris Mathrusse <christopher.mathrusse@sybase.com>:
I'm
new to the rules syntax and a bit frustrated with trying to learn it.
I've
reviewed the docs but keep running into the same issue. I have a
parent object,
Message, that contains an Order. An Order has a status that
I want to test. So
looking at the documentation and taking my best guess
I've created a rule as
follows:
rule "Order not
Accepted"
when
$m : Message( state ==
MessageState.RELEASING, order.requestStatus ==
RequestStatus.ACCEPT
)
then
...
end
The problem is that when I start my
application I get a compilation error.
Caused
by:
org.drools.rule.InvalidRulePackage: [54,54]: unknown:54:54 mismatched
token:
[@423,1899:1899='.',<69>,54:54]; expecting type
RIGHT_PAREN[54,94]:
unknown:54:94 mismatched token:
[@433,1939:1939=')',<37>,54:94]; expecting
type
LEFT_PAREN
at
org.drools.rule.Package.checkValidity (Package.java:368)
So what am
I missing? I know it has to be something simple with my understanding
of
the syntax.
Thanks for the
help...
_______________________________________________
rules-users
mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
Software Engineer
- JBoss Rules Core Developer
Office: +55 11
3529-6000
Mobile: +55 11 9287-5646
JBoss, a
division of Red Hat @ www.jboss.com
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users