Dylan's BI Study Notes

My notes about Business Intelligence, Data Warehousing, OLAP, and Master Data Management

ODI SDK: Create a Subfolder

This page includes a program to create a subfolder under an existing project and an existing folder.

import oracle.odi.core.persistence.transaction.ITransactionDefinition;
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition;
import oracle.odi.core.persistence.transaction.ITransactionManager;
import oracle.odi.core.persistence.transaction.ITransactionStatus;
import oracle.odi.core.persistence.IOdiEntityManager;
import oracle.odi.domain.project.OdiProject;
import oracle.odi.domain.project.OdiFolder;
import oracle.odi.domain.project.finder.IOdiProjectFinder;
import oracle.odi.domain.project.finder.IOdiFolderFinder;

ITransactionDefinition txnDef = new DefaultTransactionDefinition();

ITransactionManager tm = odiInstance.getTransactionManager();
ITransactionStatus txnStatus = tm.getTransaction(txnDef);

IOdiEntityManager mgr = odiInstance.getTransactionalEntityManager();

OdiProject proj = ((IOdiProjectFinder) mgr.getFinder(OdiProject.class))
.findByCode("NEW_PROJECT");
Collection<OdiFolder> folders = ((IOdiFolderFinder) mgr.getFinder(OdiFolder.class))
.findByName("Test Folder", proj.getCode());
OdiFolder topFolder = folders.iterator().next();

OdiFolder myFolder1 = new OdiFolder(topFolder,"Test Sub-Folder");

odiInstance.getTransactionalEntityManager().persist(proj);

tm.commit(txnStatus);

 

A folder is created under a project, so before you get the folder, you need to get the project.

I got the project by the project code, and got the the folder by folder name.  Both are working.

The difference is that a project can have multiple folders and they can have the same name.  To get a single folder, we can use the iteractor to go through it one by one.

One Response to “ODI SDK: Create a Subfolder”

  1. […] tried to use ODI SDK to create a project, create a folder, create a subfolder, create a short to an interface, create a variable, and update a […]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s