Search in sources :

Example 41 with JobEntryInterface

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);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface)

Example 42 with JobEntryInterface

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);
        }
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryDialogInterface(org.pentaho.di.job.entry.JobEntryDialogInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 43 with JobEntryInterface

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);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryDialogInterface(org.pentaho.di.job.entry.JobEntryDialogInterface) Shell(org.eclipse.swt.widgets.Shell) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) Spoon(org.pentaho.di.ui.spoon.Spoon) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Test(org.junit.Test)

Aggregations

JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)43 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)27 Test (org.junit.Test)15 KettleException (org.pentaho.di.core.exception.KettleException)12 JobMeta (org.pentaho.di.job.JobMeta)9 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)8 ArrayList (java.util.ArrayList)7 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)7 Job (org.pentaho.di.job.Job)7 Result (org.pentaho.di.core.Result)5 Point (org.pentaho.di.core.gui.Point)5 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)5 JobEntryBase (org.pentaho.di.job.entry.JobEntryBase)5 NotePadMeta (org.pentaho.di.core.NotePadMeta)4 JobHopMeta (org.pentaho.di.job.JobHopMeta)4 JobEntryDialogInterface (org.pentaho.di.job.entry.JobEntryDialogInterface)4 ObjectId (org.pentaho.di.repository.ObjectId)4 Date (java.util.Date)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)3