CTL Templates for Joiners

This transformation template is used in every Joiner and also in Reformat and DataIntersection.

Here is an example of how the Source tab for defining the transformation in CTL looks.

Source Tab of the Transform Editor in Joiners

Figure 50.1. Source Tab of the Transform Editor in Joiners


Table 50.2. Functions in Joiners, DataIntersection, and Reformat

CTL Template Functions
boolean init()
RequiredNo
DescriptionInitialize the component, setup the environment, global variables
InvocationCalled before processing the first record
Returnstrue | false (in case of false graph fails)
integer transform()
Requiredyes
Input Parametersnone
ReturnsInteger numbers. See Return Values of Transformations for detailed information.
InvocationCalled repeatedly for each set of joined or intersected input records (Joiners and DataIntersection), and for each input record (Reformat).
DescriptionAllows you to map input fields to the output fields using a script. If any part of the transform() function for some output record causes fail of the transform() function, and if user has defined another function (transformOnError()), processing continues in this transformOnError() at the place where transform() failed. If transform() fails and user has not defined any transformOnError(), the whole graph will fail. The transformOnError() function gets the information gathered by transform() that was get from previously successfully processed code. Also error message and stack trace are passed to transformOnError().
Example
function integer transform() {
   $0.name = $0.name;
   $0.address = $city + $0.street + $0.zip;
   $0.country = toUpper($0.country);
   return ALL;
}
integer transformOnError(string errorMessage, string stackTrace, integer idx)
Requiredno
Input Parametersstring errorMessage
string stackTrace
ReturnsInteger numbers. See Return Values of Transformations for detailed information.
InvocationCalled if transform() throws an exception.
DescriptionIt creates output records. If any part of the transform() function for some output record causes fail of the transform() function, and if user has defined another function (transformOnError()), processing continues in this transformOnError() at the place where transform() failed. If transform() fails and user has not defined any transformOnError(), the whole graph will fail. The transformOnError() function gets the information gathered by transform() that was get from previously successfully processed code. Also error message and stack trace are passed to transformOnError().
Example
function integer transformOnError(
                       string errorMessage, 
                       string stackTrace) {
   $0.name = $0.name;
   $0.address = $city + $0.street + $0.zip;
   $0.country = "country was empty";
   printErr(stackTrace);
   return ALL;
}
string getMessage()
RequiredNo
DescriptionPrints error message specified and invocated by user
InvocationCalled in any time specified by user (called only when transform() returns value less than or equal to -2).
Returnsstring
void preExecute()
RequiredNo
Input parametersNone
Returnsvoid
DescriptionMay be used to allocate and initialize resources required by the transform. All resources allocated within this function should be released by the postExecute() function.
InvocationCalled during each graph run before the transform is executed.
void postExecute()
RequiredNo
Input parametersNone
Returnsvoid
DescriptionShould be used to free any resources allocated within the preExecute() function.
InvocationCalled during each graph run after the entire transform was executed.

[Important]Important
  • Input records or fields and output records or fields

    Both inputs and outputs are accessible within the transform() and transformOnError() functions only.

  • All of the other CTL template functions allow to access neither inputs nor outputs.

[Warning]Warning

Remember that if you do not hold these rules, NPE will be thrown!