Powered By Blogger

Jul 29, 2016

WSO2 Data Mapper Operators - Common category

 This post describes about the operators in the Common category







  • Constant

Defines a String, Number or Boolean as a constant

1.Drag and drop a constant operator to the editor

cons.png

2.As you can see it only has a output connector and that value can be a either a Number, String or Boolean. To configure, right click on constant operator and click on “Configure Constant Operator” menu action. 


cons2.png



3.After specifying the value you will get an output as follows

cons3.png

  • Custom function


Custom function is for more advanced users who need more functionality other than offered in the data mapper. And if you know JavaScript well you could do many things by using custom functions with global variable operator. But here it will only describe the basic features and how to use this operator to define our own functionality.

1. Drag and drop custom function operator to editor
customfunc1.png


2. Right click and select “Configure custom function properties” menu action
-Give a name to the function in the Function Name text box. (You can not use same name to two functions in the same mapping)

-Number of parameters/inputs needed in the Number of Inputs text box.

-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.

customfunc2.png
  • Properties
More information can be found at https://medium.com/@eranda/wso2-esb-data-mapper-accessing-esb-properties-from-data-mapper-111b3e835#.4myz9hn4l
  • Compare
This operator can be used to compare any two values in the mapping. There are 8 different compare operations as follows

-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

compare.png

Eg: If the calories are less than 10, then the output boolean value will be true which is mapped to the approval value

comapreEx.png

  • Global Variable

Global variable operator is given to instantiate a variable to be used in any place in the mapping
 

1.Drag and drop the operator
global1.png
2. Right click and select “Configure Global variable operator” menu action
global2.png



3. Change the name and default value.

This is basically a JavaScript variable defined in the outer scope so that anyone can see and access it. Also you could use this variable in any custom function you define in the mapping.


No comments:

Post a Comment