我已经创建了脚本来创建Map,它能够做到这一点:
但我的问题是,如果列名相同,我应该能够自动Map,请建议如何做到这一点。
https://blogs.oracle.com/dataintegration/entry/odi_12c_mapping_builder:没有帮助。
//name of the project
projectName = "TEST"
//name of the folder
ordnerName = "First Folder"
//name of the mapping
mappingName = "MAP_SRC_TO_TRG"
//name of the model
modelName = "SAP"
//trg model"SAP_INV10", "ODSSTAGE"
modelName_trg="ODSSTAGE"
//name of the source datastore
sourceDatastoreName = "INV10"
//name of the target datastore
targetDatastoreName = "SAP_INV10"
import oracle.odi.domain.model.OdiColumn
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.project.finder.IOdiKMFinder
import oracle.odi.domain.mapping.finder.IMappingFinder
import oracle.odi.domain.adapter.project.IKnowledgeModule.ProcessingType
import oracle.odi.domain.model.OdiDataStore
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition
//set expression to the component
def createExp(comp, tgtTable, propertyName, expressionText) {
DatastoreComponent.findAttributeForColumn(comp,tgtTable.getColumn(propertyName)) .setExpressionText(expressionText)
}
//delete mapping with the same name
def removeMapping(folder, map_name) {
txnDef = new DefaultTransactionDefinition()
tm = odiInstance.getTransactionManager()
tme = odiInstance.getTransactionalEntityManager()
txnStatus = tm.getTransaction(txnDef)
try {
Mapping map = ((IMappingFinder) tme.getFinder(Mapping.class)).findByName(folder, map_name)
if (map != null) {
odiInstance.getTransactionalEntityManager().remove(map);
}
} catch (Exception e) {e.printStackTrace();}
tm.commit(txnStatus)
}
//looking for a project and folder
def find_folder(project_code, folder_name) {
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)
project = pf.findByCode(project_code)
//if there is no project, create new one
if (project == null) {
project = new OdiProject(project_code, project_code)
tme.persist(project)
}
//if there is no folder, create new one
folderColl = ff.findByName(folder_name, project_code)
OdiFolder folder = null
if (folderColl.size() == 1)
folder = folderColl.iterator().next()
if (folder == null) {
folder = new OdiFolder(project, folder_name)
tme.persist(folder)
}
tm.commit(txnStatus)
return folder
}
//name of the project and the folder
folder = find_folder(projectName,ordnerName)
//delete old mapping
removeMapping(folder, mappingName)
txnDef = new DefaultTransactionDefinition()
tm = odiInstance.getTransactionManager()
tme = odiInstance.getTransactionalEntityManager()
txnStatus = tm.getTransaction(txnDef)
dsf = (IOdiDataStoreFinder)tme.getFinder(OdiDataStore.class)
mapf = (IMappingFinder) tme.getFinder(Mapping.class)
//create new mapping
map = new Mapping(mappingName, folder);
tme.persist(map)
//insert source table
boundTo_emp = dsf.findByName(sourceDatastoreName, modelName)
comp_emp = new DatastoreComponent(map, boundTo_emp)
//insert target table
boundTo_tgtemp = dsf.findByName(targetDatastoreName, modelName_trg)
comp_tgtemp = new DatastoreComponent(map, boundTo_tgtemp)
//link source table with expression
// comp_emp.connectTo(comp_expression)
//link expression with target table
comp_emp.connectTo(comp_tgtemp)
// map.autoMap( boundTo_emp, boundTo_tgtemp);
tme.persist(map)
tm.commit(txnStatus)
//连接源组件和目标组件后
我们有类似map.autoMap(sourceDatastoreName,targetDatastoreName)的东西吗
任何帮助将不胜感激。ODI:12c
1条答案
按热度按时间a0x5cqrl1#
SDK中没有直接的方法来执行自动Map。
然而,大卫Allan写了一篇关于如何实现它的博客文章:ODI 12c - Mapping SDK Auto Mapping。