Transformation Language Lite

!!! IMPORTANT !!! Transformation Language Lite is now considered obsolete. Use Transformation Language (CTL) instead !

The purpose for this concept is to handle parsing Java transformation code enhanced with CloverETL Transformation Language Lite syntax. This allows using CloverETL specific transformation code which is then unrolled to fully compilable Java source. Thus constructs in the Transformation Language Lite can be used without loosing the speed of compiled byte code.

The Transformation Language Lite can be used with the following components (in their transform parameter):

  • Reformat
  • HashJoin
  • AproxMergeJoin
  • MergeJoin
  • DataInterseption
  • DBJoin
  • LookupJoin

If you decide to use the Transformation Language Lite to define transformation code, you don't have to write the full Java class implementation. Just focus on the transformation code itself (assignments, etc) and Clover will automatically wrap the code to proper Java class definition source code.

Currently the language supports references to field values and record & field objects. Future enhancements will include support for aggregate functions (similar to SQL aggregation).



Syntax Description
${in.record_ordinal_num. field_name} References the value of an input record's field. The value is read from the field (and then can be assigned to another field etc.).

Record ordinal number corresponds to port number from which the record is read. Field names are names of individual fields within respective records.

The actual Java code generated depends on field's data type. Data field object is casted to the proper subclass (e.g. StringDataField, NumericDataField,etc.) and then appropriate “getter” method is called. This table shows what “getter” method is generated for individual Clover field types:

STRING_FIELD	                toString()
DATE_FIELD, DATETIME_FIELD	getDate()
NUMERIC_FIELD	                getDouble()
INTEGER_FIELD	                getInt()
DECIMAL_FIELD	                getDecimal()
BYTE_FIELD	                getValue()
Note: field names are not case sensitive.
@{in.record_ordinal_num. field_name} References an intput record's field (i.e. the object of the field).

Record ordinal number corresponds to port number from which the record is read.

Field names are names of individual fields within respective records.
It is translated to object access - e.g. @<in.1.id> is translated to to something like: (inputRecords[0].getField(1))
${out.record_ordinal_num. field_name} References the value of an output record's field. The value can be changed (i.e. by assigning it the value of some input record's field).

The generated Java code takes care of casting the DataField to proper subclass (e.g. StringDataField, NumericDataField, etc.) and calling setValue() on the object.
@{out.record_ordinal_num. field_name} similar to @{in.
${par.parameter_name} References graph's paramater for reading values from it.

Parameter's value in form of String object is returned.
${seq.sequence_name} References graph's sequence for reading values from it.

Sequence must be registered within graph. The generated Java code takes care of initializing the object and calling nextValueInt().


Examples of using:

  String variable1 = Integer.parseInt(${in.0.OrderID});
  
  ${out.0.OrderID}=variable1;
  ${out.0.UniqueID}=${in.0.OrderID}+${in.0.CustomerID};

Mixed Java code:

  ${out.0.PSSO_ID} = ${seq.Sequence0};
  ${out.0.PROJECT_ID} = ${in.0.PROJECT_ID};
  ${out.0.PSFLAG} = ${in.0.PSFLAG};
  ${out.0.NAME} = ${in.0.NAME}+${in.1.NAME}.toUpperCase();
  ${out.0.PSSOUSERNUM} = ${in.0.PSSOUSERNUM};
  ${out.0.SUPPLIER} = ${in.1.SUPPLIER};
  ${out.0.PROJECTNUM} = ${in.1.PROJECTNUM};
  ${out.0.RESPONSIBLEPERSON} = "Person"+${in.1.RESPONSIBLEPERSON};
  ${out.0.HZS_IND_M} = ${in.1.HZS_IND_M};
  ${out.0.HZS_IND} = ${in.1.HZS_IND};
  ${out.0.STARTDATE} = ${in.1.STARTDATE};
  ${out.0.ENDDATE} = ${in.1.ENDDATE};
  ${out.0.DESCRIPTION} = ${par.dbURL};	 

Output Java source code (excerpt):

  ((IntegerDataField)outputRecords[0].getField(OUT0_PSSO_ID)).setValue(Sequence0.nextValueInt());
  ((IntegerDataField)outputRecords[0].getField(OUT0_PROJECT_ID)).setValue(
    (((IntegerDataField)inputRecords[0].getField(IN0_PROJECT_ID)).getInt()));
  ((IntegerDataField)outputRecords[0].getField(OUT0_PSFLAG)).setValue(
    (((IntegerDataField)inputRecords[0].getField(IN0_PSFLAG)).getInt()));
  (outputRecords[0].getField(OUT0_NAME)).setValue(
    (inputRecords[0].getField(IN0_NAME).toString())+
    (inputRecords[1].getField(IN1_NAME).toString()).toUpperCase());
  ((IntegerDataField)outputRecords[0].getField(OUT0_PSSOUSERNUM)).setValue(
    (((IntegerDataField)inputRecords[0].getField(IN0_PSSOUSERNUM)).getInt()));
  ((IntegerDataField)outputRecords[0].getField(OUT0_SUPPLIER)).setValue(
    (((IntegerDataField)inputRecords[1].getField(IN1_SUPPLIER)).getInt()));
  ((IntegerDataField)outputRecords[0].getField(OUT0_PROJECTNUM)).setValue(
    (((IntegerDataField)inputRecords[1].getField(IN1_PROJECTNUM)).getInt()));
  ((NumericDataField)outputRecords[0].getField(OUT0_HZS_IND_M)).setValue(
    (((NumericDataField)inputRecords[1].getField(IN1_HZS_IND_M)).getDouble()));
  ((NumericDataField)outputRecords[0].getField(OUT0_HZS_IND)).setValue(
    (((NumericDataField)inputRecords[1].getField(IN1_HZS_IND)).getDouble()));
  ((DateDataField)outputRecords[0].getField(OUT0_STARTDATE)).setValue(
    (((DateDataField)inputRecords[1].getField(IN1_STARTDATE)).getDate()));
  ((DateDataField)outputRecords[0].getField(OUT0_ENDDATE)).setValue(
    (((DateDataField)inputRecords[1].getField(IN1_ENDDATE)).getDate()));
  (outputRecords[0].getField(OUT0_DESCRIPTION)).setValue(param_dbURL);

transf_java_preprocess.txt · Last modified: 2009/09/16 12:27 (external edit)
Back to top
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0