Follow these steps to configure Eclipse Java EE IDE for IBM®
Cognos®
TM1®
Java™ extensions.
About this task
This procedure and the children topics of this procedure
guide you through the configuration of Eclipse and the creation of
simple example scripts that illustrate the use of Java extensions in TM1.
You can modify the examples to create your own custom scripts.
Procedure
Open Eclipse.
Click Workbench.
Click Window > Open Perspective > Java to
open the Java perspective.
Click File > Java Project to
create a new Java project.
Enter a Project name.
Click Finish.
Right-click the new project, then click Properties.
On the Properties window, click Java
Build Path.
Click the Libraries tab.
Click Add External JARs.
Add the javatiapi.jar from your TM1
installation directory.
Click OK to save the properties.
Right-click the new project, then click New > File.
Enter extension.xml as the file name.
Click Finish.
Click the Source tab, then enter
the following XML code:
This XML tells the Java extensions code that this is an extension,
and tells it where to look for these items:
id - An unique ID for your extension, each extension must have a different
ID.
name - A display name for your extension,
possibly a brief description
version - The version number for your extension. Java extensions will always load the latest version of an extension if several
extensions are all available with the same ID.
scripts-package - Tells the Java extensions engine where to look for Java extensions TurboIntegrator
scripts.
Expand the new project in Eclipse.
Right-click the SRC folder, then click New > Package.
Assign the name my.scripts to the new
package, then click Finish.
In the Package pane, right-click
the new my.scripts package, then click New > Class.
Complete the New Java Class
dialog box as follows:
Figure 1. New Java Class dialog box
Click Finish.
Enter the following code in the MyTestTI.java class:
package my.scripts;
import com.ibm.cognos.tm1.javati.TM1UserThread;
import com.ibm.cognos.tm1.javati.ti.TIFunctions;
public class MyTestTI {
public static double MyTestTI(String[] args) {
TIFunctions ti = TM1UserThread.getTIFunctions();
if (args.length < 1) {
throw new IllegalArgumentException();
}
String dim = args[0];
if (ti.DimensionExists(dim)) {
ti.DimensionDeleteAllElements(dim);
} else {
ti.DimensionCreate(dim);
}
return 0;
}
}
This script takes a single parameter, the name of a dimension. If that dimension exists it
deletes all elements, otherwise it creates a new dimension with that name. It's a simple script but
it is a useful example.