我使用groovy脚本创建了数千个映射,但我无法运行它们。
我可以迭代映射但现在想要使用groovy脚本运行映射。 如何创建映射方案然后运行方案 使用groovy脚本?
答案 0 :(得分:3)
//Created by DI Studio
//Created by DI Studio
//Created by DI Studio
//Created by DI Studio
//Created by DI Studio
//Created by DI Studio
//Created by DI Studio
import oracle.odi.domain.project.finder.IOdiProjectFinder;
import oracle.odi.domain.model.finder.IOdiDataStoreFinder;
import oracle.odi.domain.project.finder.IOdiFolderFinder;
import oracle.odi.domain.mapping.finder.IMappingFinder;
import oracle.odi.domain.model.OdiDataStore;
import oracle.odi.domain.model.OdiModel;
import oracle.odi.domain.model.finder.IOdiModelFinder;
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition;
import oracle.odi.generation.support.OdiScenarioGeneratorImpl;
import oracle.odi.generation.IOdiScenarioGenerator;
import oracle.odi.domain.runtime.scenario.OdiScenario;
import oracle.odi.domain.mapping.Mapping;
import oracle.odi.domain.mapping.finder.IMappingFinder;
import oracle.odi.domain.runtime.scenario.finder.IOdiScenarioFinder;
import oracle.odi.domain.project.OdiProject;
//txnDef = new DefaultTransactionDefinition()
//tm = odiInstance.getTransactionManager()
//tme = odiInstance.getTransactionalEntityManager()
//txnStatus = tm.getTransaction(txnDef)
//pf = (IOdiProjectFinder)tme.getFinder(OdiProject.class)
//ff = (IOdiFolderFinder)tme.getFinder(OdiFolder.class)
//Variables
//projectName = "Project Name"
//folderName = "Folder Name"
//sourcemodelName = "Source Name"
//targetmodelName = "Target name"
//find project and the folder
/*
def mappingList = ((IMappingFinder) odiInstance.getTransactionalEntityManager().getFinder(Mapping.class)).findByProject("STOO3", "STO3")
ms=mapplingList.iterator()
while(ms.hasNext()){
println ms.getName()
}
*/
txnDef = new DefaultTransactionDefinition()
tm = odiInstance.getTransactionManager()
tme = odiInstance.getTransactionalEntityManager()
txnStatus = tm.getTransaction(txnDef)
def fm = ((IMappingFinder) tme.getFinder(Mapping.class)) // shorcut to Find Mapping
def mappingList = fm.findAll().findAll{w -> w.getProject().getCode() == 'CUSTDBN'}
//def mappingList = ((IMappingFinder) odiInstance.getTransactionalEntityManager().getFinder(Mapping.class)).findByProject("SOCAIRO", "STO")
if (mappingList == null){
println "Map is null"
}
ms=mappingList.iterator()
while(ms.hasNext()){
ms_i = ms.next()
println ms_i.getName()
scenName = ms_i.getName();
//IIOdiScenarioGenerator gene = new OdiScenarioGeneratorImpl((odiInstance)
//OdiScenario newScen = gene.generateScenario(ms_i, scenName,newVersion)}
//odiInstance.getTransactionalEntityManager().persist(ms_i);
//OdiScenarioGenerator gene = new OdiScenarioGeneratorImpl((odiInstance)
//gene.generateScenario(ms_i, scenName,"001")
stxnDef = new DefaultTransactionDefinition()
stm = odiInstance.getTransactionManager()
stme = odiInstance.getTransactionalEntityManager()
stxnStatus = stm.getTransaction(stxnDef)
OdiScenario sc = ((IOdiScenarioFinder) stme.getFinder(OdiScenario.class)).findLatestByName(scenName)
if (sc != null){
println "Scenario already exist"
println sc
}
IOdiScenarioGenerator gene = new OdiScenarioGeneratorImpl(odiInstance);
OdiScenario newScen = gene.generateScenario(ms_i, scenName, "001")
println newScen
//tme.persist(newScen)
stm.commit(stxnStatus)
println "Created"
//odiInstance.close()
}
tm.commit(txnStatus)
//println ((IMappingFinder) odiInstance.getTransactionalEntityManager().getFinder(Mapping.class)).findByProject("STOO3", "STO3")
//ms_i.validate()
//ms_i.submit()