Sample Rules: Complex Attributes (List Of Rule Objects)

Figure 1. Complex Attributes (List Of Rule Objects)
  <Class name="Context" extends="AbstractContext" extendsRuleSet="MotivationRuleSet"
        xsi:noNamespaceSchemaLocation="http://www.curamsoftware.com/CreoleRulesSchema.xsd">
        <Attribute name="householdMembers">
           <type>
                <javaclass name="List">
                    <ruleclass name="AbstractPerson" ruleset="MotivationRuleSet">
                </javaclass>
            </type>
            <derivation>
                <readall ruleclass="Person">
            </derivation>
        </Attribute>
        .. Other attributes ..
    </Class>

   <Class name="Person" extends="AbstractPerson" extendsRuleSet="MotivationRuleSet"
   xsi:noNamespaceSchemaLocation="http://www.curamsoftware.com/CreoleRulesSchema.xsd">
     .. Attributes ..
    </Class>

The attribute householdMembers above is a complex attribute, returning a List of RuleObjects. Each of the RuleObjects in the list will result in a new datastore entity being created and appended to the Context datastore entity, provided the name of these RuleObjects is appropriate for the schema. In this case, the processing will check the schema to see if Context.Person is allowed (ie a combination of the parent RuleObject's name and this RuleObject's name), the schema does allow this so a number of Person entities will be added and appended to the Context entity. For attributes that refer to a List of RuleObjects, the name of the attribute on the parent RuleClass is not important (ie in the Context RuleClass above, the name of householdMembers attribute is ignored). The matching is based on the name of the parent RuleObject and the name of each RuleObject itself, not the name of the attribute that refers to each RuleObject on the parent RuleObject.