Sample Rules: Complex Attributes (Single Rule Object, Annotated)

Figure 1. Complex Attributes (Single Rule Object, Annotated)
<Class name="Eligibility" extends="AbstractEligibility" 
extendsRuleSet="MotivationRuleSet" 
xsi:noNamespaceSchemaLocation="http://www.curamsoftware.com/CreoleRulesSchema.xsd">
         .. Other attributes ..
        <Attribute name="annotatedAttributeElementWillBeAnnotated">
            <type>
                <ruleclass name="AnnotatedElement">
            </type>
            <derivation>
                <create ruleclass="AnnotatedElement">
            </derivation>
        </Attribute>
    </Class>

   <Class name="AnnotatedElement"
        xsi:noNamespaceSchemaLocation="http://www.curamsoftware.com/CreoleRulesSchema.xsd">
        <Annotations>
            <Motivation_Display_Element resultSchemaElement="ElementNameFromAnnotation">
        </Annotations>

        .. Attributes ..

    </Class>

AnnotatedElement has been annotated so the name used for the corresponding datastore entity will be the resultSchemaElement attribute of the annotation, ie ElementNameFromAnnotation. The processing will check the schema to see if Eligibility.ElementNameFromAnnotation is allowed (ie a combination of the parent RuleObject's name and this RuleObject's name), the schema does allow this so an ElementNameFromAnnotation entity will be added and appended to the Eligibility entity. For attributes that refer to a RuleObject, the name of the attribute on the parent RuleClass is not important (ie in the Eligibility RuleClass above, the name of annotatedAttributeElementWillBeAnnotated attribute is ignored). The matching is based on the name of the parent RuleObject and the name of the RuleObject itself, not the name of the attribute that refers to the RuleObject on the parent RuleObject. Note that if the annotation was not present, the name that would be used for the potential datastore entity would be AnnotatedElement. The schema does not allow Eligibility.AnnotatedElement and so this entity would not be created. This demonstrates that a RuleClass which is intended to be present in the results datastore must be annotated to match the expected elements in the schema.