Declaring ownership relations on BOM classes to simplify rules
You can declare an ownership relation between BOM classes to simplify rules that refer to these elements.
About this task
In the BOM editor, you use the ownershipRelation property to declare an ownership relation between elements. You can then access these elements in the rules through this relation.
Procedure
Example
In the following example, the
Policy class contains vehicles members, which
are defined in the Vehicle class. The following rule
contains a definition that explicitly defines a relation between these elements, and instances of
the vehicle object are accessed by using this relation
in the condition part of the
rule:definitions
set 'the policy' to a policy;
set 'the vehicle' to a vehicle in the vehicles of 'the policy';
if
the age of 'the vehicle' is at least 5
then
print "This vehicle is too old." ;You
can simplify this rule by declaring that the
Vehicle
class is owned by the Policy class directly in the BOM
elements. To do so, you add the ownershipRelation property to the custom
properties of the Vehicle class, and set its value to
com.ibm.rules.Policy.vehicles. You can now write a simplified version of the
rule:definitions
set 'the vehicle' to a vehicle;
if
the age of 'the vehicle' is at least 5
then
print "This vehicle is too old." ;Here
the definition clause does not contain an in or from construct, and the instances are accessed through the
ownership relation. The rule is evaluated for each vehicle in the list of vehicles of each policy
that is available in the working memory. When no ownership relation is defined, and no in or from
constructs are used, rules can only access instances that are directly available in the working
memory.
the
vehicle:
if
the age of the vehicle is at least 5
then
print "This vehicle is too old." ;