Skip to main content
Jump to: navigation, search

Stardust/Knowledge Base/Integration/Application/MessageOperations/MessageTransformation


Purpose

Definition of the field values of a Structural Datum (OUT Data Mapping) depending on the field values of one or more Structural Data (IN Data Mapping). The dependency functions (i.e. mapping) is specified using Message Transformation Application.

Note: The Stardust model discussed in this article can be downloaded from here.

Model Description

The following model is used to implement an example of message transformation application (MessageTransformation.xpdl):

Stardust Integration Application MessageTransformation.jpg

Hereby both the structured data Product1 and Product2 are bound to a composite type "Product" containing the following fields of type String: Name, Synopsis, State, Analysis.

Configuration of Message Transformation Application

1. Open the properties of the message transformation application and select "Message Transformation" in the list on the left hand side. The message transformation overview appears divided in two parts:

Source Messages that contain all the structured data whose fields are used as a source for mapping (here:Product1). Target Messages that contain the structured data whose fields are to be determined using the mapping, i.e. message transformation application (here:Product2)

2. To add the corresponding structured data for source and target messages, use "Add Input/Add Output" buttons, select "Structured Data" as Datatype and "Product" as Structured Data:

Stardust Integration Application MessageTransformation1.jpg

3. Afterwards, the message transformation window should look as follows:

Stardust Integration Application MessageTransformation 2.jpg

4. The values of the fields of the target structured data depending on the source structured data are defined using JavaScript syntax. Select Synopsis field of Product2. Now it is possible to assign a value to this field depending on the other fields of Product1. Therefore type Product1.Synopsis in the Mapping Expression window below.

Stardust Integration Application MessageTransformation 3.jpg

Hint: The same can be achieved by drag and drop of the field ''Synopsis' of 'Product1' on the same field of 'Product2'.

Thus, the value of the of the field Synopsis of Product2 is defined to be equal to the value of the same field of Product1. Note that the expression used for the mapping of the corresponding field is given in the column Mapping of the Target Messages window.

5. In the Message Transformation dialog, assign the value of Product1.Analysis to the same field of Product2.

6. By selecting Product1 in the Source Message section and dragging it on the field Name of the Product2 on the right hand side the field Name is automatically mapped as the concatenation of all fields of Product1.

Hint: The same can be achieved by selecting not the structured datum but all its fields and dragging the selection on the 
Name field.

7. It is also possible to use functions and variables to define the mapping that is more complex. Select the field State of Product2. Then, check the Advanced Mapping box in the Mapping Expression window. Now it is possible to enter JavaScript code that defines the field value. For example, enter the following code:

function addString(arg) {
	return "_" + arg;
}
var testNumber = 1;
for (var i=0; i<3; i++) {
	testNumber = testNumber*10+i;
}
Product2.State = Product1.State + addString(Product1.Analysis) + addString(testNumber.toString());

Note that the expression "Product2.State=" visible below the Advanced Mapping checkbox in Step 4 has disappeared after the Advanced Mapping checkbox was checked. Therefore, the closing line of the code should contain the assignment of the value to the correspondent field, i.e. start with the expression "Product2.State =".

8. The compete mapping should look as follows:

Stardust Integration Application MessageTransformation 5.jpg

Copyright © Eclipse Foundation, Inc. All Rights Reserved.