Tuesday Aug 06, 2013

ODI - Accelerator Launchpad, getting Groovy

To organize your groovy scripts and package up utilities there are various approaches to take. This one will exploit a little known fact in the groovy studio support. The code executed has some contextual variables available that you may be aware of - such as the odiInstance variable which represents a handle to the repository in the SDK. There is also another contextual variable which is 'this', this happens to be the groovy shell reference, which is very useful to execute other scripts from. For example the command below if executed will execute the groovy script from the filesystem from my script when executed. 

this.evaluate(new File("d:\\accelerators\odi_create_model.groovy"))

 This is a useful approach if you want to execute your scripts from a launchpad, or quick start/accelerator control. The image below shows a launchpad with buttons for various activities, one of which is the create model accelerator groovy script I created (this was blogged here).

When the '1. Create Model' button is pressed, the groovy script to execute the create model groovy is executed. This can do whatever you want, below is what my groovy script does to create a model;

Each button in the accelerator launchpad is defined as below, the script representing the action is evaluated when the button is pressed, its quite straightforward; 

  1.         button(action: action(name: '1. Create Model', closure: {
  2.           gshell.evaluate(new File("d:\\accelerators\odi_create_model.groovy"))
  3.         })

 You can quite easily invoke your companies specific accelerator routines with this approach.

Here is the full script...

  1. import groovy.swing.SwingBuilder
  2. import java.awt.FlowLayout as FL
  3. import javax.swing.BoxLayout as BXL

  4. def startLaunchPad() {
  5.   def s = new SwingBuilder()
  6.   s.setVariable('myDialog-properties',[:]) 
  7.   def vars = s.variables 
  8.   def dial = s.dialog(title:'ODI Accelerator Launchpad',id:'myDialog',modal:true) { 
  9.   def gshell = this
  10.   panel() {
  11.     flowLayout(alignment:FL.RIGHT)
  12.     label(icon:imageIcon(url:new java.net.URL('file:///d|/accelerators/images/odi_launchpad.jpg')))

  13.     panel() {
  14.         boxLayout(axis:BXL.Y_AXIS)
  15.         panel(alignmentX:0f) {
  16.             flowLayout(alignment:FL.CENTER)
  17.         button(action: action(name: '1. Create Model', closure: {
  18.           gshell.evaluate(new File("d:\\ accelerators\odi_create_model.groovy"))
  19.         }))
  20.         }
  21.         panel(alignmentX:0f) {
  22.             flowLayout(alignment:FL.CENTER)
  23.         button(action: action(name: '2.         ..........', closure: {
  24.           gshell.evaluate(new File("d:\\ accelerators\anotherscript.groovy"))
  25.         }))
  26.         }
  27.         panel(alignmentX:0f) {
  28.             flowLayout(alignment:FL.CENTER)
  29.         button(action: action(name: '3.         ..........', closure: {
  30.           gshell.evaluate(new File("d:\\ accelerators\yetanotherone.groovy"))
  31.         }))
  32.         }
  33.         panel(alignmentX:0f) {
  34.             flowLayout(alignment:FL.LEFT)
  35.             button('OK',preferredSize:[80,24],
  36.                    actionPerformed:{
  37.                        vars.dialogResult = 'OK' 
  38.                        dispose()
  39.             })
  40.             button('Cancel',preferredSize:[80,24],
  41.                    actionPerformed:{
  42.                        vars.dialogResult = 'cancel'
  43.                        dispose()
  44.             })
  45.         }
  46.     }
  47. }  }
  48.   dial.pack()
  49.   dial.show()
  50.   return vars
  51. }

  52. vars= startLaunchPad()

The SwingBuilder framework is quite simple and lets you build up these kind of wrapper interfaces very simply.

Friday May 10, 2013

ODI 11g – XML Model Expert Accelerator

The blog post here provided a model creation accelerator for relational oriented technologies, I have uploaded another one for XML oriented data. The expert can be found on the java.net site here.

This expert greatly simplifies getting up and running with XML in ODI, well I think so anyway. It asks the basic questions, whats the file name... then allows additional configuration if you want. You can skip advanced and external database storage and you will have a model with the topology objects built, you can get right into reverse engineering the datastores.

The tool tips come straight from the ODI documentation.

If the advanced option was selected, after pressing OK above, you will be shown some common advanced properties, you can change these and these will be used when building the URL for the XML data server (see full doc here). The actual root element in your document will be displayed in the root element entry.

The external database dialog has details of the relational system you wish to use. This has the basic properties, there are lots more potential configuration options, my goal here is to illustrate the expert which will get you up and running. Enter the ODI encoded password.

Once you have done this you can reverse your model....very simple! 

The expert is written in groovy using the ODI SDK and SwingBuilder which is very simple to use for creating these types of accelerators, let us know what you think.

Saturday May 21, 2011

Extending the Interface Accelerator

Carrying on the automate, automate theme, here’s an illustration of some really useful capabilities using the ODI 11g SDK which make it more powerful, carrying on from the post on the simple accelerator that I posted here. In this posting I had a simple control file that mapped some table to some other table that were defined in in the control file. The auto mapping as-in the ODI UI itself matches on exact names of columns.

What if we want to do something a little different and automate? For example say some standard suffixes or prefixes have been added to the column names what can we do? With the previous posting no columns will be mapped. This was because I used the auto mapping provided out of the box (see the following line in the interfaceAccelerator.java file from the post mentioned;

interactiveHelper.performAction(new InterfaceActionSetTargetDataStore(targetDatastore, new MappingMatchPolicyLazy(), new AutoMappingComputerLazy(), new AutoMappingComputerLazy(), new TargetKeyChooserPrimaryKey()));

Here is where we can refine this by specializing the auto mapping class that ODI provides, I will create one called MyRegexpAutoMappingComputer.java this class will refine the method performAutoMapping which will construct the mapping for a target column – it can even call the super classes method and reuse the default exact name matching if needed.

interactiveHelper.performAction( new InterfaceActionSetTargetDataStore(targetDatastore, new MappingMatchPolicyLazy(), new MyRegexpAutoMappingComputer( MyRegexpAutoMappingComputer.MatchTypes.TGTENDSWITH), new MyRegexpAutoMappingComputer( MyRegexpAutoMappingComputer.MatchTypes.TGTENDSWITH), new TargetKeyChooserPrimaryKey()));

You can see in the above call I now use a new auto mapping class and pass in the TGTENDSWITH enumeration to do matching (so a source call named EMPNO will match with a target name of STG_EMPNO). The new files are available here;

The class could be enhanced to support more complex stuff, hopefully you see how this works and an insight into how you can extend the SDK provided and add even more value.

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
« July 2014
SunMonTueWedThuFriSat
  
4
5
6
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today