ODI Experts

The blog for Oracle Data Integrator

Generate All Scenario for a Particular Project using ODI SDK

Hi Friends!

First of all HAPPY NEW YEAR!

We, from ODI Experts, hope that 2012 be a fantastic year for all of you!

Continuing our “Java code series” take a look on this new one.

The below code is used to Generate/Regenerate  All Scenario and depending on the options the appropriate ODI Objects scenario will be generated/regenerated.

Also make sure you use the appropriate Generating option  i.e INCREMENTAL_MODE (OR)  REGENERATE_MODE (OR)   REPLACE_MODE

GenerationOptions options=new GenerationOptions(GenerationOptions.INCREMENTAL_MODE, GenerateFromPackage, GenerateFromInterface, GenerateFromProcedure, GenerateFromVariable);

package odi.sdk;

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.project.OdiFolder;
import oracle.odi.domain.project.OdiProject;
import oracle.odi.domain.project.finder.IOdiProjectFinder;
import oracle.odi.domain.runtime.scenario.OdiScenario;
import oracle.odi.generation.GenerationOptions;
import oracle.odi.generation.support.OdiScenarioGeneratorImpl;
import oracle.odi.impexp.EncodingOptions;
import oracle.odi.impexp.support.ExportServiceImpl;

public class RegenrateAllScen {

    private static String Project_Code;
    private static OdiProject project;
    private static String   Folder_Name;
    private static OdiFolder folder;

    /**
     * @param args
     */
    public static void main(String[] args) {

         /****** Please change these Parameters *********/

        /** Development Repository ****/    

         String Url = "jdbc:oracle:thin:@localhost:1521:xe";
         String Driver="oracle.jdbc.OracleDriver";
         String Master_User="ODI_MASTER_11G";
         String Master_Pass="ODI_MASTER_11G";
         String WorkRep="WORKREP1";
         String Odi_User="SUPERVISOR";
         String Odi_Pass="SUNOPSIS";

      // Generating ODI Objects options

         Boolean GenerateFromInterface     = true;
         Boolean GenerateFromPackage       = true;
         Boolean GenerateFromProcedure     = true;
         Boolean GenerateFromVariable      = true;

         Project_Code   ="XMT";

         /********************************************/

 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());

//Regenerating All Scenario by Project
// Get Project
project = ((IOdiProjectFinder) odiInstance.getTransactionalEntityManager().getFinder(OdiProject.class)).findByCode(Project_Code);

OdiScenarioGeneratorImpl generatescen=new OdiScenarioGeneratorImpl(odiInstance);
//
// Please change your Generating Option ie INCREMENTAL (or) REGENERATE (or) REPLACE
//
GenerationOptions options=new GenerationOptions(GenerationOptions.INCREMENTAL_MODE, GenerateFromPackage, GenerateFromInterface, GenerateFromProcedure, GenerateFromVariable);
OdiScenario[] scen =generatescen.generateAllScenarios(project, options);
for (OdiScenario odiScenario : scen) {
    System.out.println( options.getMode()+" Generating Scenario  " +odiScenario.getName()+"\t"+odiScenario.getVersion());
}

odiInstance.getTransactionManager().commit(trans);
System.out.println("Commiting Changes \n Process Completed");
odiInstance.close();

    }

}

Keep visiting us!

Author: Kshitiz Devendra

ODI Experts Admin and Co-Author .He enjoys programming espcially Java/Jython based applications, some of which have been used in scientific research areas for analyzing Next Generation Sequencing data. He has also recently written ODI JDBC EXCEL and ODI JDBC ACCESS. You can reach him at kdevendr@gmail.com

5 Comments

  1. How to enable the check box “Generate Scenario as if all underlying objects are Materialized” while creating the scenario using ODI SDK…

    code to which we are using is not enabling this check-box.

    import oracle.odi.generation.OdiScenarioGeneratorException;
    import oracle.odi.generation.support.OdiScenarioGeneratorImpl;

    OdiScenarioGeneratorImpl generatescen = new OdiScenarioGeneratorImpl(odiInstance);
    OdiScenario odiScenario = generatescen.generateScenario(shortcutPackage, scenarioName.toUpperCase(), “01″);

    need your inputs !!

    thanks
    prasanna

  2. I think this is among the most vital information
    for me. And i am glad reading your article. But want to remark on few general things, The site style is great,
    the articles is really great : D. Good job, cheers

  3. Check with your DBA if they can catch the reason else drop and recreate the DBlinks and see if that helps.

  4. Hi Kshitiz,

    I am facing quite a strange problem in ODI11.1.1.5 version.

    Very recently the backend db was upgraded to a new Oracle DB Patch:11.2.0.3.2.
    Few of my ODI Jobs has DB Links (LKMs). Now, When I execute them sometimes the Jobs are failing (frequently) and sometimes they are just passing fine(very rarely).
    ALL the Jobs were running absolutely fine in the previous Oracle DB version

    Error: TNS could not resolve the identifier

    I had done lot of modulations:
    1. TNS names now point to the new Oracle Home
    2. I had ckecked the Host file and its fine, as well
    3. The TNSnames.ora is fine with all the server informations
    4. I had created an agent, as well with the new Server details so that my new agent points to the new server…

    One thing I donot get is: why would the jobs fail and pass frequently..! There’s no consistency at all… Failure is though quite often..!!
    Is there a cause that we have some ODI system registry which has both the Old and new DB infos so ODI is behaving randomly…? Or is there is a solution to this..?

    Any input is greatly appreciated..!!
    Thanks!

    - Shib

Leave a Reply

Required fields are marked *.