Configure Eclipse Java EE IDE

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

  1. Open Eclipse.
  2. Click Workbench.
  3. Click Window > Open Perspective > Java to open the Java perspective.
  4. Click File > Java Project to create a new Java project.
  5. Enter a Project name.
  6. Click Finish.
  7. Right-click the new project, then click Properties.
  8. On the Properties window, click Java Build Path.
  9. Click the Libraries tab.
  10. Click Add External JARs.
  11. Add the javatiapi.jar from your TM1 installation directory.
  12. Click OK to save the properties.
  13. Right-click the new project, then click New > File.
  14. Enter extension.xml as the file name.
  15. Click Finish.
  16. Click the Source tab, then enter the following XML code:
    <extension>
        <id>my.extension</id>
        <name>My Extension</name>
        <version>1.0.0.0</version>
        <scripts-package>my.scripts</scripts-package>
    </extension>

    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.
  17. Expand the new project in Eclipse.
  18. Right-click the SRC folder, then click New > Package.
  19. Assign the name my.scripts to the new package, then click Finish.
  20. In the Package pane, right-click the new my.scripts package, then click New > Class.
  21. Complete the New Java Class dialog box as follows:
    Figure 1. New Java Class dialog box
    New Java Class dialog box.
  22. Click Finish.
  23. 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.