ODI 11g - Scripting a Reverse Engineer
- by David Allan
A common question is related to how to script the reverse engineer using the ODI SDK. This follows on from some of my posts on scripting in general and accelerated model and topology setup.
Check out this viewlet here to see how to define a reverse engineering process using ODI's package.
Using the ODI SDK, you can script this up using the OdiPackage and StepOdiCommand classes as follows;
OdiPackage pkg = new OdiPackage(folder, "Pkg_Rev"+modName);
StepOdiCommand step1 = new StepOdiCommand(pkg,"step1_cmd_reset");
step1.setCommandExpression(new Expression("OdiReverseResetTable \"-MODEL="+mod.getModelId()+"\"",null, Expression.SqlGroupType.NONE));
StepOdiCommand step2 = new StepOdiCommand(pkg,"step2_cmd_reset");
step2.setCommandExpression(new Expression("OdiReverseGetMetaData \"-MODEL="+mod.getModelId()+"\"",null, Expression.SqlGroupType.NONE));
StepOdiCommand step3 = new StepOdiCommand(pkg,"step3_cmd_reset");
step3.setCommandExpression(new Expression("OdiReverseSetMetaData \"-MODEL="+mod.getModelId()+"\"",null, Expression.SqlGroupType.NONE));
pkg.setFirstStep(step1);
step1.setNextStepAfterSuccess(step2);
step2.setNextStepAfterSuccess(step3);
The biggest leap of faith for users is getting to know which SDK classes have to be used to build the objects in the design, using StepOdiCommand isn't necessarily obvious, once you see it in action though it is very simple to use. The above snippet uses an OdiModel variable named mod, its a snippet I added to the accelerated model creation script in the post linked above.