Import object in Odi 12c using ODI SDK

2.3k views Asked by At

I' m trying to automate the import of mappings (XML) in ODI 12c, using a Groovy script and the ODI SDK. But my code just keeps running without any result. Here's is my code.

txnDef = new DefaultTransactionDefinition()
tm = odiInstance.getTransactionManager()
tme = odiInstance.getTransactionalEntityManager()
txnStatus = tm.getTransaction(txnDef)
ImportServiceImpl importSrv = new ImportServiceImpl(odiInstance);
importSrv.importObjectFromXml(importSrv.IMPORT_MODE_SYNONYM_INSERT, filename, parentObj, true, null, true);
tm.commit(txnStatus)

The code runs for indefinite amount of time until I manually terminate the program. I don't understand what is the problem. Link to javadoc: https://docs.oracle.com/middleware/1213/odi/reference-java-api/oracle/odi/impexp/IImportService.html#importObjectFromXml(int,%20java.lang.String,%20boolean,%20char[],%20boolean)

And also, I don't understand the fourth parameter in the method

void importObjectFromXml(int pImportMode,
                   java.lang.String pFileName,
                   IImportRoot pObjectParent,
                   boolean pDeclareMissingRepository,
                   char[] pExportKey,
                   boolean pImportWithoutCipherData)
                     throws OdiImportNotSupportedException,
                            OdiImportException,
                            java.io.IOException

I tried using both true and false for pDeclareMissingRepository but none works. Please help, if I'm missing something.

Thanks.

1

There are 1 answers

2
JeromeFr On BEST ANSWER

You should use importObjectFromXml instead of importFromXml which is specific to SmartImport.

Try with importSrv.importObjectFromXml(IImportService.IMPORT_MODE_SYNONYM_INSERT, filename, parentObj, true, null, true)

The pDeclareMissingRepository is linked to the way objects were identified in 11g, with an internal ID and a repository ID. When importing it would check if it could recognize the repository ID from where the object is exported. I don't think it's used anymore but for your usage you can safely leave the value to true.