use of org.pentaho.di.ui.spoon.job.JobGraph in project pentaho-kettle by pentaho.
the class GraphTest method testDelJobNoSelections.
@Test
public void testDelJobNoSelections() {
JobMeta jobMeta = mock(JobMeta.class);
Spoon spoon = mock(Spoon.class);
when(jobMeta.getSelectedEntries()).thenReturn(Collections.<JobEntryCopy>emptyList());
JobEntryCopy je = mock(JobEntryCopy.class);
JobGraph jobGraph = mock(JobGraph.class);
doCallRealMethod().when(jobGraph).setJobMeta(any(JobMeta.class));
doCallRealMethod().when(jobGraph).setSpoon(any(Spoon.class));
doCallRealMethod().when(jobGraph).delSelected(any(JobEntryCopy.class));
jobGraph.setJobMeta(jobMeta);
jobGraph.setSpoon(spoon);
jobGraph.delSelected(je);
verify(spoon).deleteJobEntryCopies(jobMeta, je);
}
use of org.pentaho.di.ui.spoon.job.JobGraph in project pentaho-kettle by pentaho.
the class SpoonJobDelegate method executeJob.
public void executeJob(JobMeta jobMeta, boolean local, boolean remote, Date replayDate, boolean safe, String startCopyName, int startCopyNr) throws KettleException {
if (jobMeta == null) {
return;
}
JobExecutionConfiguration executionConfiguration = spoon.getJobExecutionConfiguration();
// Remember the variables set previously
//
Object[] data = spoon.variables.getData();
String[] fields = spoon.variables.getRowMeta().getFieldNames();
Map<String, String> variableMap = new HashMap<>();
for (int idx = 0; idx < fields.length; idx++) {
variableMap.put(fields[idx], data[idx].toString());
}
executionConfiguration.setVariables(variableMap);
executionConfiguration.getUsedVariables(jobMeta);
executionConfiguration.setReplayDate(replayDate);
executionConfiguration.setRepository(spoon.rep);
executionConfiguration.setSafeModeEnabled(safe);
executionConfiguration.setStartCopyName(startCopyName);
executionConfiguration.setStartCopyNr(startCopyNr);
executionConfiguration.getUsedArguments(jobMeta, spoon.getArguments(), spoon.getMetaStore());
executionConfiguration.setLogLevel(DefaultLogLevel.getLogLevel());
JobExecutionConfigurationDialog dialog = newJobExecutionConfigurationDialog(executionConfiguration, jobMeta);
if (!jobMeta.isShowDialog() || dialog.open()) {
JobGraph jobGraph = spoon.getActiveJobGraph();
jobGraph.jobLogDelegate.addJobLog();
//
for (String varName : executionConfiguration.getVariables().keySet()) {
String varValue = executionConfiguration.getVariables().get(varName);
jobMeta.setVariable(varName, varValue);
}
//
for (String paramName : executionConfiguration.getParams().keySet()) {
String paramValue = executionConfiguration.getParams().get(paramName);
jobMeta.setParameterValue(paramName, paramValue);
}
jobMeta.activateParameters();
//
if (executionConfiguration.getLogLevel() != null) {
jobMeta.setLogLevel(executionConfiguration.getLogLevel());
}
//
if (executionConfiguration.getStartCopyName() != null) {
jobMeta.setStartCopyName(executionConfiguration.getStartCopyName());
}
// Set the run options
//
jobMeta.setClearingLog(executionConfiguration.isClearingLog());
jobMeta.setSafeModeEnabled(executionConfiguration.isSafeModeEnabled());
jobMeta.setExpandingRemoteJob(executionConfiguration.isExpandingRemoteJob());
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonJobMetaExecutionStart.id, jobMeta);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonJobExecutionConfiguration.id, executionConfiguration);
try {
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, jobMeta, jobMeta, spoon.getRepository() });
} catch (KettleException e) {
log.logError(e.getMessage(), jobMeta.getFilename());
return;
}
if (!executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely()) {
if (jobMeta.hasChanged()) {
jobGraph.showSaveFileMessage();
}
}
//
if (executionConfiguration.isExecutingLocally()) {
jobGraph.startJob(executionConfiguration);
} else if (executionConfiguration.isExecutingRemotely()) {
// Executing remotely
// Check if jobMeta has changed
jobGraph.handleJobMetaChanges(jobMeta);
// Activate the parameters, turn them into variables...
// jobMeta.hasChanged()
jobMeta.activateParameters();
if (executionConfiguration.getRemoteServer() != null) {
Job.sendToSlaveServer(jobMeta, executionConfiguration, spoon.rep, spoon.metaStore);
spoon.delegates.slaves.addSpoonSlave(executionConfiguration.getRemoteServer());
} else {
MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message"));
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title"));
mb.open();
}
}
}
}
use of org.pentaho.di.ui.spoon.job.JobGraph in project pentaho-kettle by pentaho.
the class SpoonTabsDelegate method getActiveMeta.
public EngineMetaInterface getActiveMeta() {
TabSet tabfolder = spoon.tabfolder;
if (tabfolder == null) {
return null;
}
TabItem tabItem = tabfolder.getSelected();
if (tabItem == null) {
return null;
}
// What transformation is in the active tab?
// TransLog, TransGraph & TransHist contain the same transformation
//
TabMapEntry mapEntry = getTab(tabfolder.getSelected());
EngineMetaInterface meta = null;
if (mapEntry != null) {
if (mapEntry.getObject() instanceof TransGraph) {
meta = (mapEntry.getObject()).getMeta();
}
if (mapEntry.getObject() instanceof JobGraph) {
meta = (mapEntry.getObject()).getMeta();
}
}
return meta;
}
use of org.pentaho.di.ui.spoon.job.JobGraph in project pentaho-kettle by pentaho.
the class SpoonTabsDelegate method tabClose.
public boolean tabClose(TabItem item, boolean force) throws KettleException {
// Try to find the tab-item that's being closed.
boolean createPerms = !RepositorySecurityUI.verifyOperations(Spoon.getInstance().getShell(), Spoon.getInstance().getRepository(), false, RepositoryOperation.MODIFY_TRANSFORMATION, RepositoryOperation.MODIFY_JOB);
boolean close = true;
boolean canSave = true;
for (TabMapEntry entry : tabMap) {
if (item.equals(entry.getTabItem())) {
final TabItemInterface itemInterface = entry.getObject();
final Object managedObject = itemInterface.getManagedObject();
if (!force) {
if (managedObject != null && AbstractMeta.class.isAssignableFrom(managedObject.getClass())) {
canSave = !((AbstractMeta) managedObject).hasMissingPlugins();
}
if (canSave) {
// Can we close this tab? Only allow users with create content perms to save
if (!itemInterface.canBeClosed() && createPerms) {
int reply = itemInterface.showChangedWarning();
if (reply == SWT.YES) {
close = itemInterface.applyChanges();
} else {
if (reply == SWT.CANCEL) {
close = false;
} else {
close = true;
}
}
}
}
}
String beforeCloseId = null;
String afterCloseId = null;
if (itemInterface instanceof TransGraph) {
beforeCloseId = KettleExtensionPoint.TransBeforeClose.id;
afterCloseId = KettleExtensionPoint.TransAfterClose.id;
} else if (itemInterface instanceof JobGraph) {
beforeCloseId = KettleExtensionPoint.JobBeforeClose.id;
afterCloseId = KettleExtensionPoint.JobAfterClose.id;
}
if (beforeCloseId != null) {
try {
ExtensionPointHandler.callExtensionPoint(log, beforeCloseId, managedObject);
} catch (KettleException e) {
// prevent tab close
close = false;
}
}
//
if (close) {
if (itemInterface instanceof TransGraph) {
TransMeta transMeta = (TransMeta) managedObject;
spoon.delegates.trans.closeTransformation(transMeta);
spoon.refreshTree();
// spoon.refreshCoreObjects();
} else if (itemInterface instanceof JobGraph) {
JobMeta jobMeta = (JobMeta) managedObject;
spoon.delegates.jobs.closeJob(jobMeta);
spoon.refreshTree();
// spoon.refreshCoreObjects();
} else if (itemInterface instanceof SpoonBrowser) {
this.removeTab(entry);
spoon.refreshTree();
} else if (itemInterface instanceof Composite) {
Composite comp = (Composite) itemInterface;
if (comp != null && !comp.isDisposed()) {
comp.dispose();
}
}
if (afterCloseId != null) {
try {
ExtensionPointHandler.callExtensionPoint(log, afterCloseId, managedObject);
} catch (KettleException e) {
// fails gracefully... what else could we do?
}
}
}
break;
}
}
return close;
}
use of org.pentaho.di.ui.spoon.job.JobGraph in project pentaho-kettle by pentaho.
the class SpoonTabsDelegate method renameTabs.
/**
* Rename the tabs
*/
public void renameTabs() {
List<TabMapEntry> list = new ArrayList<TabMapEntry>(tabMap);
for (TabMapEntry entry : list) {
if (entry.getTabItem().isDisposed()) {
// this should not be in the map, get rid of it.
tabMap.remove(entry.getObjectName());
continue;
}
// TabItem before = entry.getTabItem();
// PDI-1683: need to get the String here, otherwise using only the "before" instance below, the reference gets
// changed and result is always the same
// String beforeText=before.getText();
//
Object managedObject = entry.getObject().getManagedObject();
if (managedObject != null) {
if (entry.getObject() instanceof AbstractGraph) {
AbstractMeta meta = (AbstractMeta) managedObject;
String tabText = makeTabName(meta, entry.isShowingLocation());
entry.getTabItem().setText(tabText);
String toolTipText = BaseMessages.getString(PKG, "Spoon.TabTrans.Tooltip", tabText);
if (entry.getObject() instanceof JobGraph) {
toolTipText = BaseMessages.getString(PKG, "Spoon.TabJob.Tooltip", tabText);
}
if (Const.isWindows() && !Utils.isEmpty(meta.getFilename())) {
toolTipText += Const.CR + Const.CR + meta.getFilename();
}
entry.getTabItem().setToolTipText(toolTipText);
}
}
}
spoon.setShellText();
}
Aggregations