In the previous blogs such as the one here I illustrated how to use the SDK to perform interface creation using various auto mapping options for generating 1:1 interfaces either using positional based matching, like names ignoring case and so on. Here we will see another example (download OdiInterfaceBuilder.java) showing a different aspect using a control file which describes the interface in simple primitives which drives the creation. The example uses a tab delimited text file to control the interface creation, but it could be easily taken and changed to drive from Excel, XML or whatever you wanted to capture the design of the interface.
The interface can be as complete or incomplete as you’d like, so could just contain the objects or could be concise and semantically complete.
The control file is VERY simple and just like ODI requests the minimal amount of information required. The basic format is as follows;
Directive | Column 2 | Column 3 | Column 4 | Column 5 |
source | <model> | <datastore> | ||
can add many | ||||
target | <model> | <datastore> | ||
mapping | <column> | <expression> | ||
can add many | ||||
join | <expression> | |||
can add many | ||||
filter | <expression> | |||
can repeat many | ||||
lookup | <model> | <datastore> | <alias> | <expression> |
can add many |
So for example the control file below can define the sources, target, joins, mapping expressions etc;
source SCOTT EMP
source SCOTT DEPT
target STG_MODEL_CASE TGTEMP
mapping ENAME UPPER(EMP.ENAME)
mapping DNAME UPPER(DEPT.DNAME)
mapping DEPTNO ABS(EMP.EMPNO)
join EMP.DEPTNO = DEPT.DEPTNO
lookup SCOTT BONUS BONUS BONUS.ENAME = EMP.ENAME
filter EMP.SAL > 1
mapping COMM ABS(BONUS.COMM)
When executed, this generates the interface below with the join, filter, lookup and target expressions from the file.
Image may be NSFW.
Clik here to view.
You should be able to join the dots between the control file sample and the interface design above.
So just like the initial post you will compile and execute the code, but use the different classname OdiInterfaceBuilder;
java –classpath <cp> OdinterfaceBuilder jdbc:oracle:thin:@localhost:1521:ora112 oracle.jdbc.OracleDriver ODI_MASTER mypwd WORKREP1 SUPERVISOR myodipwd STARTERS SDK DEMO1 <myinterfacecontrolfile.tab
The interface to be created is passed from the command line. You can intersperse other documentation lines between the control lines so long as the control keywords in first column don’t clash.
Image may be NSFW.
Clik here to view.
Anyway some useful snippets of code for those learning the SDK, or for those wanting to capture the design outside and generate ODI Interfaces. Have fun!