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 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.
<fmtDef id="mappingFmt31"> <mapperConverterExpression> <map fromExpression="accountList$0$name" to="fisherMan.name" /> <map fromExpression="byteField1 + byteField2" to="byteField" /> </mapperConverterExpression> </fmtDef>
<iColl id="OperL1IColl" size="0"> <kColl id="OperL1Kcoll"> <kColl id="OperatorTypedDataRec"> <data id="StringFieldResult" refType="String" /> </kColl> </kColl> </iColl> <fmtDef id="testConstantToMultiLevelICollFmt"> <mapperConverterExpression> <map fromExpression="'aaa'" to="OperL1IColl.*.OperatorTypedDataRec.StringFieldResult"/> </mapperConverterExpression> </fmtDef>
<fmtDef id="mappingConditionGetRowByIndex"> <mapperConverterExpression> <map fromExpression="functs_BTTGlobalFunctions.getRowByIndex(iColl01,2)" to="iCollField01" /> </mapperConverterExpression> </fmtDef>
<iColl id="SrcOneLvlIColl" size="0"> <kColl id="SrcTypedDataRec"> <data id="SrcIntegerField" refType="Integer" /> </kColl> </iColl> <iColl id="DestOneLvlIColl" size="0"> <kColl id="TypedDataRec"> <data id="IntegerField" refType="Integer" /> </kColl> </iColl>
<fmtDef id="FuncOneLevelICollConstantFmt"> <mapperConverterExpression> <map fromExpression="functs_BTTCustomTestFunction.sum(SrcOneLvlIColl$*$SrcIntegerField,5)" to="DestOneLvlIColl.*.IntegerField" /> </mapperConverterExpression> </fmtDef>
<iColl id="OperL1IColl" size="0"> <kColl id="OperL1Kcoll"> <iColl id="OperL2IColl" size="0"> <kColl id="OperL2Kcoll"> <kColl id="OperatorTypedDataRec"> <data id="StringFieldOne" refType="String" /> <data id="StringFieldTwo" refType="String" /> </kColl> </kColl> </iColl> </kColl> </iColl> <iColl id="OperL1IColl" size="0"> <kColl id="OperL1Kcoll"> <iColl id="OperL2IColl" size="0"> <kColl id="OperL2Kcoll"> <kColl id="OperatorTypedDataRec"> <data id="StringFieldResult" refType="String" /> </kColl> </kColl> </iColl> </kColl> </iColl>
<fmtDef id="OperatorMultiLevelICollFmt"> <mapperConverterExpression> <map fromExpression="OperL1IColl$*$OperL2IColl$*$OperatorTypedDataRec$StringFieldOne + OperL1IColl$*$OperL2IColl$*$OperatorTypedDataRec$StringFieldTwo" to="OperL1IColl.*.OperL2IColl.*.OperatorTypedDataRec.StringFieldResult" /> </mapperConverterExpression> </fmtDef>
<iColl id="S7PL1I" size="0"> <kColl id="S7Person" dynamic="false"> <data id="age" refType="Byte" /> </kColl> </iColl> <kColl id="groupedData" dynamic="false"> <data id="avgAge" refType="Integer" /> </kColl>
<fmtDef id="SingleLevelS7PersonStatiscalDataFmt"> <mapperConverterExpression> <map fromExpression="functs_BTTS7PersonFunctions.averageAge(S7PL1I$*$age)" to="groupedData.avgAge" /> </mapperConverterExpression> </fmtDef>
<kColl id="CustomerInfo" dynamic="true"> <field id="username" /> <field id="age" /> <field id="address" /> </kColl>
<kColl id="CustData" dynamic="true"> <field id="username" /> <field id="age" /> <field id="gender" /> </kColl>
<fmtDef id="mappingConditionGetRowByIndex"> <mapperConverterExpression> <map from="*" to="*"/> </mapperConverterExpression> </fmtDef>
<kColl id="AccountInfo" dynamic="true"> <field id="accountNumber" /> <field id="balance" /> </kColl>
<kColl id="CustomerInfo" dynamic="true"> <field id="name" /> <field id="age" /> <field id="address" /> <kColl id="Account" > <field id="accountNumber" /> <field id="balance" /> </kColl> </kColl>
<fmtDef id="mappingConditionGetRowByIndex"> <mapperConverterExpression> <map from="*" to="Account"/> </mapperConverterExpression> </fmtDef>
<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>