Search in sources :

Example 11 with JobEntryInterface

use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.

the class RepositoryImporterTest method testImportJob_patchJobEntries_without_variables.

@Test
public void testImportJob_patchJobEntries_without_variables() throws KettleException {
    JobEntryInterface jobEntry = createJobEntry("/userName");
    StepMetaInterface stepMeta = createStepMeta("");
    RepositoryImporter importer = createRepositoryImporter(jobEntry, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importJob(entityNode, feedback);
    verify((HasRepositoryDirectories) jobEntry).setDirectories(new String[] { ROOT_PATH + USER_NAME_PATH });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Test(org.junit.Test)

Example 12 with JobEntryInterface

use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.

the class RunConfigurationDelegate method updateLoadedJobs.

protected void updateLoadedJobs(String key, RunConfiguration runConfig) {
    for (JobMeta job : spoonSupplier.get().getLoadedJobs()) {
        for (int i = 0; i < job.nrJobEntries(); i++) {
            JobEntryInterface entry = job.getJobEntry(i).getEntry();
            if (entry instanceof JobEntryRunConfigurableInterface) {
                JobEntryRunConfigurableInterface jet = (JobEntryRunConfigurableInterface) entry;
                if (jet.getRunConfiguration() != null) {
                    if (jet.getRunConfiguration().equals(key)) {
                        try {
                            ExtensionPointHandler.callExtensionPoint(job.getLogChannel(), KettleExtensionPoint.JobEntryTransSave.id, new Object[] { job, runConfig.getName() });
                        } catch (KettleException e) {
                            spoonSupplier.get().getLog().logBasic("Unable to set run configuration in job " + job.getName());
                        }
                        jet.setRunConfiguration(runConfig.getName());
                        if (runConfig instanceof DefaultRunConfiguration) {
                            jet.setRemoteSlaveServerName(((DefaultRunConfiguration) runConfig).getServer());
                            jet.setLoggingRemoteWork(((DefaultRunConfiguration) runConfig).isLogRemoteExecutionLocally());
                        }
                        jet.setChanged();
                    }
                }
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryRunConfigurableInterface(org.pentaho.di.job.entry.JobEntryRunConfigurableInterface) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 13 with JobEntryInterface

use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method newJobEntry.

public JobEntryCopy newJobEntry(JobMeta jobMeta, String type_desc, boolean openit) {
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface jobPlugin;
    try {
        jobPlugin = PluginRegistry.getInstance().findPluginWithName(JobEntryPluginType.class, type_desc);
        if (jobPlugin == null) {
            // Check if it's not START or DUMMY
            if (JobMeta.STRING_SPECIAL_START.equalsIgnoreCase(type_desc) || JobMeta.STRING_SPECIAL_DUMMY.equalsIgnoreCase(type_desc)) {
                jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, JobMeta.STRING_SPECIAL);
            }
        }
        if (jobPlugin != null) {
            // Determine name & number for this entry.
            // See if the name is already used...
            // 
            String entry_name = type_desc;
            int nr = 2;
            JobEntryCopy check = jobMeta.findJobEntry(entry_name, 0, true);
            while (check != null) {
                entry_name = type_desc + " " + nr++;
                check = jobMeta.findJobEntry(entry_name, 0, true);
            }
            // Generate the appropriate class...
            JobEntryInterface jei = (JobEntryInterface) registry.loadClass(jobPlugin);
            jei.setPluginId(jobPlugin.getIds()[0]);
            jei.setName(entry_name);
            if (jei.isSpecial()) {
                if (JobMeta.STRING_SPECIAL_START.equalsIgnoreCase(type_desc)) {
                    // Check if start is already on the canvas...
                    if (jobMeta.findStart() != null) {
                        JobGraph.showOnlyStartOnceMessage(spoon.getShell());
                        return null;
                    }
                    ((JobEntrySpecial) jei).setStart(true);
                }
                if (JobMeta.STRING_SPECIAL_DUMMY.equalsIgnoreCase(type_desc)) {
                    ((JobEntrySpecial) jei).setDummy(true);
                }
            }
            if (openit) {
                JobEntryDialogInterface d = getJobEntryDialog(jei, jobMeta);
                if (d != null && d.open() != null) {
                    JobEntryCopy jge = new JobEntryCopy();
                    jge.setEntry(jei);
                    jge.setLocation(50, 50);
                    jge.setNr(0);
                    jobMeta.addJobEntry(jge);
                    // Verify that the name is not already used in the job.
                    // 
                    jobMeta.renameJobEntryIfNameCollides(jge);
                    spoon.addUndoNew(jobMeta, new JobEntryCopy[] { jge }, new int[] { jobMeta.indexOfJobEntry(jge) });
                    spoon.refreshGraph();
                    spoon.refreshTree();
                    return jge;
                } else {
                    return null;
                }
            } else {
                JobEntryCopy jge = new JobEntryCopy();
                jge.setEntry(jei);
                jge.setLocation(50, 50);
                jge.setNr(0);
                jobMeta.addJobEntry(jge);
                spoon.addUndoNew(jobMeta, new JobEntryCopy[] { jge }, new int[] { jobMeta.indexOfJobEntry(jge) });
                spoon.refreshGraph();
                spoon.refreshTree();
                return jge;
            }
        } else {
            return null;
        }
    } catch (Throwable e) {
        new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.UnexpectedErrorCreatingNewJobGraphEntry.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.UnexpectedErrorCreatingNewJobGraphEntry.Message"), new Exception(e));
        return null;
    }
}
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) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) JobEntryPluginType(org.pentaho.di.core.plugins.JobEntryPluginType)

Example 14 with JobEntryInterface

use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method getJobEntryDialog.

public JobEntryDialogInterface getJobEntryDialog(JobEntryInterface jobEntryInterface, JobMeta jobMeta) {
    Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class };
    Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta };
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.getPlugin(JobEntryPluginType.class, jobEntryInterface);
    String dialogClassName = plugin.getClassMap().get(JobEntryDialogInterface.class);
    if (dialogClassName == null) {
        // try the deprecated way
        log.logDebug("Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead.");
        dialogClassName = jobEntryInterface.getDialogClassName();
    }
    try {
        Class<JobEntryDialogInterface> dialogClass = registry.getClass(plugin, dialogClassName);
        Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor(paramClasses);
        JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance(paramArgs);
        entryDialogInterface.setMetaStore(spoon.getMetaStore());
        return entryDialogInterface;
    } catch (Throwable t) {
        t.printStackTrace();
        String errorTitle = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title");
        String errorMsg = BaseMessages.getString(PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName);
        spoon.getLog().logError(spoon.toString(), errorMsg);
        new ErrorDialog(spoon.getShell(), errorTitle, errorMsg, t);
        return null;
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryDialogInterface(org.pentaho.di.job.entry.JobEntryDialogInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Shell(org.eclipse.swt.widgets.Shell) Repository(org.pentaho.di.repository.Repository) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 15 with JobEntryInterface

use of org.pentaho.di.job.entry.JobEntryInterface in project pentaho-kettle by pentaho.

the class JobGraph method openTransformation.

public void openTransformation() {
    JobEntryCopy jobEntryCopy = getJobEntry();
    final JobEntryInterface entry = jobEntryCopy.getEntry();
    openTransformation((JobEntryTrans) entry, jobEntryCopy);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface)

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