Integrator Scripting API

image_pdfimage_print

In Jedox Integrator, the use of scripting languages is foreseen in the following components:

  • Function Type Groovy
  • Function Type JavaScript
  • Job type Groovy
  • Job type JavaScript
  • Variable definition (Groovy only)

Besides the functionality of the scripting language, Jedox Integrator provides several classes with additional functionality related to the Jedox Integrator processing. The methods of the different classes are listed below.  Examples for the use of script functions and jobs can be found in the sample Jedox Integrator projects sampleGroovyOlap.xml, sampleGroovyFunction.xml, sampleGroovyJob.xml, and ETLTasks.xml (located in <InstallpathJedoxSuite\tomcat\webapps\etlserver\data\samples>).

Methods of the different classes

Class API (in all components)
These methods can be used in jobs, functions and variables. Additional methods are provided for the specific component types.

 String

getComponentName()
Gets the name of the Jedox Integrator component (the function or the job).

String

getConfigSetting (String key)
Gets a value from Jedox Settings Manager for a given key

 String

getConfigSetting (String key, String scope)
Gets a value from Jedox Settings Manager for a given key in a scope (i.e. technical name of a model)

 String

getLocalFilesDir()
Gets the absolute path of the directory used for relative paths in filebased connections.

String

getProperty (String name)
Gets the value of a property. Properties are used for different purposes depending on the scope:
– Variables: All variables holding their static default values. No possibilty call set properties
– Functions: Manually set arbitrary key-value pairs used as cache to store values of preceding rows
– Jobs: Manually set project variables to start job and lod executions with different variable settings.

boolean

isNumeric (String inputData)
Fast test if a given input data is numeric or not.  

Class API (in jobs and functions)

void clearProperties()
Clears all variables set prior via setProperty(String, String).
Source getSource (String name, String format, int size)
Initializes a new processor for access to the data of source if the source is not yet initialized. Otherwise returns an existing processor.
State getState ()
Get the execution state of the currently running execution e.g. job. The state holds information like e.g. the start time.
Source initSource (String name)
Initializes a new processor for access to the data of source.
Source initSource (String name, String format, int size)
Initializes a new processor for access to the data of source. Format defines the output of tree-based sources. Size limits the number of rows (default 0).
Void setProperty (String name, String value)
Sets a variable with a given value.
Class API (in jobs only)
State getConnectionMetadata (String name, String selector, Properties metadataProps)
Retrieve metadata information from a connection. The selector defines which information is requested, each connection type has its own selectors (see table below). Additional filter parameters are given as metadata properties.
State executeJob (String name)
Starts a job with all properties as variables and waits until the execution is finished. Name specifies the name of the job. Returns an Execution State.
State executeLoad (String name)
Starts a load with all properties as variables and waits until the execution is finished. Name specifies the name of the load. Returns an Execution State.
State testConnection (String name)
Tests a connection with all properties as variables. Name specifies the name of the connection. Returns an Execution State.
State testJob (String name)
Tests a job with all properties as variables. Name specifies the name of the job. Returns an Execution State.
State testLoad (String name)
Tests a load with all properties as variables. Name specifies the name of the load. Returns an Execution State.
State testSource (String name)
Tests a source (an extract or a transform) with all properties as variables. Name specifies the name of the source. Returns an Execution State.
Class API (in functions only)
Int getCalculationCount ()
Gets the number of times a function has been calculated in the source. A calculation of the function is not necessary for identical input values.
com.jedox.palojlib.interfaces.IElement

getTreeElement ()
(only for TreeElement tranform) returns the IElement of the processed element in the tree which holds children, parents, weight and attrib

 

Class API (Mailer) 

MailUtil
______________
getMailer()
Get the MailUtil utility instance that is used to send custom emails, the configuration for the sender’s email is read from the component Administration of Jedox Web. (See Adjusting the Settings for Email Notifications).

Class MailUtil
 
A utility class to send custom emails. Only the SMTP user/password authentication is supported.

Void
______________
addRecipient(String emailAddress)
Add recipient email (e.g. happy@jedox.com). Several recipients can be added.
Void setSubject(String subject)
Set the email subject text.
Void setMessage(String message)
Set the email body text.
Void addAttachment(String filename)
Add an email attachment (e.g. filename.txt). The path (similar to “File” connection) is relative to the “files” folder under etlserver webapp folder. Several attachments can be added.
Void reset()
Removes the email info, such as to send different mails to different recipients.
Void send()
Send an email; sender configuration is read from the Administration component of Jedox Web; recipients and email configurations are given directly by the user using the previously set methods.

