OpenTool in ODI using Java

OpenTool in ODI using Java:

Hi Guys !!! ๐Ÿ™‚
Today I am going to write something interesting for ODI Lovers. Whenever you are creating a package you can see a lot of OdiTools like OdiSendMail, OdiFileDelete, OdiSqlUnload etc. You may not know this but good thing is that you can develop your own tool by adding a desired image/icon with few lines of codes. But the only thing that might worry you is that you should have sound knowledge on java to create couple of class files and wrap it into a Jar. Best option would be to develop it in eclipse which will automatically generate the class file and finally you can export it as a Jar file. If you are not familiar with Java and Eclipse IDE try writing couple of small programs and create Jar out of it.

Ok, here is the code snippet to get you started on this.

package com.bhabani.OdiTool;
import oracle.odi.sdk.opentools.IOpenTool;
import oracle.odi.sdk.opentools.OpenToolExecutionException;
import oracle.odi.sdk.opentools.OpenToolAbstract;
import oracle.odi.sdk.opentools.OpenToolParameter;

public class getLogCountFromDjLog extends OpenToolAbstract{
String DJLOGPATH;
String OUTFILEPATH;
private static final OpenToolParameter[] mParameters = new OpenToolParameter[]
{
new OpenToolParameter(“-DJLOGPATH”, “DJLOGPATH“, “DJ LOG PATH.”, true),
new OpenToolParameter(“-OUTFILEPATH”, “OUTFILEPATH“, “OUTPUT FILE PATH.”, true),
};
public getLogCountFromDjLog()
{
super();

}
public void execute() throws OpenToolExecutionException
{
try
{
this.DJLOGPATH = ((String)getParameterValue(“-DJLOGPATH“));
this.OUTFILEPATH = ((String)getParameterValue(“-OUTFILEPATH“));
getLog(DJLOGPATH,OUTFILEPATH);
}
catch (IllegalArgumentException e)
{
throw new OpenToolExecutionException(e);
}
catch (Exception e) {
throw new OpenToolExecutionException(e);
}
}


public static void getLog( String DJLOGPATH, String OUTFILEPATH){
…………………..
//your customized codes starts here based on the input
…………………..
………………….
……………….
………………..
}

public String getSyntax()
{
return “GetDJLogCount \”-DJLOGPATH=\” \”-OUTFILEPATH=\””;
}

/**
* Description of the Open Tool. This description is displayed when adding the Open Tool.
* @Returns A string containing the description.
*/
public String getDescription()
{
return “This ODI Open Tool is used to sending log count of DJ.”;
}
@Override
public String getIcon(int pIconType)
{
switch (pIconType)
{
case IOpenTool.SMALL_ICON:
return “com/bhabani/OdiTool/images/DJICON.jpg”;
case IOpenTool.BIG_ICON:
return “com/bhabani/OdiTool/images/DJICON.jpg”;
default:
return “”;
}
}
public String getVersion()
{
return “v1.0”;
}

/**
* Name of the provider of this Open Tool.
* @return A string containing ‘My Company, Inc.’
*/
public String getProvider()
{
return “Bhabaniranjan.com”;
}

/**
* Returns an array containing the parameters of this Open Tool.
* @return An array of two ISnpsOpenToolParameter objects.
*/
public OpenToolParameter[] getParameters()
{
return mParameters;
}
}

You just need to insert your customized java codes inside the function body. you create a jar file based on your class files and put it in odi client directory as well as driver directory. Then start odistudio.

Go to ODI menu and click on add/remove odiopentools..Click on the binocular button to open your class files under the package. Select the class file and click ok. Now click on the plus symbol to add the opentool. You can see the screenshot here.
odiopentool4
Once the opentool is added you can see this in the oditool box of package as given below.
odiopentool2
Just provide the values in the options and execute it. Very simple, powerful and of-course a great feature provided by ODI. Keep visiting for more tips and tricks and feel free to ask in case you got some questions.

0

About the author

