[rules-users] RE: questions on guvnor and drools 5.0

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jun 4 12:58:49 EDT 2009


On 6/4/09, Garner, Shawn <Garner.Shawn at principal.com> wrote:
> 2) How do you use the test scenarios with complex object structures?
>        -eg Create a fact in working memory that has another Object in it which in turn has a list of Objects in it.
>        -Seems like any Fact in working memory is assumed to only have only primitive values like Strings or numbers.
>        -We would like a more depth of objects where objects have a deep relationship to other objects at least 2-4 levels deep.

Any object that is inserted as a fact may contain references to other
objects, which, in turn, may contain references, and so on.

The main thing to consider with complex object structures is, which of
the objects should be inserted as facts. The distinction should be
made according to whether an object's properties participate in rule
patterns and whether this object will change during the (stateful)
session. If so, make it a fact.

Referring to object properties via one or more levels of dereferencing
when using them in patterns won't be possible except in inline evals
or eval patterns.

Notice that LHS patterns may be written so that additional levels of
objects are included in the reasoning, letting you access their
non-reference fields in field constraints, e.g.:

rule x
when
   $p : Person( $name : name, $f : father )
   Person( this == $f, name == "Joe" )
then
   // $name is a child of Joe
end

-W



More information about the rules-users mailing list