ODI SDK: Leveraging ODI Tools with Groovy

In a previous post, Uli Bethke asked if it would be possible to leverage ODI Tools using Groovy.

It turns out that yes, you can do so by combining Groovy and the SDK: dynamically build a package that contains the tools, and execute the code - all in one shot.

The key elements in the code are:

  • Create an empty package
  • Add a step to the package and name that step 
  • Add code for that step
  • Generate a scenario from the package
  • Execute the scenario

You can find a procedure (generated with ODI 11.1.15) with the code here.

The text of the code is available here if you ever have issues with the procedure.

(Note: some people seem to have a hard time when they click on the links to view the procedure or the code. This seems to be browser dependent. In that case do a "right-click" on the link and select "save as..." to make a local copy)

Comments:

hi,
i can not see the procedure ; there is only "null null null null null null null null null null null null null null null null null null null null null null null null null" when i click on "here" button.
Please help..

Posted by icz_cube on September 08, 2011 at 12:48 AM PDT #

Hi Christophe,

Its really helpful for me.I tried in eclipse and its working absolutely fine.But i have one doubt about StartupParameter. I want to pass one external java variable value to odi scenario during invocation. How can i achieve this.Please suggest.

Thanks

Ashok

Posted by Ashok on February 15, 2012 at 09:21 AM PST #

hicz_cube,

Try and right-click on the link to save the XML file locally - or follow the link for the code and create your own procedure by copying the text (remember to set the technology to Groovy in that case). Either approach should work.

-Christophe

Posted by Christophe Dupupet on February 15, 2012 at 03:21 PM PST #

Ashok,

The first thing to keep in mind is that when you pass a parameter to a scenario, you need to pass the name of the ODI that will receive the value along with the value itself. In your scenario, you have to make sure that the variable is declared in the very first steps to retrieve the value of the parameter.

Now from a coding perspective, there are two possible approaches:
1. StartupParameter has two constructors, one with no parameters, the other one with a map of variable name/value pairs:
public StartupParameters(java.util.Map<java.lang.String,java.lang.String> pParameters)

2. Take advantage of the StartupParametersBuilder helper:
- create a new StartupParameterBuilder
- then use setDate, setLong or setString to define the value of yor parameters, and toStartupParameter to retrieve the StartupParameter that you have built.

I hope this helps!
-Christophe

Posted by guest on February 15, 2012 at 03:28 PM PST #

I didnot get " you need to pass the name of the ODI that will receive the value along with the value itself."

Its better to use StartupParameterBuilder. But i am unable to convert StartupParameters to StartupParams since invokeStartScenario taking only StartupParams as below format

invokeStartScenario(String, String, StartupParams, String, String, Integer, String, boolean, String)

I tried below code but its not inserting any rows.If i am putting null in place of StaupParams its inserting a row.What wrong

String TEST_VARIABLE2="TEST_VARIABLE2";
Map<String, String> map = new HashMap<String, String>();
map.put(TEST_VARIABLE2, "99");
StartupParams sp=new StartupParams(map);
agent.invokeStartScenario("PKG_SCOTT", "001", sp, "", "GLOBAL", 5, "PKG_SCOTT", true, "ODI_WORK");
Here TEST_VARIABLE2 is the ODI variable in declare mode inside my scenario.

Posted by Ashok on February 16, 2012 at 02:14 AM PST #

That great Christophe,

Now its working. I used StaupParams. But i didnt get how to convert StaupParameters to StaupParams.

Thanks a ton.

Posted by Ashok on February 16, 2012 at 02:32 AM PST #

Hi,
It seems to be an error in the line

System.err.println("Error: cannot find folder "+folder+" in project "+project);

Property "project" is not defined.

Posted by Sek on February 28, 2012 at 04:48 AM PST #

Good catch indeed - the code for the error message should be:
System.err.println("Error: cannot find folder "+folder+" in project "+projectCode);

The fact that went down this part of the code indicates that the folder name that you used was not found in your project though. Rememeber to change that!

-Christophe

Posted by Christophe Dupupet on February 28, 2012 at 07:08 AM PST #

To Ashok: should have been: "the name of the ODI *variable* that will receive the value"

Posted by Christophe Dupupet on February 28, 2012 at 07:12 AM PST #

Hi Christophe.

How to get the log details of scenario inside SDK.I am trying to implement OdiStepReport but still no lock. Can you please suggest.
Thanks.

Posted by Ashok on March 21, 2012 at 02:47 AM PDT #

Ashok,

I have tried to build a quick example with OdiStepReport. The details are available here: https://blogs.oracle.com/dataintegration/entry/odi_sdk_retrieving_information_from
My best

-Christophe

Posted by Christophe on April 02, 2012 at 10:25 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Learn the latest trends, use cases, product updates, and customer success examples for Oracle's data integration products-- including Oracle Data Integrator, Oracle GoldenGate and Oracle Enterprise Data Quality

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
3
5
6
7
8
9
10
12
13
14
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today