Bhabani(http://dwteam.in) - Currently Bhabani is working as Sr Development Engineer at Harman International. He has good expertise on Oracle, Oracle Data Integrator, Pervasive Data Integrator, MSBI, Talend and Java. He is also contributing in ODI-OTN forum for last 5 years. He is from India. If you want to reach him then please visit contact us page. If you have any doubts or concerns on the above article, please put your question here. Dw Team will try to respond it as soon as possible. Also dont forget to provide your comments / suggestions / feedback for further improvement. Thanks for your time.

Similar Posts

14 comments

Just one word ‘WOW’. I know basics of java and I was searching for such codes where I can create my own opentool in odi. Thanks for the post and i will definitely try this one and if i face any problem i will disturb you again Bhabani. ๐Ÿ™‚

Hi Rajan,
how are you doing.I hope you are doing well.

I want to load multiple scenarios with parallel loading in packages . Can you post the process.

Thanks

Sure, I will put it ASAP.

There is something called load planner in the ODI 11g you can use it easily for parallel as well as consecutive execution.

hi bro..
h ru
well im facing one problem in odi..one of my procedure is failing everyday..in that procedure have some java code and i don’t have any idea about the java code..
can u tell me why its failing?
where should run this java code at outside of my odi.
thanks

Are you using any custom jar files or extra jar files for your cutsom java codes? If it is then put them in the local lib directory and restart agent,odi studio. Now you are good to go. Also let me know what java code you are using with the error message, so that i can better track the issue.
Thanks

Hi bhabani,
I took your valuable suggestion for my earlier problem, now Iโ€™m facing one more problem with topology , below things can explain you briefly,

I’m currently working on Renters project under CombinedDatastore

I need to access tables on Quebec server (database = HOUnderwriting, schema = Community) so I created Data Server ‘Community’

Now I also need some other tables from Quebec.HOUnderwriting, but in dbo.

I can create a new physical schema Community.HOUnderwriting.dbo, but I don’t know how to tie everyting together. That’s what I need your help with.

Tables needed Community schema Dbo schema
Community

Hi Bhabani,

Hru,hope u feeling good,
I have doubt, which is in geocode procedure. If I run the geocode in production itโ€™s failing and giving this error:
org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File “”, line 577, in
TypeError: ReportError() takes exactly 3 arguments (2 given)
And same code if I run development itโ€™s giving this error:
org.apache.bsf.BSFException: exception from Jython:
Traceback (most recent call last):
File “”, line 82, in
IOError: (13, ‘EACCES’, ‘c:/bulkfiles/GEOCODES-2013-08-28_03-31-44’)
Development and production code is same but why these errors are different. Not able to understand. Please try to advise me a solution.

Hi Guru,

Now I’m getting a problem.
ODI-1228: Task Copy of NOLDriver (Integration) fails on the target MICROSOFT_SQL_SERVER connection USEREDWProd.
Caused By: com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part identifier “NDR.QUOTE_#” could not be bound.
what is this multi part identifer ,why im getting this,what should i do for resoulation
Any idea…

Hi I have made a open tool on same lines. the code is working perfectly in studio. I have made a j2ee agent and am trying to call the scenario using the agent can u please let me know the procedure to do it.

I am able to deploy the agent and call the scenario where I have used by the ODI built in components but am facing problems where I am using my custom open tool. can u please let me know where should I place my jars for the j2ee agent?

You have to place the jar files in Middleware_Home\user_projects\domains\base_domain\lib location and then restart your ee agent to pick up the driver

import oracle.odi.sdk.opentools.IOpenTool;
import oracle.odi.sdk.opentools.OpenToolExecutionException;
import oracle.odi.sdk.opentools.OpenToolAbstract;
import oracle.odi.sdk.opentools.OpenToolParameter;

public class getLogCountFromDjLog extends OpenToolAbstract {
String DJLOGPATH;
String OUTFILEPATH;
private static final OpenToolParameter[] mParameters = new OpenToolParameter[] {
new OpenToolParameter(“-DJLOGPATH”, “DJLOGPATH”, “DJ LOG PATH.”,
true),
new OpenToolParameter(“-OUTFILEPATH”, “OUTFILEPATH”,
“OUTPUT FILE PATH.”, true), };

public getLogCountFromDjLog() {
super();

}

public void execute() throws OpenToolExecutionException {
try {
this.DJLOGPATH = ((String) getParameterValue(“-DJLOGPATH”));
this.OUTFILEPATH = ((String) getParameterValue(“-OUTFILEPATH”));
getLog(DJLOGPATH, OUTFILEPATH);
} catch (IllegalArgumentException e) {
throw new OpenToolExecutionException(e);
} catch (Exception e) {
throw new OpenToolExecutionException(e);
}
}

public static void getLog(String DJLOGPATH, String OUTFILEPATH) {

// your customized codes starts here based on the input

}

public String getSyntax() {
return “GetDJLogCount \”-DJLOGPATH=\” \”-OUTFILEPATH=\””;
}

/**
* Description of the Open Tool. This description is displayed when adding
* the Open Tool.
*
* @Returns A string containing the description.
*/
public String getDescription() {
return “This ODI Open Tool is used to sending log count of DJ.”;
}

@Override
public String getIcon(int pIconType) {
switch (pIconType) {
case IOpenTool.SMALL_ICON:
return “com/bhabani/OdiTool/images/DJICON.jpg”;
case IOpenTool.BIG_ICON:
return “com/bhabani/OdiTool/images/DJICON.jpg”;
default:
return “”;
}
}

public String getVersion()
{
return “v1.0”;
}

/**
* Name of the provider of this Open Tool.
*
* @return A string containing โ€˜My Company, Inc.โ€™
*/
public String getProvider() {
return “Bhabaniranjan.com”;
}

/**
* Returns an array containing the parameters of this Open Tool.
*
* @return An array of two ISnpsOpenToolParameter objects.
*/
public OpenToolParameter[] getParameters() {
return mParameters;
}
}

Hi Guys,
I created one java jar file. this file is placed in odi server as well as local. after that i executed in odi through procedure technology (Jython) its working in local only(means local agent), but not working in server(ODIAgent)(job is success) but i did not get any output values. job is success i am getting the output as file.can you please guide me what is the issues.

Leave a replay to Tashia Cancel reply

required*

Are you a human? *