use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class Spoon method editSelectAll.
public void editSelectAll() {
TransMeta transMeta = getActiveTransformation();
if (transMeta != null) {
transMeta.selectAll();
getActiveTransGraph().redraw();
}
JobMeta jobMeta = getActiveJob();
if (jobMeta != null) {
jobMeta.selectAll();
getActiveJobGraph().redraw();
}
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobGraph method loadReferencedObject.
protected void loadReferencedObject(JobEntryCopy jobEntryCopy, int index) {
try {
Object referencedMeta = jobEntryCopy.getEntry().loadReferencedObject(index, spoon.rep, spoon.metaStore, jobMeta);
if (referencedMeta == null) {
// Compatible re-try for older plugins.
referencedMeta = compatibleJobEntryLoadReferencedObject(jobEntryCopy.getEntry(), index, spoon.rep, jobMeta);
}
if (referencedMeta != null && (referencedMeta instanceof TransMeta)) {
TransMeta launchTransMeta = (TransMeta) referencedMeta;
// Try to see if this transformation is already loaded in another tab...
//
TabMapEntry tabEntry = spoon.delegates.tabs.findTabForTransformation(launchTransMeta);
if (tabEntry != null) {
// Switch to this one!
//
spoon.tabfolder.setSelected(tabEntry.getTabItem());
return;
}
copyInternalJobVariables(jobMeta, launchTransMeta);
spoon.setParametersAsVariablesInUI(launchTransMeta, launchTransMeta);
launchTransMeta.clearChanged();
spoon.addTransGraph(launchTransMeta);
TransGraph transGraph = spoon.getActiveTransGraph();
attachActiveTrans(transGraph, launchTransMeta, jobEntryCopy);
spoon.refreshTree();
spoon.applyVariables();
}
if (referencedMeta != null && (referencedMeta instanceof JobMeta)) {
JobMeta launchJobMeta = (JobMeta) referencedMeta;
// Try to see if this job is already loaded in another tab...
//
String tabName = spoon.delegates.tabs.makeTabName(launchJobMeta, true);
TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
if (tabEntry != null) {
// Switch to this one!
//
spoon.tabfolder.setSelected(tabEntry.getTabItem());
return;
}
spoon.setParametersAsVariablesInUI(launchJobMeta, launchJobMeta);
launchJobMeta.clearChanged();
spoon.addJobGraph(launchJobMeta);
JobGraph jobGraph = spoon.getActiveJobGraph();
attachActiveJob(jobGraph, launchJobMeta, jobEntryCopy);
spoon.refreshTree();
spoon.applyVariables();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Message"), e);
}
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobGraph method openJob.
public void openJob(JobEntryJob entry, JobEntryCopy jobEntryCopy) {
try {
JobMeta launchJobMeta = null;
switch(entry.getSpecificationMethod()) {
case FILENAME:
// See if this file is already loaded...
//
String exactFilename = jobMeta.environmentSubstitute(entry.getFilename());
if (Utils.isEmpty(exactFilename)) {
throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoFilenameSpecified"));
}
//
if (KettleVFS.fileExists(exactFilename)) {
launchJobMeta = new JobMeta(jobMeta, exactFilename, spoon.rep, spoon.metaStore, null);
} else {
launchJobMeta = new JobMeta();
}
launchJobMeta.setFilename(exactFilename);
break;
case REPOSITORY_BY_NAME:
String exactJobname = jobMeta.environmentSubstitute(entry.getJobName());
String exactDirectory = jobMeta.environmentSubstitute(entry.getDirectory());
if (Utils.isEmpty(exactJobname)) {
throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobNameSpecified"));
}
if (Utils.isEmpty(exactDirectory)) {
throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobDirectorySpecified"));
}
// Open the job or create a new one...
//
RepositoryDirectoryInterface repDir = spoon.rep.findDirectory(entry.getDirectory());
boolean exists = spoon.rep.exists(exactJobname, repDir, RepositoryObjectType.JOB);
if (!exists) {
launchJobMeta = new JobMeta();
launchJobMeta.setName(exactJobname);
launchJobMeta.setRepositoryDirectory(repDir);
} else {
// Always reads last revision
launchJobMeta = spoon.rep.loadJob(exactJobname, repDir, null, null);
}
break;
case REPOSITORY_BY_REFERENCE:
if (entry.getJobObjectId() == null) {
throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobReferenceSpecified"));
}
// Always reads last revision
launchJobMeta = spoon.rep.loadJob(entry.getJobObjectId(), null);
break;
default:
break;
}
//
if (launchJobMeta == null) {
throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoValidJobSpecified"));
}
launchJobMeta.setRepository(spoon.getRepository());
launchJobMeta.setMetaStore(spoon.getMetaStore());
// Try to see if this job is already loaded in another tab...
//
String tabName = spoon.delegates.tabs.makeTabName(launchJobMeta, true);
TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
if (tabEntry != null) {
// Switch to this one!
//
spoon.tabfolder.setSelected(tabEntry.getTabItem());
return;
}
spoon.setParametersAsVariablesInUI(launchJobMeta, launchJobMeta);
spoon.addJobGraph(launchJobMeta);
launchJobMeta.clearChanged();
JobGraph jobGraph = spoon.getActiveJobGraph();
attachActiveJob(jobGraph, launchJobMeta, jobEntryCopy);
spoon.refreshTree();
spoon.applyVariables();
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingChefCanNotLoadJob.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingChefCanNotLoadJob.Message"), e);
}
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobGraph method editProperties.
public static boolean editProperties(JobMeta jobMeta, Spoon spoon, Repository rep, boolean allowDirectoryChange) {
if (jobMeta == null) {
return false;
}
JobDialog jd = new JobDialog(spoon.getShell(), SWT.NONE, jobMeta, rep);
jd.setDirectoryChangeAllowed(allowDirectoryChange);
JobMeta ji = jd.open();
//
if (jd.isSharedObjectsFileChanged()) {
try {
SharedObjects sharedObjects = rep != null ? rep.readJobMetaSharedObjects(jobMeta) : jobMeta.readSharedObjects();
spoon.sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
} catch (Exception e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", spoon.delegates.tabs.makeTabName(jobMeta, true)), e);
}
}
// If we added properties, add them to the variables too, so that they appear in the CTRL-SPACE variable completion.
//
spoon.setParametersAsVariablesInUI(jobMeta, jobMeta);
if (jd.isSharedObjectsFileChanged() || ji != null) {
spoon.refreshTree();
// cheap operation, might as will do it anyway
spoon.delegates.tabs.renameTabs();
}
spoon.setShellText();
return ji != null;
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class JobGraph method enableDisableNextHops.
private Set<JobEntryCopy> enableDisableNextHops(JobEntryCopy from, boolean enabled, Set<JobEntryCopy> checkedEntries) {
checkedEntries.add(from);
jobMeta.getJobhops().stream().filter(hop -> from.equals(hop.getFromEntry())).forEach(hop -> {
if (hop.isEnabled() != enabled) {
JobHopMeta before = (JobHopMeta) hop.clone();
hop.setEnabled(enabled);
JobHopMeta after = (JobHopMeta) hop.clone();
spoon.addUndoChange(jobMeta, new JobHopMeta[] { before }, new JobHopMeta[] { after }, new int[] { jobMeta.indexOfJobHop(hop) });
}
if (!checkedEntries.contains(hop.getToEntry())) {
enableDisableNextHops(hop.getToEntry(), enabled, checkedEntries);
}
});
return checkedEntries;
}
Aggregations