Data type mappings
The Connector SDK addresses a common requirement in connector implementations by mapping simple types in objects that the target service exposes (represented in XSD by a simpleType element) to data types.
Data type mapping techniques
The Connector SDK provides the following techniques to specify data type mappings:
- Connector descriptor — In the connector descriptor file, the
profileTypeMappingselement specifies default data type mappings for new operations. - Object definition schema annotations — You can specify mappings for individual operations in the object definition schema by applying annotations to elements, attributes, or
simpleTypedefinitions. When specified in this way, these mappings override defaults specified in the connector descriptor.
The default mapping format for date, time, and datetime simple types is the date/time format — yyyy-MM-dd'T'HH:mm:ss.SSSZZ.
Element annotation example
The following element annotation example maps a string field to a number field with the format \#.00:
<xs:element name="numberFromString" type="xs:string">
<xs:annotation>
<xs:documentation>Number with format #.00</xs:documentation>
<xs:appinfo>
<dataFormat dataType="number" format="#.00" xmlns="http://www.boomi.com/connector/annotation" />
</xs:appinfo>
</xs:annotation>
</xs:element>
Attribute annotation example
The following attribute annotation example maps an integer field to a string field:
<xs:attribute name="numberAsString" type="xs:integer">
<xs:annotation>
<xs:documentation>String</xs:documentation>
<xs:appinfo>
<dataFormat dataType="character" xmlns="http://www.boomi.com/connector/annotation" />
</xs:appinfo>
</xs:annotation>
</xs:attribute>
SimpleType annotation example
The following simpleType annotation example maps a string field to a date field with the format yyyy:
<xs:simpleType name="YearFromString">
<xs:annotation>
<xs:documentation>Date with format yyyy</xs:documentation>
<xs:appinfo>
<dataFormat dataType="datetime" format="yyyy" xmlns="http://www.boomi.com/connector/annotation" />
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string" />
</xs:simpleType>
JSON implementation
The representation of JSON schema annotations for data type mapping overrides typically corresponds to the XML representation:
-
The JSON
boomi_dataFormatannotation property corresponds to the XMLdataFormatelement. -
boomi_dataFormatproperties and values for specifying target data types and formats are identical to the XMLdataFormatelement’s attributes and values.
JSON sample
The following JSON represents the Element annotation example in this topic:
"numberFromString" : {
"type": "string",
"annotations": {
"documentation" : "Number with format #.00",
"boomi_dataFormat": { "dataType": "number", "format": "#.00" }
}
}
The JSON implementation in Integration supports only the JSON schema primitive data types (integer, number, string, boolean, null, object, and array) as field properties. Date and/or time fields are typically defined as strings in supported JSON field definitions.