As an example, you can find in sampleGroovyJob the Groovy job SendMail with the following script (located in <InstallpathJedoxSuite\tomcat\webapps\etlserver\data\samples>):

mailer = API.getMailer();
mailer.setServer();
/* for 2 recipients */
mailer.addRecipient("changeme@gmail.com");
mailer.addRecipient("changeme2@gmail.com");
mailer.setSubject("ETL Test Mail");
mailer.setMessage("Hello! here are the files.");
/* with 2 attachements */
mailer.addAttachment("FileToOlap.csv");
mailer.addAttachment("BikerOrderlines.csv");
mailer.send();

 

Class LOG
With this class a simple data validation can be added to a script function (among other things).

Void debug (Object message)
Adds a debug message to the log of the Jedox Integrator execution
Void error (Object message)
Adds an error message to the log of the Jedox Integrator execution
Void info (Object message)
Adds an info message to the log of the Jedox Integrator execution
Void warn (Object message)
Adds a warning message to the log of the Jedox Integrator execution
Class OLAP
The connection refers to the name of the Jedox connection in the Jedox Integrator project. 
In order to get a complete API on cubes, dimensions and elements, use method getDatabase(). With an object of type IDatabase all methods of the OLAP Java Client-Library (palojlib) are available. Package com.jedox.palojlib.interfaces.IDatabase is automatically imported. See also Java API for Jedox OLAP Server and the Jedox Integrator sample project sampleGroovyOLAP.xml.
IDatabase getDatabase (String connection)
Returns an OLAP database object (com.jedox.palojlib.interfaces.IDatabase). The connection is opened at the end of a Jedox Integrator execution. The connection is closed automatically from Jedox Integrator. See Jedox SDK for a reference of the OLAP Java Client Library.
IConnection getConnection (String connection)
Returns an OLAP connection object (com.jedox.palojlib.interfaces.IConnection). The connection is opened, and at the end of a Jedox Integrator execution the connection is closed automatically from Jedox Integrator. 
Note that for use of methods at the database level, getDatabase() can be used directly without calling this method first.
Boolean cubeConvert (String connection, String cube, int type)
Converts a cube to a different type. Type 0=Normal, Type 4=GPU. Returns true if the conversion has been successful.
Object data (String connection, String cube, String[] coordinates)
Gets the cell value of a Jedox cube. The coordinates are a list of elements for the cube dimensions.
Void erename (String connection, String dimension, String oldName, String newName)
Renames an element of a dimension
Void erename (String connection, String dimension, String[] oldNames, String[] newNames)
Renames multiple elements of a dimension
Class State
Information about the status of an Jedox Integrator execution can be retrieved.
Boolean isOK ()
Returns true if the execution status is “Completed successfully” or “Completed with Warnings”; otherwise false.
String getStatus ()
Gets the status code of the execution.
Int getWarnings ()
Gets the number of warnings that occurred while executing.
Int getErrors ()
Gets the number of errors that occurred while executing.
String getLog ()
Date getStartDate ()
Gets the start date of the execution.
Date getStopDate ()
Gets the stop date of the execution.
long getExecutionId()
Gets the identifier of the execution
long getExecutionParentId()
For parallel executions: Gets the identifier of the execution in which this sub-execution was started
String getUserName()
Gets the name of the user who initiated the execution
String getName()
Gets the name of the executed component e.g. name of the job or transform
String getType()
Gets the type of the executed component e.g. “transform”, “load” or “job”
   
Class Source
Handles a source processor to access to data of extracts and transforms.
Void close ()
Closes the source processor.
String getColumnString (String name)
Returns the value of a column in the current row as a string
Object getColumnValue (String name)
Returns the value of a column in the current row.
Boolean nextRow()
Gets the next row of data from the source processor. Returns false if no more rows are found, otherwise true.

To limit the authorizations of a script on the OS-level side (e.g. access to files and directories), change the OS user for the JedoxSuiteTomcatService, as described in the article Accessing Network Files.

image_pdfimage_print
Was this post helpful?
NoYes (-1 rating, 7 votes)
Loading...