Development tools : Transaction editor : Drawing flows in the flow editor : Setting data mappings to states or transitions : Defining data formatter : Defining Conditional mapping by data mapping
  
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 and 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.