Disable/Enable Odi Loadplan Step using SDK

Disable/Enable Odi Loadplan Step using SDK:

This post is based on theĀ request raised on OTN. I know it took a few days to post it here and I apologize for that. Its all because of lack of time.

Let’s take a look on the following code snippet. It is not that difficult if you have fair knowledge on core java programming. Initially I didn’t find a way to select the substep as parent step as I was trying to get all of its children steps using getChildren() method. But finally I found the trick and it was just a type cast.

import java.util.List;

import oracle.odi.core.OdiInstance;
import oracle.odi.core.config.MasterRepositoryDbInfo;
import oracle.odi.core.config.OdiInstanceConfig;
import oracle.odi.core.config.PoolingAttributes;
import oracle.odi.core.config.WorkRepositoryDbInfo;
import oracle.odi.core.persistence.transaction.ITransactionStatus;
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition;
import oracle.odi.core.security.Authentication;
import oracle.odi.domain.runtime.loadplan.OdiLoadPlan;
import oracle.odi.domain.runtime.loadplan.OdiLoadPlanStep;
import oracle.odi.domain.runtime.loadplan.OdiLoadPlanStepContainer;
import oracle.odi.domain.runtime.loadplan.OdiLoadPlanStepSerial;
import oracle.odi.domain.runtime.loadplan.finder.IOdiLoadPlanFinder;

public class ScenSchedule {
public static void main(String[] args) {
String Url = "jdbc:oracle:thin:@localhost:1521:xe";
String Driver="oracle.jdbc.OracleDriver";
String Master_User="ODI_MASTER_OLD";
String Master_Pass="odi";
String WorkRep="WORKREP651";
String Odi_User="SUPERVISOR";
String Odi_Pass="SUNOPSIS";

MasterRepositoryDbInfo masterInfo = new MasterRepositoryDbInfo(Url, Driver, Master_User,Master_Pass.toCharArray(), new PoolingAttributes());
WorkRepositoryDbInfo workInfo = new WorkRepositoryDbInfo(WorkRep, new PoolingAttributes());
OdiInstance odiInstance=OdiInstance.createInstance(new OdiInstanceConfig(masterInfo,workInfo));
Authentication auth = odiInstance.getSecurityManager().createAuthentication(Odi_User,Odi_Pass.toCharArray());
odiInstance.getSecurityManager().setCurrentThreadAuthentication(auth);
ITransactionStatus trans = odiInstance.getTransactionManager().getTransaction(new DefaultTransactionDefinition());

OdiLoadPlan odilplan= ((IOdiLoadPlanFinder) odiInstance.getTransactionalEntityManager().getFinder(OdiLoadPlan.class)).findByName("TESTLOADPLAN");
OdiLoadPlanStepSerial olpss=odilplan.getRootStep();
List<OdiLoadPlanStep> olpchild= olpss.getChildrenSteps();

for (int i = 0; i < olpchild.size(); i++) {
System.out.println("Prniting hierarchy " +i+"\n");
OdiLoadPlanStep olps= olpchild.get(i);
<strong>OdiLoadPlanStepContainer olpsc= (OdiLoadPlanStepContainer)olps;</strong>
List&lt;OdiLoadPlanStep&gt; olpscchild=olpsc.getChildrenSteps();
System.out.println("Printing steps under above hirarchy \n");
for (int j = 0; j &lt; olpscchild.size(); j++) {
System.out.println(olpscchild.get(j).getName());
<strong>//based on the hierarchy and children you can disable any of the steps.</strong>
<strong>olpscchild.get(0).setEnabled(false);</strong>
}
}

try{
odiInstance.getTransactionalEntityManager().persist(odilplan);
odiInstance.getTransactionManager().commit(trans);
System.out.println("Loadplan Updated Successfully");
}
finally
{
if (odiInstance != null)
{
odiInstance.getSecurityManager().clearCurrentThreadAuthentication();

if (auth != null) {
auth.close();
}
odiInstance.close();
}
}
}
}

loadplan_console

As you can see the ODISQLUNLOAD has been unchecked.

loadplan

Let me know if you find any other workaround.

Thanks guys!!

0

About the author

Bhabani(http://dwteam.in) - Currently Bhabani is working as Sr Development Engineer at Harman International. He has good expertise on Oracle, Oracle Data Integrator, Pervasive Data Integrator, MSBI, Talend and Java. He is also contributing in ODI-OTN forum for last 5 years. He is from India. If you want to reach him then please visit contact us page. If you have any doubts or concerns on the above article, please put your question here. Dw Team will try to respond it as soon as possible. Also dont forget to provide your comments / suggestions / feedback for further improvement. Thanks for your time.

Similar Posts

1 comments

Thanks for great post Bhabani. I am struggling to find info to invoke Console so that I can see my println output. I need to debug some groovy code in ODI studio. Could you shed some light into it please ?

Thanks for your help.

Leave a reply

required*

Are you a human? *