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);
OdiLoadPlanStepContainer olpsc= (OdiLoadPlanStepContainer)olps;
List<OdiLoadPlanStep> olpscchild=olpsc.getChildrenSteps();
System.out.println("Printing steps under above hirarchy \n");
for (int j = 0; j < olpscchild.size(); j++) {
System.out.println(olpscchild.get(j).getName());
//based on the hierarchy and children you can disable any of the steps.
olpscchild.get(0).setEnabled(false);
}
}

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!!

About Bhabani 86 Articles
Bhabani has 10 plus years of experience in Data warehousing and Analytics projects that has span across multiple domains like Travel, Banking and Financial, Betting and Gaming Industries. Solution areas he focuses on designing the data warehouse and integrating it with cloud platforms like AWS or GCP. He is also a Elite level contributor at OTN forum more than 9 years. He loves to do experiment and POC on different integration tools and services. Some of his favorite skills are Redshift, Big Query, Python, Apache Airflow, Kafka, HDFS, Map Reduce ,HIVE, Habse, Sqoop, Drill, Impala.

2 Comments

  1. 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

Your email address will not be published.


*