Products Downloads


French version


 

Option to convert data from the data model before it is processed by the template (JSON Object array type)

 

It is used to apply a transformation to certain data model data before being converted into a data source and processed by the template.

The transformation consists in changing the value of an item of data (while keeping its type or changing the value type) but it cannot change the structure of the data model tree view.

The option enables several transformations to be defined; each transformation is defined by:

  • path (syntax close to XPath notation) which is used to identify one or more items of data in the data model tree view,
  • Java class which contains the transformation process to apply for each data value described by the path.

 

A transformation is described in JSON by an object with two members: "path" and "className" (Java conversion class name).

 

The jsonPathConv option is described in JSON as an object array (transformations).

 

Predefined transformations

There are several transformation classes available:

  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.ISO8601ToDateConversion: converts a date in the form of an alphanumeric string in ISO 8601 format (YYYY-MM-DD format, for example: 2018-12-31) into data interpreted by the data source as being FreeMarker Date type (conversion of Java String types to java.sql.Date);
  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.ISO8601ToTimeConversion: converts a time in the form of an alphanumeric string into ISO 8601 format (HH:MM:SS format, for example: 15:17:45) into data interpreted by the data source as being FreeMarker Time type (conversion of Java String types to java.sql.Time) ;
  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.ISO8601ToTimestampConversion : Converts a timestamp in the form of an alphanumeric string in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmm format, for example: 2018-12-31T15:17:45.682) into data interpreted by the data source as being FreeMarker Date-time type (conversion of Java String types to java.sql.Timestamp);
  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.YYYYMMDDNumberToDateConversion: converts a number (8 figures maximum) in the form of a date in YYYYMMDD format into data interpreted in the data source as being FreeMarker Date type (conversion of Java Integer types to java.sql.Date);
  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.EpochToDateConversion: converts a timestamp in the form of a number corresponding to a duration (in milliseconds) from January 1, 1970 at 0 o'clock (UTC) into data interpreted in the data source as being FreeMarker Date type (conversion of Java Long types to java.sql.Date);
  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.EpochToTimeConversion: converts a timestamp in the form of a number corresponding to a duration (in milliseconds) from January 1, 1970 at 0 o'clock (UTC) into data interpreted in the data source as being FreeMarker Time type - the conversion extracts the time of day from the timestamp - (conversion of Java Long types to java.sql.Time);
  • com.hardis.adelia.mergedocengine.datamodel.conversion.convertors.EpochToTimestampConversion: converts a timestamp in the form of a number corresponding to a duration (in milliseconds) from January 1, 1970 at 0 o'clock (UTC) into data interpreted in the data source as being FreeMarker Date-time type (conversion of Java Long types to java.sql.Timestamp);

↑ Top of page

 

Path syntax

The description of data chosen to apply the transformation uses a syntax close to the XPath language. A JSONPath expression:

  • Starts with the $ character: it is used to reference the highest level of root object, similar to the FreeMarker ".data_model" variable,
  • Uses the "dot" notation to identify the sub-variable identifying the data (e.g. $.name, $.client.lastname),
  • Uses "" notation to identify several sub-variables (e.g: $.studentList[].name).

 

Click below for more information: 

 

The JSONPath expression must reference simple-type variables and cannot reference complex-type variables (e.g. $.studentList[], $.).

 

For example:

"Options" parameter

Data model before transformation

Data model after transformation

 

 

↑ Top of page


 

  • Aucune étiquette