TM1 with Java

Post Reply
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

TM1 with Java

Post by tianoklein »

Hello Folks!
I would like to create an application with JAVA using TM1 like a Database (Create, Insert, Update, Delete cubes/dimensions/elements).
It is possible ? How can I do it?

Any help will be welcome!
David Usherwood
Site Admin
Posts: 1453
Joined: Wed May 28, 2008 9:09 am

Re: TM1 with Java

Post by David Usherwood »

Suggest you look at the Java Extensions for TM1:
https://www.ibm.com/developerworks/comm ... Integrator
Note that the description is misleading. The intended use is for creating Java routines to be called from within TI. I don't find your post completely clear but I think you are talking about calling TI functions from within Java - but a good subset of the TI commands are supported by the Java Extensions. I don't know for sure that you can use them other than by embedding them in a call from TI but it may be possible.
On a side note -
using TM1 like a database
- TM1 is a database - just not a relational database.
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: TM1 with Java

Post by tianoklein »

Hello David,
Wow!
That was exactly what I was looking for. I will study more to understand how it works...
but ... :)
Would you have some sample scripts (can be very simple) using these features?
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: TM1 with Java

Post by tianoklein »

What i really want is maintain a dimension with a java application.
I mean, create, update, delete,insert, search, etc.

Do you thinks its possible with TI java extension?

Thanks for help-me!
User avatar
qml
MVP
Posts: 1094
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: TM1 with Java

Post by qml »

tianoklein wrote:What i really want is maintain a dimension with a java application.
I mean, create, update, delete,insert, search, etc.

Do you thinks its possible with TI java extension?
This is exactly what it's for. You can either replace your TI scripts with Java classes (well, almost), or use them to enrich your TI routines. Either way, you should be able to do pretty much all ETL tasks, including the activities that you mention.
Kamil Arendt
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: TM1 with Java

Post by tianoklein »

Hello qml,
Many thanks for your advice.. will be very useful...
I would really appreciate if you had any examples to share with me. Could be very simple.
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: TM1 with Java

Post by tianoklein »

Hello folks,

I tried to create a simple java code to create items in a Dimension, but doesn't work. :x
Any advice will be welcome!

Code: Select all

	static TM1Dimension dimCreateElement(TM1Server oServer, String dimName, String elmName) {
		TM1Dimension sd;
		TM1Element elm = TM1Element.NullElement;
		int elementTYPE = TM1ObjectType.ElementSimple;
		sd = oServer.getDimension(dimName);
		String[] s_fields;
		s_fields = new String[2];
		
		s_fields[0] = "test1";
		s_fields[1] = "test2";
		sd.register(oServer, dimName);
		sd.register(oServer, elmName);
		sd.insertElement(elm, s_fields[1], elementTYPE);

		return null;
	}
BrianL
MVP
Posts: 264
Joined: Mon Nov 03, 2014 8:23 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2 PA2
Excel Version: 2016

Re: TM1 with Java

Post by BrianL »

You probably want something more like this:

Code: Select all

static TM1Dimension dimCreateElement(TM1Server oServer, String dimName, String elmName) {
          TM1Dimension sd;
          TM1Element elm = TM1Element.NullElement;
          int elementTYPE = TM1ObjectType.ElementSimple;
          sd = oServer.getDimension(dimName);

          TM1Element newElem = sd.insertElement(elm, elmName, elementTYPE);

          if( newElem.isError() )
          {
                    return null;
          } else {
                    return newElem;
          }
 }
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: TM1 with Java

Post by tianoklein »

Hello BrianL,
Thanks for your reply.

I tried de code, but now the variable newElement have de Error below:

Error: ObjectIsRegistered

Image
BrianL
MVP
Posts: 264
Joined: Mon Nov 03, 2014 8:23 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2 PA2
Excel Version: 2016

Re: TM1 with Java

Post by BrianL »

Sorry, Dimension require the duplicate, edit, and update steps. You are not allowed to make edits directly to the public (registered) dimension. That's the error message you were seeing.

To correct it, you first create a duplicate dimension, make all your edits to that duplicate dimension, then call updateDimension when you are done editing to make your changes public.

Code: Select all

    static TM1Dimension dimCreateElement(TM1Server oServer, String dimName, String elmName) {
              TM1Dimension sd;
              TM1Element elm = TM1Element.NullElement;
              int elementTYPE = TM1ObjectType.ElementSimple;
              sd = oServer.getDimension(dimName);
              sdCopy = sd.duplicate();

              TM1Element newElem = sdCopy.insertElement(elm, elmName, elementTYPE);

              if( newElem.isError() )
              {
                        return null;
              } else {
                        sd = sd.updateDimension(sdCopy);
                        return null;
              }
     }
User avatar
tianoklein
Posts: 41
Joined: Fri Jun 13, 2014 1:23 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: TM1 with Java

Post by tianoklein »

Wow.. Thank you...

Now it's working...But, where did you find this information? I searched for all the web...and nothing...
I wouldn't want to importune you all the time... :D
Post Reply