use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.
the class JobGraph method openJob.
public void openJob() {
JobEntryCopy jobEntryCopy = getJobEntry();
final JobEntryInterface entry = jobEntryCopy.getEntry();
openJob((JobEntryJob) entry, jobEntryCopy);
}
use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.
the class SpoonJobDelegate method editJobEntry.
public void editJobEntry(JobMeta jobMeta, JobEntryCopy je) {
try {
spoon.getLog().logBasic(spoon.toString(), BaseMessages.getString(PKG, "Spoon.Log.EditJobEntry", je.getName()));
JobEntryCopy before = (JobEntryCopy) je.clone_deep();
JobEntryInterface jei = je.getEntry();
JobEntryDialogInterface d = getJobEntryDialog(jei, jobMeta);
if (d != null) {
if (d.open() != null) {
// First see if the name changed.
// If so, we need to verify that the name is not already used in the job.
//
jobMeta.renameJobEntryIfNameCollides(je);
JobEntryCopy after = (JobEntryCopy) je.clone();
spoon.addUndoChange(jobMeta, new JobEntryCopy[] { before }, new JobEntryCopy[] { after }, new int[] { jobMeta.indexOfJobEntry(je) });
spoon.refreshGraph();
spoon.refreshTree();
}
} else {
MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.JobEntryCanNotBeChanged.Message"));
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.JobEntryCanNotBeChanged.Title"));
mb.open();
}
} catch (Exception e) {
if (!spoon.getShell().isDisposed()) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorEditingJobEntry.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorEditingJobEntry.Message"), e);
}
}
}
use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.
the class SpoonJobDelegateTest method testGetJobEntryDialogClass.
@Test
public void testGetJobEntryDialogClass() throws KettlePluginException {
PluginRegistry registry = PluginRegistry.getInstance();
PluginMockInterface plugin = mock(PluginMockInterface.class);
when(plugin.getIds()).thenReturn(new String[] { "mockJobPlugin" });
when(plugin.matches("mockJobPlugin")).thenReturn(true);
when(plugin.getName()).thenReturn("mockJobPlugin");
JobEntryInterface jobEntryInterface = mock(JobEntryInterface.class);
when(jobEntryInterface.getDialogClassName()).thenReturn(String.class.getName());
when(plugin.getClassMap()).thenReturn(new HashMap<Class<?>, String>() {
{
put(JobEntryInterface.class, jobEntryInterface.getClass().getName());
put(JobEntryDialogInterface.class, JobEntryDialogInterface.class.getName());
}
});
registry.registerPlugin(JobEntryPluginType.class, plugin);
SpoonJobDelegate delegate = mock(SpoonJobDelegate.class);
Spoon spoon = mock(Spoon.class);
delegate.spoon = spoon;
delegate.log = mock(LogChannelInterface.class);
when(spoon.getShell()).thenReturn(mock(Shell.class));
doCallRealMethod().when(delegate).getJobEntryDialog(any(JobEntryInterface.class), any(JobMeta.class));
JobMeta meta = mock(JobMeta.class);
// verify that dialog class is requested from plugin
try {
// exception is expected here
delegate.getJobEntryDialog(jobEntryInterface, meta);
} catch (Throwable ignore) {
verify(jobEntryInterface, never()).getDialogClassName();
}
// verify that the deprecated way is still valid
when(plugin.getClassMap()).thenReturn(new HashMap<Class<?>, String>() {
{
put(JobEntryInterface.class, jobEntryInterface.getClass().getName());
}
});
try {
// exception is expected here
delegate.getJobEntryDialog(jobEntryInterface, meta);
} catch (Throwable ignore) {
verify(jobEntryInterface, times(1)).getDialogClassName();
}
// cleanup
registry.removePlugin(JobEntryPluginType.class, plugin);
}
Aggregations