Development tools : Transaction editor : Drawing flows in the flow editor : Setting data mappings to states or transitions : Defining data formatter
  
Defining data formatter
This section describes how to create a new data formatter and its data mappings.
One data formatter consists of at least one data mapping. Once the data formatter is created, it would be displayed in the Format editor (Format tab in the Transaction editor).
1 In the Enterprise Explorer pane, double-click the Transaction file that contains data formatter that you want to remove.
The Transaction file opens in the Transaction editor.
2 In the Transaction editor, click the Flow tab.
3 In the Flow tab, click the transition or state to which the data formatter that you want to operate with belongs.
Information on the transition or state displays in the Properties tab.
Note If the Properties tab is not open, click Window > Show View > Other > Properties to open the Properties tab.
4 In the Properties panel, choose the Mapping direction.
If you want to map output data, use Output Mapping.
If you want to map input data, use Input Mapping.
These two directions share the same process. The following steps take Input mapping as an example.
5 Select 'Simple Mapping' and click '+' button to open the Mapping editor.
This graphic is described in the surrounding text.
6 In the Mapping Source panel, use the drop-down list to specify which type the mapping source is and define the entire expression according to the selected type.
This graphic is described in the surrounding text.
There are six types, Constant, Expression, Context, Global Function, Common and Condition.
Condition: define the Condition of conditional mapping. Conditional mapping means applying specific data mappings under specific condition. See Defining Conditional mapping by data mapping for details.
Besides Condition, the following types are all used for defining Mapping source. Mapping source is divided into type data (Constant and Context) and expression (Expression, Global Function and Common). For type data mapping, there is a compatibility requirement: see Type data mapping compatibility.
Note The following steps are based on Expression editor to define Mapping expression. For more information of this editor, see Expression editor.
Constant: you could specify the Constant Type as String, Number, Boolean, Index, NLS Key or other customized types.
This graphic is described in the surrounding text.
Note Mapping editor supports not only mapping from any typed data to a constant of the same type, but also natural combinations (such as a Number Constant to any numeric typed data, such as Long, Short, and BigDecimal).
Expression: perform a arithmetical, logical or relational operation with arithmetic, comparison and boolean operands.
This graphic is described in the surrounding text.
Select one of the operators to define Expression type.
Define left and right input elements according to Expression type. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
Context: Select the data element from available contexts.
This graphic is described in the surrounding text.
In the Context list panel, use the drop-down list to select the corresponding context. For detailed information about listed items in the panel, see Mapping context list.
In the Context data panel, only the data elements that have the appropriate flag set (input/output/both) are shown. Specifically, when mapping to a context, only the elements with the input flag set appear; when mapping from a context, only the elements with the output flag set are shown. Therefore, only output data is displayed at the Mapping Source panel and only input data is displayed at the Mapping Target panel. For data attributes of input/output, see Data element external definitions.
Global function: common data manipulation, such as compare and concatenate provided by the toolkit.
This graphic is described in the surrounding text.
Steps
Expand the functions tree to select the Global function. You could use the search bar to find the Global function you want and use Description label to know better about the function. See Global functions for detailed information about the function.
Define each parameter. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
Common: common condition which has been defined by users in Condition Dictionary.
This graphic is described in the surrounding text.
Steps:
Select the Common from the List panel.
Define each parameter. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
In all cases, the final expression will be shown at the bottom of the Mapping Source panel, in the Expression field. You could use that to confirm your definition.
7 In the Mapping Target panel, specify mapping target from one of the available contexts. Mapping Target only supports contexts. Thus you would refer to Select context as mapping source.
8 Click Bind in the middle of the window to bind the source and target data.
This graphic is described in the surrounding text.
Then the data mapping just defined would be displayed in the mapping table. In the mapping table, different colors of mappings stand for different meanings.
Meanings for different colors
 
