Page 1 of 1
TM1 with Java
Posted: Mon Mar 16, 2015 1:53 am
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!
Re: TM1 with Java
Posted: Mon Mar 16, 2015 9:24 am
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.
Re: TM1 with Java
Posted: Fri Mar 20, 2015 9:49 am
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?
Re: TM1 with Java
Posted: Sun Mar 22, 2015 2:38 pm
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!
Re: TM1 with Java
Posted: Mon Mar 23, 2015 4:51 pm
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.
Re: TM1 with Java
Posted: Fri Mar 27, 2015 12:33 pm
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.
Re: TM1 with Java
Posted: Tue Mar 31, 2015 8:55 pm
by tianoklein
Hello folks,
I tried to create a simple java code to create items in a Dimension, but doesn't work.
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;
}
Re: TM1 with Java
Posted: Wed Apr 01, 2015 10:23 pm
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;
}
}
Re: TM1 with Java
Posted: Mon Apr 06, 2015 1:25 pm
by tianoklein
Hello BrianL,
Thanks for your reply.
I tried de code, but now the variable newElement have de Error below:
Error: ObjectIsRegistered

Re: TM1 with Java
Posted: Mon Apr 06, 2015 2:58 pm
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;
}
}
Re: TM1 with Java
Posted: Mon Apr 06, 2015 8:27 pm
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...
