IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Enterprise Service Bus programming > Data Transformation > Business Object Map and Mapping mediation primitives

Example scenarios

In this scenario, a fictitious company, Personal Holidays have a holiday booking system.

In order for customers to book flights with Personal Holidays, the flight availability must be checked against a fictitious airline company, My Airways, flight schedule. The interface for the Personal Holidays booking system is generic and not airline specific. The Personal Holidays booking system represents information differently to the My Airways booking system. The differences are shown in the following XML.

The Personal Holidays flight booking system message that represents a flight search:

<flightBooking>
	<departFrom>London</departFrom>
	<goingTo>Paris</goingTo>
	<departDate>29/10/2010</departDate>
	<returnDate>12/11/2010</returnDate>
	<adults>2</adults>
	<children>0</children>
</flightBooking>

The My Airways flight booking system message that represents a flight search:

<flightBooking>
	<countryOfDeparture>UK</countryOfDeparture>
	<from>London</from>
	<to>Paris</to>
	<depart>29/10/2010</depart>
	<return>12/11/2010</return>
	<flightClass>2</flightClass>
	<adult>2</adult>
	<children>0</children>
</flightBooking>


Mapping message structures

To implement the basic request, Personal Holidays are required to map their message structure with the My Airways message structure. To map these interfaces, they must use a data transformation. The transformation takes place on the body of the message within a simple mediation flow component. The integration developer uses a Mapping mediation primitive to transform the body of the message. This is shown in Figure 1 .

Figure 1. Message Structure mapping using a Mapping mediation primitive within a mediation flow component

When a Mapping mediation primitive is created, a mapping file associated with the primitive is created or selected that describes the transformation between the source and the target business objects. This is shown in Figure 2 . The image also shows the way the values in the source message are used to populate the target message.

Figure 2. Message Structure mapping within Integration Designer


Service enrichment

Personal Holidays must determine the country of departure dynamically from within the mediation module.

The countryOfDeparture field does not exist within the Personal Holidays flight booking message structure. A Database Lookup mediation primitive is used to establish the country of departure in any given instance. The Database Lookup mediation primitive populates the country of departure into the transient context. In this example, the company use a BO Mapper mediation primitive to transform the transient context and body into the new required message structure. This is shown in Figure 3.

Figure 3. Service enrichment using a BO mapper within a mediation flow component


Data field level

In addition to changing the structure of a message, data transformation often requires changing the content of individual values.

For example, it is common for date and time formats to differ between applications, or for string values to carry composed values that need to be extracted and separated. Within the mapping transformation primitives, you can operate on data values using a variety of built-in functions or calling out to custom code in a number of forms.

As an example, the Personal Holidays booking request includes a departure date of the form, yyyy-mm-dd (2010-11-10). My Airways expects the same date value to be represented in the form, dd-mm-yyyy (10-11-2010). In an XML map, the Format date function can apply a chosen pattern to a date field. This is shown in Figure 4 and Figure 5.

Figure 4. Format date function

In the Properties view, you should select the intended output format:

Figure 5. The configuration of the format date transformation

The value that is input to the function is the source field for the mapping. The transformed value is set into the output field. The transformation is performed in the XML domain, (inside the XSLT processor). The element value appears in XML. By contrast, operations that take place inside the BO Maps are performed in the SDO domain, that is using the Java business object representation. To perform an equivalent transformation in a BO Map, we would use a custom Java snippet, which would be passed to the data field as a java.util.Date object. This is shown in Figure 6 and Figure 7.

Figure 6. Custom transformation in a BO map

The Java code that implements the custom mapping is written in the Properties view:

Figure 7. Java code in the Properties view

In Figure 7 the java.text.DateFormat class is used to format the incoming Date object to produce a formatted string using the built in SimpleDateFormat.SHORT format. This corresponds to dd-mm-yyyy or yyyy-mm-dd. By using a Java snippet, you can access the source and target data fields as local variables. These are described in the generated comments produced by the editor. From a custom Java snippet, it is also possible to invoke code from other Java classes that are contained in the module or in an associated library project.

Business Object Map and Mapping mediation primitives