Newsletter
DBConcepts Logo Original

Programmgesteuertes Verschieben des ODI Load Plan in einen bestimmten Ordner

Haben Sie schon einmal erlebt, dass Ihr Load Plan nicht dort ist wo Sie ihn hinterlegt haben?

Aufgrund der manchmal schlechten Implementierung der ODI-Studio Benutzeroberfläche kommt es sehr oft vor, dass jemand anderes (oder sogar Sie selbst) einen Load Plan an einen Ort verschoben hat, an dem er nicht sein sollte.

Wenn die entsprechende Warnung in den ODI Studio Einstellungen deaktiviert ist, erkennt der Entwickler nicht einmal, dass er verschoben wurde.

Sobald Sie dann das Chaos entdeckt haben könnte es auch noch schwierig sein den Load Plan wegen Tonnen von Szenarien in der ODI-Studio Ansicht „Ladepläne und Szenarien“ zurückzusetzen.

Aus diesem Grund habe ich ein nützliches Skript geschrieben, um einen Load Plan wieder an seinen richtigen Platz zu bringen.

Viel Spaß!

 
import oracle.odi.core.persistence.transaction.ITransactionStatus;
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition;
import oracle.odi.domain.runtime.scenario.finder.IOdiScenarioFolderFinder;
import oracle.odi.domain.runtime.scenario.OdiScenarioFolder;
import oracle.odi.domain.runtime.loadplan.OdiLoadPlan;
import oracle.odi.domain.runtime.loadplan.finder.IOdiLoadPlanFinder;
 
//
// Find a subfolder with given folderName in parentFolder.
// When no folder exists and creationFlag = true then the folder will be created.
//
def getScenFolder(parentFolder,folderName,creationFlag,tme) {
 def ff = (IOdiScenarioFolderFinder)tme.getFinder(OdiScenarioFolder.class);
 // There would be a findName() method in the finder class,
 // but it delivers the first folder having the given name even if more than one exists.
// So here all folders have to be checked.
 def fs = ff.findAll();
 def folder = null;
 for (f in fs) {
   // If the folder has the same name and the parent folder is the given parentFolder then correct folder was found.
   // The last part of the expression also checks the top level folder.
   if (f.getName()==folderName&&((f.getParentScenFolder()==parentFolder)||(!f.getParentScenFolder()&&!parentFolder))) {
      folder = f;
    }
}
// If the folder doesn’t exist and creation is requested then it will be created´.
if ((!folder)&&creationFlag) {
if (parentFolder) {
folder = new OdiScenarioFolder(parentFolder, folderName);
}
else {
folder = new OdiScenarioFolder(folderName);
}
tme.persist(folder);
}
return folder;
}
 
//
// Find the folder represented by the full folderPath.
// The creationFlag indicated if the path should be created if is not exists.
//
def getScenFolder(folderPath,creationFlag,tme){
// Split the folder path into parts based on slashes
parts = folderPath.split(„/“);
def parentFolder = null;
// Loop through the parts to find the correct folder beginning with the root to the leaves.
for (part in parts) {
if (part) {
folder = getScenFolder(parentFolder,part,creationFlag,tme);
if (!folder) return null; // Stop when either no folder was found or no folder was created.
parentFolder = folder; // Save found folder as parentfolder for the next level loop.
}
}
return folder;
}
 
//
// Find the loadplan
//
def getLoadPlan(lpName,tme){
lpf = (IOdiLoadPlanFinder)tme.getFinder(OdiLoadPlan.class);
lp = lpf.findByName(lpName);
return lp;
}
 
//
// Move the loadplan named with lpName to the folder given by the full folder path in folderPath.
//
def fixLP(folderPath,lpName,creationFlag){
txnDef = new DefaultTransactionDefinition();
tm = odiInstance.getTransactionManager();
tme = odiInstance.getTransactionalEntityManager();
txnStatus = tm.getTransaction(txnDef);
 
try{
lp = getLoadPlan(lpName,tme);
// Get the scenario folder given by the full path (creationFlag could force the creation of this path)
scenf = getScenFolder(folderPath,creationFlag,tme);
lp.setScenarioFolder(scenf); // Move the load plan to the scenario folder
tme.persist(lp); // Persist the changes
tm.commit(txnStatus); // Commit everything
} catch (Throwable all) {
println(all)
tm.rollback(txnStatus); // Rollback if something went wrong
println(all.getStackTrace());
    }
}
 
//
// Call the main function to move the loadplan where it should be.
//
fixLP(‚/ALL_LOADPLANS/MY_LOADPLANS‘,’MY_LOADPLAN‘,true);
 

DBConcepts

Weitere Beiträge

AOUG – Anwenderkonferenz 2024

Mit dem Motto „Driving Transformation“ findet dieses Jahr im Juni 2024 im Tech Gate (Donau-City-Straße 9, 1220 Wien) die Anwenderkonferenz der Austrian Oracle User Group

DBConcepts Sommerfest2024

Jetzt schon den 5. September vormerken – Da findet unser legendäres Sommerfest statt. Wer gewinnt die Tretboot-Challenge dieses Jahr? Freut euch jetzt schon auf einen

DBConcepts

Newsletter abonnieren

Wir freuen uns, dass wir Ihr Interesse für den Newsletter geweckt haben! Mit dem Versand dieser Zustimmung erhalten Sie regelmäßig alle aktuellen Informationen!

Vielen Dank für Ihr Interesse an unserem Unternehmen. Derzeit suchen wir niemanden für diese Stelle. Aber wir sind immer an talentierten Menschen interessiert und freuen uns von Ihnen zu hören! Schicken Sie uns einfach Ihren Lebenslauf und eine kurze Nachricht und schreiben Sie an welcher Stelle Sie interessiert sind: recruitment@dbconcepts.com. Wir freuen usn von Ihnen zu hören!