WSO2 Data Mapper Common Type Operators

WSO2 Data Mapper Common Type Operators

INTRODUCTION

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.

  1. How to Use WSO2 Data Mapping Mediator in ESB (Updated for-ESB-5.0.0-Beta2)
  2. Understanding WSO2 Data Mapper 5.0.0

OVERVIEW

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.

diagramEditor

They are,

  • Links
  • Common
  • Arithmetic
  • Conditional
  • Boolean
  • Type Conversion
  • String

In this post we will discuss about Common Operators, given in data mapper.

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

constantdefault

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.

configuremenuconstant.png

So you can define the value you need in here.

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

defaultcustomfunctionconfiguratoncustomfunction

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 Properties – use product specific runtime variables

This operator is discussed in great detail in the following post by Eranda.

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

GVoperatorGVconfiguration

This is basically a JavaScript variable defined in the outer scope so that any one can see and access it. You could use this variable in any custom function you define in the mapping. In the configuration you can change the name and default value of it.

Compare 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

compareOperatorcompareconfiguration

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s