This function is used to execute a script in the Groovy programming language. Groovy is a relatively new script language that is closely based on Java syntax, but also allows a simplified syntax. It is characterized by its dynamic typing, high execution speed and good integration into the Java Virtual Machine. The Groovy function can be used to program very individual transformations implemented at runtime. It is also suitable for mathematical calculations.
More information about the Groovy programming language is available at http://groovy-lang.org.
The input fields can be used in the script with their names as variables. The name of the input field should also be a valid Groovy variable name. If the input field contains a space or, for example, a “-” or “+”, “_input1” or “_input2” must be written in the script instead of the input name.
A type can be assigned to each input field that defines the type of the variable in the script. If necessary, a type conversion of the input data are done before the script is executed (except for Object type, which does no conversion and keeps the input type). This is especially helpful for numerical inputs and calculations.
The following data types exist:
The default type is string.
|Type||The data type of return value. All of the above data types are possible; the assignment of a type is optional.|
|buffered||If set, the function results are cached and the script is not evaluated for identical input values (default). If not set, the script is always evaluated for all rows. This is necessary if the result depends on the row number or a random number generator.|
The result of the function is determined in the script with a return statement. If no value is returned, then the function has the result NULL.
Note: for performance reasons, the Groovy function internally buffers the results, so that a script is executed only once for the same set of input values. This may lead to wrong values if the script doesn’t depend only on the input values, e.g. random value functions, use of setProperty()/getProperty(). In this case, a RowNumber function should be added to the input list of the script function so that it is always unique.
Besides the various functionalities offered by Groovy (and Java), specific Jedox Integrator functionality can be used via the Jedox Integrator Scripting API.