Relationship and naming annotations

Add annotations to define relationships to entities and events, or to specify a business name for an attribute.

In the complex types that describe your entities and events, you can specify relationships to other types. You can also specify a business name for an element.

To define relationships to other entity or event types, or to specify a business name for an attribute, you can add either or both of the following annotations to your XML schema. You must add the annotation inside an element that is contained in a complex type.

<annotation>
 <appinfo source="http://www.ibm.com/ia/Annotation">
   <businessName name="scan"/>
   <businessType type="org.example.bagscan.Scan"/> 
 </appinfo>
</annotation>

The business name specifies the name to create in the BOM, and it is verbalized to be used in the rules. The business name must follow the JavaBeans naming convention.

The business type specifies the relationship to another type. In the business type, you write the fully qualified name of the BOM class:
  • If the relationship refers to a type that is defined in the XSD, the name of the BOM class is based on the namespace. For example, if the namespace is http://www.example.org/bagscan, the package name of the BOM class is org.example.bagscan.
  • If the relationship refers to a type that exists in the BOM, you add the fully qualified name of the BOM class.

Example of a business name

In the following example, the element is named ticketId, and the specified business name is "ticket".

<complexType name="Ticket">
[...]
<element name="ticketId" type="string">
 <annotation>
  <appinfo source="http://www.ibm.com/ia/Annotation">
   <businessName name="ticket"/>
   <businessType type="org.example.bagscan.Ticket"/> 
  </appinfo>
 </annotation>
</element> 

Example of a relationship

In the following example, the airport open event has a relationship to the airport entity.

<element name="AirportOpenEvent" type="m:AirportOpenEvent"/>
<complexType name="AirportOpenEvent">
 <annotation>
  <appinfo source="http://www.ibm.com/ia/Annotation">
   <event elementName="AirportOpenEvent"/>
  </appinfo>
 </annotation>
 <sequence>
  <element name="airport" type="string">
   <annotation> 
    <appinfo source="http://www.ibm.com/ia/Annotation">
     <businessType type="sample.acmeairlines.model.Airport"/>
    </appinfo>
   </annotation>
  </element>
  <element name="eventDatetime" type="dateTime">
   <annotation>
    <appinfo source="http://www.ibm.com/ia/Annotation">
     <timestamp/>
    </appinfo>
   </annotation>
  </element>
 </sequence>
</complexType>