I'm trying to figure out how to use groovy to edit existing mapping.
I am able to create new mapping. I tried to remove the delete portion of the code but it would give me an error that I need to delete exiting mapping
//delete old mapping
/* remove delete portion to use edit existing 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)
From the error it seems like the mapping (Load_TRG_CUSTOMER) must be delete. Please let me know if you need more code.
Error:
ODI-16096: A mapping with name Load_TRG_CUSTOMER already exists in folder TEST_FOLDER.
(Subtract 18 from the error line number to account for the standard imports)
oracle.odi.domain.mapping.exception.MappingException: ODI-16096: A mapping with name Load_TRG_CUSTOMER already exists in folder TEST_FOLDER.
at oracle.odi.domain.mapping.Mapping.checkName(Mapping.java:153)
Thank you for everyone's help.
IMappingFinder provides useful methods to find an existing mapping. As you already know the name and folder, I guess that the findByName method is the best suited for you.
I see you already have an IMappingFinder instanciated (although it's commented at the moment). So you only need to replace :
map = new Mapping(mappingName, folder);
by
map = (Mapping) mapf.findByName(folder, mappingName);