Executing Scripts in Groovy Jobs

Database scripts can be generated and executed in Jedox Integrator with a Groovy job. 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.

Task Interface Example
Generating script for a dimension IDimensionScriptContext
Copy
IDimension dim = db.getDimensionByName("Regions");
                                IDimensionScriptContext dsc = dim.getScriptContext();
                                dsc.setComplete(true);
                                dsc.setWithAttribute(true);
                                dsc.setIncludeLocalSubsets(true);
                                dsc.setIncludeGlobalSubsets(true);
                                dsc.setIncludeDimensionRights(true);
                                dsc.setCreateClause(IScriptHandler.ScriptCreateClause.NO_ERROR);
                            String dimScript = dim.generateScript(dsc);
Generating script for a cube ICubeScriptContext
Copy
ICube cube = db.getCubeByName("Sales");
                                ICubeScriptContext csc = cube.getScriptContext();
                                csc.setComplete(true);
                                csc.setWithAttribute(true);
                                csc.setWithRule(true);
                                csc.setIncludeCubeRights(true);
                                csc.setCreateClause(IScriptHandler.ScriptCreateClause.NO_ERROR);
                            String cubeScript = cube.generateScript(csc);
Generating script for a whole database IDatabaseScriptContext
Copy
IDatabaseScriptContext dbsc = db.getScriptContext();
                                dbsc.setCreateClause(IScriptHandler.ScriptCreateClause.NO_ERROR);
                            String databaseScript = db.generateScript(dbsc);
Reading the variables and values of a given script IScriptVariable
Copy
IConnection conn = OLAP.getConnection("olapdemo");
                                LOG.info("Variable Name - Variable Value - Description:");
                                IScriptVariable[] variables = conn.getScriptHandler().getVariables(dimScript);
                            for (IScriptVariable variable : variables)
Setting the variable values in a given script IScriptVariable
Copy
for (IScriptVariable variable : variables) {
                                if (variable.getName().equals("DimensionName")) {
                                String newName = variable.getValue()+"_Copy";
                                LOG.info("Change dimension name to "+newName);
                                variable.setValue(variable.getValue()+"_Copy");
                                }
                            }
Executing a database script (with a given set of variable values) IScriptHandler
Copy
IScriptHandler scriptHandler = conn.getScriptHandler();
                                IDatabase db = OLAP.getDatabase("olapdemo");
                                IDimension dim = db.getDimensionByName("Regions");
                                IDimensionScriptContext dsc = dim.getScriptContext();
                                String dimScript = dim.generateScript(dsc);
                            scriptHandler.execute(dimScript,"Demo",variables);

For the list of all functions provided in the Jedox Java API see the Java API Documentation, which is available online or as a download.

 

Updated September 27, 2022