Color
Meaning
black
already existing mapping
red
invalid mapping
green
updated mapping
blue
new created mapping
1 Optional: Add comments to data mapping in order to clarify its purpose or function. Comment lists as third column of the table. Click the button in the cell and input your comments.
2 You can define as many mappings as you may require in two ways. You need to make sure data mappings at the same level have different Mapping targets.
Define new data mappings by restarting from Step 6 again. Before that, there are two ways to return to the initial status of the wizard.
Press Reset Selection button.
Click on the blank area inside the mapping table.
Reference defined data formatter. Click 'Add RefFmt' button in the Control area and select the data formatter from the popup dialog.
This graphic is described in the surrounding text.
3 Click OK.
Note As long as you have not clicked OK, you could use CTRL+ z/y to undo/redo the previous operation. Once clicked OK, the data formatter would be saved into the Transaction file and can be viewed in the Format tab of the Transaction editor.
See also
Setting data mappings to states or transitions
Defining Conditional mapping by data mapping
Conditional mapping applies certain data mappings under the corresponding condition. The basic structure is like:
[Condition][Data mapping],[Condition][Data mapping]
Users need to define the Conditions and the corresponding data mappings as a set of Conditional mapping. Defining the corresponding data mapping is like defining traditional data mapping. As for defining the Condition, there are two ways: by data mapping (Mapping editor) and by mapping flow. For the other way, see Defining Conditional mapping by mapping flow.
Notes
Only typed data is supported for conditional mapping. Field type data is not supported. Runtime uses the type information to check if the data is a number type data.
At least one converter must be defined for one type in the type.xml file. Otherwise, runtime can not find the number type, which leads to the mapping error.
Procedure
1 Launch the Mapping editor and select Condition as Mapping Source. See Defining data formatter.
This graphic is described in the surrounding text.
To define conditional mapping, you need to define the Condition first. Select the Condition type and define the Condition expression.
2 Select the Conditional type as mapIf.
This graphic is described in the surrounding text.
There are three kinds of Conditional mapping, mapIf, mapElseIf and mapElse, which stands for the processing sequence. As Conditions are nested as a group and there could be multiple Condition groups with multiple nested Conditions, users should make sure every Condition group is valid:
Start with one mapIf and it should be the only one.
If needed, have multiple mapElseIf.
If needed, end with only one mapElse.
In this way, every Condition must have a mapIf. And particularly, there could be many mapIf as many Condition groups are in one formatter.
3 Select Condition type and define the entire Condition expression according to the selected type.
There are three Condition types, Expression, Global function, and Common.
Note The list of possible Global functions and Common s would be restricted to the target environment, such as the server-side, client-side or both.
Expression: logical or relational operation defined by users.Steps:
This graphic is described in the surrounding text.
Select one of the operators to define Expression type.
Define left and right input elements according to Expression type. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
Global function: common data manipulation, such as compare and concatenate provided by UDTT. Steps:
This graphic is described in the surrounding text.
Expand the functions tree to select the Global function. You could use the search bar to find the Global function you want and use Description label to know better about the function. See Global functions for detailed information about the function.
Define each parameter. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
Common: common condition which has been defined by users in Condition Dictionary.
This graphic is described in the surrounding text.
Steps:
Select the Common from the List panel.
Define each parameter. Click the 'browse' button on the right. In the pop-up Expression editor, select one of the supported elements and assign the value.
4 Click 'Create' button in the Control area.
This graphic is described in the surrounding text.
5 After defined the Condition, you should define the data mapping applied under this condition.
Note When the focus is on the Condition or inside mappings, the new created mapping will be under this condition. Otherwise when the focus is lost, the new created mapping will be outside this condition.
Under a Condition, you could define nested Conditions. You need to follow the restrictions on valid Condition group.
6 If needed, define mapElseIf or mapElse Condition as the previous steps.
After the creation of MapIf, the 'Add Nest' button is valid. This means you could define a Condition under some upper level by clicking this button at the last step.
Note If you created a Condition at the wrong level, you could use drag & drop to reorder the levels. For more information, see Reordering the mappings.
Result
In this way, users could define multiple switches that specific data mappings would be applied under specific Condition.
Conditionalmapping example
Note The conditional mapping, expression calculation, and global function invocation are implemented with expressions and are run as scripts dynamically in run time. The expression execution might take longer time than other statement execution. Therefore, the conditional mapping and mapping expression are not suitable for the large scale expressions and conditional mapping. Using conditional mapping for large scale expressions might cause performance issue.
In the following example, if sampleList contains 10000 elements, the conditional mapping takes long time, which might cause performance bottleneck for the system.
This graphic is described in the surrounding text.
In the case of large scale expressions, use the Operation and Java logic instead of the conditional mapping.