Search in sources :

Example 6 with JobEntrySpecial

use of org.pentaho.di.job.entries.special.JobEntrySpecial in project pentaho-kettle by pentaho.

the class JobMeta method createStartEntry.

/**
 * Creates the start entry.
 *
 * @return the job entry copy
 */
public static final JobEntryCopy createStartEntry() {
    JobEntrySpecial jobEntrySpecial = new JobEntrySpecial(STRING_SPECIAL_START, true, false);
    JobEntryCopy jobEntry = new JobEntryCopy();
    jobEntry.setObjectId(null);
    jobEntry.setEntry(jobEntrySpecial);
    jobEntry.setLocation(50, 50);
    jobEntry.setDrawn(false);
    jobEntry.setDescription(BaseMessages.getString(PKG, "JobMeta.StartJobEntry.Description"));
    return jobEntry;
}
Also used : JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy)

Example 7 with JobEntrySpecial

use of org.pentaho.di.job.entries.special.JobEntrySpecial 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();
        if (jei.isSpecial()) {
            JobEntrySpecial special = (JobEntrySpecial) jei;
            if (special.isDummy()) {
                return;
            }
        }
        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) JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) 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 8 with JobEntrySpecial

use of org.pentaho.di.job.entries.special.JobEntrySpecial in project pentaho-kettle by pentaho.

the class JobHasNoDisabledHopsImportRuleIT method testRule.

public void testRule() throws Exception {
    // Create a job to test.
    // 
    JobMeta jobMeta = new JobMeta();
    // Add 3 dummy steps connected with hops.
    // 
    JobEntryCopy lastCopy = null;
    for (int i = 0; i < 3; i++) {
        JobEntrySpecial dummy = new JobEntrySpecial();
        dummy.setDummy(true);
        dummy.setName("dummy" + (i + 1));
        JobEntryCopy copy = new JobEntryCopy(dummy);
        copy.setLocation(50 + i * 50, 50);
        copy.setDrawn();
        jobMeta.addJobEntry(copy);
        if (lastCopy != null) {
            JobHopMeta hop = new JobHopMeta(lastCopy, copy);
            jobMeta.addJobHop(hop);
        }
        lastCopy = copy;
    }
    // Load the plugin to test from the registry.
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasNoDisabledHops");
    assertNotNull("The 'job has no disabled hops' rule could not be found in the plugin registry!", plugin);
    JobHasNoDisabledHopsImportRule rule = (JobHasNoDisabledHopsImportRule) registry.loadClass(plugin);
    assertNotNull("The 'job has no disabled hops' class could not be loaded by the plugin registry!", plugin);
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has no disabled hops'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    jobMeta.getJobHop(0).setEnabled(false);
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has no disabled hops'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setEnabled(false);
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't expect any feedback from the 'job has no disabled hops' while disabled", feedback.isEmpty());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) JobHopMeta(org.pentaho.di.job.JobHopMeta) JobHasNoDisabledHopsImportRule(org.pentaho.di.imp.rules.JobHasNoDisabledHopsImportRule) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Aggregations

JobEntrySpecial (org.pentaho.di.job.entries.special.JobEntrySpecial)8 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 JobHopMeta (org.pentaho.di.job.JobHopMeta)2 JobMeta (org.pentaho.di.job.JobMeta)2 JobEntryDialogInterface (org.pentaho.di.job.entry.JobEntryDialogInterface)2 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 FileObject (org.apache.commons.vfs2.FileObject)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Result (org.pentaho.di.core.Result)1 KettleJobException (org.pentaho.di.core.exception.KettleJobException)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1 JobTracker (org.pentaho.di.core.gui.JobTracker)1