DataMapperExpressionConverterFormat definition examples

This topic provides a description and example definitions of the DataMapperExpressionConverterFormat formatter.

The DataMapperExpressionConverterFormat class extends the DataMapperConverterFormat class to support mapping from expression manipulation to context value.

The expression is a JavaScript snippet which supports multiple data types such as constants, context value, global function and expression, also supported nested expressions.

The DataMapperExpressionConverterFormat definition contains a new attribute, "fromExpression”, whose value is an expression. WebSphere® Multichannel Bank Transformation Toolkit contains a new JavaScript evaluation engine to execute the expression and return a result. If the result is a WebSphere Multichannel Bank Transformation Toolkit data element, then it will be mapped to another data element which defined in the “to” attribute. If the result is a pure Java object, then it will be mapped to a data field which defined in the “to” attribute.

A DataMapperExpressionConverterFormat expression can be derived from the mapping tooling that is included in the Transaction Editor. In the expression, escape characters might be used that cannot be easily understood by end users; for example, a dollar sign ($) might be used instead of a dot (.) when specifying data paths so that “preson$address$street” is used instead of “preson.address.street” in expressions. A dot (.) is used in expressions for function separating character such as functs_BTTGlobalFunctions.concat(param1,param2). It is strongly recommended that you create or modify expressions by using WebSphere Multichannel Bank Transformation Toolkit tooling instead of by manually creating or modifying the expressions.

The DataMapperExpressionConverterFormat class supports mapping with wildcard data elements, such as iCollA.*.fieldA and iCollA.*.iCollB.*.iCollC.*.FieldA. The leaf element can be field, typed data, kColl or iColl. They also can be used with Global functions and Operators. But they must meet the following requirements strictly:
  1. Have the same deepness path.
  2. Have the same leaf element type.

The DataMapperExpressionConverterFormat class can also be extended to support mapping between two contexts and to support mapping between a context and a keyed collection. In such cases, the mapping elements of the source and target should have same name.

Mapping from a manipulated value to a data field

Mapping from a manipulated data element to another data element

Mapping between contexts

This example shows how to map between two contexts. In the formatter definition shown above, the “username” and “age” fields are mapped because the names of the field elements are the same in the source context and the target context. Data elements that have different names between the source context and the target context are not mapped.

Mapping between a context and a keyed collection

This example shows how to map the root keyed collection of the source context to the inner keyed collection of the target context.

Mapping between contexts with an inner indexed collection and a keyed collection

A keyed collection from a source context:
<kColl id="CustomerInfo" dynamic="true">
  <field id="name"  />
  <field id="age" />
<kColl id="Account" >
	  <field id="accountNumber"  />
	  <iColl id="SubAccountsList" >
	  	 <kColl >
				<field id="acctID" />
			    <field id="balance" />
 </kColl>
</iColl>
 </kColl>
</kColl>
A keyed collection from a target context:
<kColl id="UserInfo" dynamic="true">
  <field id="name"  />
  <field id="address" />
<kColl id="Account" >
	  <field id="accountNumber"  />
	  <iColl id="SubAccountsList" >
	  	 <kColl >
				<field id="acctID" />
			    <field id="balance" />
 </kColl>
</iColl>
 </kColl>
</kColl>
In Figure 1, the whole context is mapped to the target context, including both the inner keyed collection and the inner indexed collection.
Figure 1. Mapper definition 1
<fmtDef id="mappingConditionGetRowByIndex">
	<mapperConverterExpression>
		<map from="*"  to="*"/>
	</mapperConverterExpression>
</fmtDef>
In Figure 2, only the “SubAccountsList” inner indexed collection is mapped.
Figure 2. Mapper definition 2
<fmtDef id="mappingConditionGetRowByIndex">
	<mapperConverterExpression>
		<map from="Account.SubAccountsList" 
 to="Account.SubAccountsList"/>
	</mapperConverterExpression>
</fmtDef>
For more information on data mapper formatters, refer to DataMapperConverterFormat definition example.