Docs Menu
TRANSFORMER Step
This is one of the most frequently used steps on the platform. The creates and manages various input and output variables and their associated mappings. Every variable that is created under the Transformer has a pencil sign with it depicting that the variable has been created under the current Transformer. In the below example, we have created an intA variable of type integer. The pencil here depicts that the intA variable has been created under the current TRANSFORMER.
As we proceed to the next Transformer the pencil sign on intA is not visible as it does not pertain to that Transformer.
This mapping is carried out between two variables. The mapping assigns the value of the source variables to the destination variables. The datatypes of both variables should be the same. The mapping is carried out by clicking on the source variable and dragging the mouse up to the destination variables. The mapping is represented by a line.
Example: The figure below shows the mapping of two variables.
The mapping between intA and intB is clearly seen. This mapping represents that the value of intA is assigned to intB or it can be directly written as intB = intA.
We can have multiple Transformers in a flow service and these can be also placed using various control structures also. A Transformer is created in the flow service. A TRANSFORMER step is created by right-clicking on the control flow section and selecting TRANSFORMER from the context menu strip shown below:
This will create a TRANSFORMER step in the Syncloop Workspace.
TRANSFORMER Properties
It has four main properties
Status: | To enable/disable the TCF Block. The default status will be in enabled mode. If the status is selected as disabled in the case switch & its child cases and further steps will not execute when the API service will be invoked either from HTTP or from another service. |
Snapshot: | Create a runtime data state snapshot for the switch step. |
Comment: | Add comment to the TCF Block. |
Transformer Sections
When we click on the TRANSFORMER, the following window is displayed. The tools are distributed between the input, output, and mapping.
This window has two main parts
1) Input Section
These sections displayed all the input parameters of the service. This section is used to carry forward the reference of the variables created in proceeding TRANSFORMERs. These parameters can be a variable of types such as String, integer, Date, Number, Boolean, Document, etc. The tools are available to manipulate and work on these variables. The various tools associated with these variables are shown in the table below:
2) Output Section
These sections displayed all the output parameters of the service. All the new variables are created in the output section. These parameters can be a variable of types such as String, integer, Date, Number, Boolean, Document, etc. The tools are available to manipulate and work on these variables.
Tools used in Input and Output Sections
The various tools used in the request and response sections are explained below:
1) Maximize:
This is used to maximize the request and response window on to the workspace. This provides better visibility and flexibility for working the variables and also their mapping.
2) Custom Mapping Configuration
This option is used when there is a need to customize the existing mapping between two variables via a mapping line. To create a custom mapping configuration for an existing map. Click on the mapping line and once the line is red.
Then click on the Custom Mapping Configuration tool in the toolbar, A custom mapping configuration dialog will be displayed. There are two types of mapping possible
1. Custom Mapping
2. Conditional Mapping
These two mappings are discussed in the various properties associated with Custom Mapping Configuration below:
The description for the Custom Mapping Configuration is described below:
Path From This is the XPath Source Variable. This variable can be a variable of type as String, integer, Date, Number, Boolean, or Document.
Path To This is the XPath destination Variable. This variable can be a variable of type as String, integer, Date, Number, Boolean, or Document.
Method Some default function methods are provided including custom methods. If the method is selected as the custom then we need to explicitly specify the code in the function. The method can take any of the values
trim: The value of the source variable will be trimmed (right and left blank Spaces removed) before assigning it to the destination variables.
emptyToNull: The value of the source variable will be changed from empty to Null before assigning it to the destination variable.
blankToNull: The value of the source variable will be changed from blank value to Null before assigning it to the destination variable.
numberToString: The value of the source variable will be changed from number to string before assigning it to the destination variable.
custom: The custom will provide an option to the developer to have a custom transformation function from the source variable to the destination. When the custom option is selected the function text box if populated with
function (val){
return val;
}
Using this function, the developer can specify its own configuration mapping code which can be changed and modified accordingly.
Condition To specify conditions on mapping. This condition has to remain true and then only the mapping will take place. Any relation operation can be performed in the condition text box. The various relation operators that can be used in the text box are shown in the table below
An Example of Mapping Condition is provided by the video link below:
Video link: https://www.youtube.com/watch?v=SsStgqyXCkQ
3) Drop an Element
The renders element/variable is unusable for the following steps. Once any element is dropped it is not visible in the next Transformer.
4) Initialize an Element
Assigns value or expression to the variables. To assign the value to select the variable and click on initialize the element tool, the following dialog will be displayed.
5) Refresh
It is used to refresh the section.
The detailed description of all the options provided in the initial element dialog is displayed in the table below.
None
A constant value can be assigned to the variable. These constants can use different types of single (Not an Array) constant values such as String, integer, Date, Number, and Boolean but Document, Byte, and Object are not accepted.
Evaluate Expression
An expression consisting of variable names and operations can be provided in this text box. The Java inbuilt function can also be used with the existing local configuration variables.
These variables can use different types of single (Not an Array) constant values such as String, integer, Date, Number, and Boolean but Document, Byte, and Object are not accepted. Each variable is represented by its XPath.
The variables are entered using their XPaths using the following syntax
#{<variable-name>}
Example: #{*payload/strOutput}
Where *payload/strOutput is the XPath of the strOutput variable.
All the JavaScript functions can also be used by selecting Evaluate Expression option.
Evaluate Local Package variables
To change or create new local configuration variables, click on the configuration tool at the top of the workspace and initialize these variables in the configuration property section of the dialog.
These variables can use different types of single (Not an Array) constant values such as String, integer, Date, Number, and Boolean but Document, Byte, and Object are not accepted. Each variable is represented by its XPath.
Evaluate Package Configuration Variables
The value of the Package Configuration variable can be picked from the local configuration. To access the local Package Configuration, click on the package file that is located under the config folder of the current package. Once we click on the package information will be displayed in the workspace as variable names with their values.
These variables can use different types of single (Not an Array) constant values such as String, integer, Date, Number, and Boolean but Document, Byte, and Object are not accepted. Each variable is represented by its XPath.
Evaluate Global Configuration Variables
The values are picked from the Global Configuration file. This file is located in the Global Package in the package explorer. The file ready contains some global property variables. To create a new Global Configuration variable and new variable is added to the file.
These variables can use different types of single (Not an Array) constant values such as String, integer, Date, Number, and Boolean but Document, Byte, and Object are not accepted. Each variable is represented by its XPath.
To know more about local, package and global configurations watch the video below. Suitable examples are also provided in the said video. The video link is given below:
https://www.youtube.com/watch?v=7H3PIan9JQ4
Maximise Button
This button is used to maximize the dialog. When the dialog is maximized, the value can be entered in multiline mode. It means that JSON data values can also be entered directly as the value. It also enhances the developer’s ability to work on the initialize element dialog providing more clarity and flexibility.
Close button
Once the Set dialog is directly closed without clicking on the OK button to save the variable data, the application prompts the developer to save the value entered in the dialog.
Delete Mapping/Value Deletes the configuration mapping, and drop function. Before deleting the element, we need to use this tool to delete the mapping or the value associated with the variable/element.
Refresh Refreshes the variable/element created in the input and output sections.