WSO2 data mapper is a data mapping solution that convert and transform one format of data to a different format. It provides a WSO2 Developer Studio based tool to create the graphical mapping configuration and generate the files needed to execute the mapping configuration by the WSO2 Data mapper engine.
If you first came to here look for the two previous posts which will give you the basic understanding of WSO2 Data Mapper and how to integrate it with WSO2 ESB.
- How to Use WSO2 Data Mapping Mediator in ESB (Updated for-ESB-5.0.0-Beta2)
- Understanding WSO2 Data Mapper 5.0.0
This post is one of many to introduce data mapper operations available and how to use it in mapping configuration. There are mainly six categories in the operator pallet as shown in the following diagram.
- Type Conversion
In this post we will discuss about Common Operators, given in data mapper.
Constant- define string, number or boolean constant values.
This operator is basically to define values we need to use in mapping. When you drag and drop the constant operator from the pallet to editor area you will get it as following diagram.
As you can see it only has a output connector. And that value can be a Number, String or Boolean. To configure it right click on constant operator and click the configure constant operator menu action. It will pop up a dialog box to configure the operator as follows.
So you can define the value you need in here.
Custom Function – define custom function to use in mapping
Custom function is for more advanced users who need more functionality other than offered in the data mapper. And if you know Java Script well you could do many things by using custom functions with global variable operator. But here I will only describe the basic features and how to use this operator to define our own functionality.
When you drag and drop custom function operator for editor you will get the following default operator and the configuration.
You should first give a name to your function in the Function Name text box. You can not use same name to two functions in the same mapping.
Then define the number of parameters/inputs you need in the Number of Inputs text box.
Then you need to define the parameters inside the function definition () according to the number of inputs you specified above. Use those parameters or any Global Variable value inside the custom function to do the functionality and return the value.
Properties – use product specific runtime variables
This operator is discussed in great detail in the following post by Eranda.
Global Variable – instantiate global variable to access from any where
Global variable operator is given to instantiate a variable and use in any where in the mapping. When you drag and drop the operator to editor you will see following default operator and the configuration.
Compare – compare two inputs in the mapping
This operator can be used to compare any two values in the mapping. There are 8 different compare operations you could do. They are,
- equal value (two inputs are equal or not)
- equal value type (two inputs are equal in both value and type)
- not equal value (two inputs are not equal or not)
- not equal value type (two inputs are not equal in both value and type)
- greater than
- greater than or equal
- lower than
- lower than or equal