Search in sources :

Example 6 with JobEntryInterface

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

the class KettleDatabaseRepositoryJobEntryDelegate method loadJobEntryCopy.

/**
 * Load the chef graphical entry from repository We load type, name & description if no entry can be found.
 *
 * @param log
 *          the logging channel
 * @param rep
 *          the Repository
 * @param jobId
 *          The job ID
 * @param jobEntryCopyId
 *          The jobentry copy ID
 * @param jobentries
 *          A list with all jobentries
 * @param databases
 *          A list with all defined databases
 */
public JobEntryCopy loadJobEntryCopy(ObjectId jobId, ObjectId jobEntryCopyId, List<JobEntryInterface> jobentries, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, String jobname) throws KettleException {
    JobEntryCopy jobEntryCopy = new JobEntryCopy();
    try {
        jobEntryCopy.setObjectId(jobEntryCopyId);
        // Handle GUI information: nr, location, ...
        RowMetaAndData r = getJobEntryCopy(jobEntryCopyId);
        if (r != null) {
            // These are the jobentry_copy fields...
            // 
            ObjectId jobEntryId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY, 0));
            ObjectId jobEntryTypeId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE, 0));
            jobEntryCopy.setNr((int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR, 0));
            int locx = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X, 0);
            int locy = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y, 0);
            boolean isdrawn = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW, false);
            boolean isparallel = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL, false);
            // Do we have the jobentry already?
            // 
            jobEntryCopy.setEntry(JobMeta.findJobEntry(jobentries, jobEntryId));
            if (jobEntryCopy.getEntry() == null) {
                // What type of jobentry do we load now?
                // Get the jobentry type code
                // 
                RowMetaAndData rt = getJobEntryType(new LongObjectId(jobEntryTypeId));
                if (rt != null) {
                    String jet_code = rt.getString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE, null);
                    JobEntryInterface jobEntry = null;
                    PluginRegistry registry = PluginRegistry.getInstance();
                    PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, jet_code);
                    if (jobPlugin == null) {
                        jobEntry = new MissingEntry(jobname, jet_code);
                    } else {
                        jobEntry = (JobEntryInterface) registry.loadClass(jobPlugin);
                    }
                    if (jobEntry != null) {
                        jobEntryCopy.setEntry(jobEntry);
                        // 
                        if (jobEntry instanceof JobEntryBase) {
                            loadJobEntryBase((JobEntryBase) jobEntry, jobEntryId, databases, slaveServers);
                            ((JobEntryBase) jobEntry).setAttributesMap(loadJobEntryAttributesMap(jobId, jobEntryId));
                        }
                        compatibleJobEntryLoadRep(jobEntry, repository, jobEntryTypeId, databases, slaveServers);
                        jobEntry.loadRep(repository, repository.metaStore, jobEntryId, databases, slaveServers);
                        jobEntryCopy.getEntry().setObjectId(jobEntryId);
                        jobentries.add(jobEntryCopy.getEntry());
                    } else {
                        throw new KettleException("JobEntryLoader was unable to find Job Entry Plugin with description [" + jet_code + "].");
                    }
                } else {
                    throw new KettleException("Unable to find Job Entry Type with id=" + jobEntryTypeId + " in the repository");
                }
            }
            jobEntryCopy.setLocation(locx, locy);
            jobEntryCopy.setDrawn(isdrawn);
            jobEntryCopy.setLaunchingInParallel(isparallel);
            return jobEntryCopy;
        } else {
            throw new KettleException("Unable to find job entry copy in repository with id_jobentry_copy=" + jobEntryCopyId);
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException("Unable to load job entry copy from repository with id_jobentry_copy=" + jobEntryCopyId, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry) JobEntryBase(org.pentaho.di.job.entry.JobEntryBase) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 7 with JobEntryInterface

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

the class JobMetaTest method createJobEntryCopy.

private JobEntryCopy createJobEntryCopy(String name) {
    JobEntryInterface jobEntry = mock(JobEntryInterface.class);
    JobEntryCopy jobEntryCopy = new JobEntryCopy(jobEntry);
    when(jobEntryCopy.getName()).thenReturn(name);
    jobEntryCopy.setNr(0);
    return jobEntryCopy;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface)

Example 8 with JobEntryInterface

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

the class RepositoryImporterTest method testImportJob_patchJobEntries_with_variable.

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

Example 9 with JobEntryInterface

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

the class RepositoryImporterTest method testImportTrans_patchTransEntries_when_directory_path_ends_with_variable.

@Test
public void testImportTrans_patchTransEntries_when_directory_path_ends_with_variable() throws KettleException {
    JobEntryInterface jobEntryInterface = createJobEntry("");
    StepMetaInterface stepMeta = createStepMeta("/myDir/${USER_VARIABLE}");
    RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta).setDirectories(new String[] { "/myDir/${USER_VARIABLE}" });
    StepMetaInterface stepMeta2 = createStepMeta("/myDir/${USER_VARIABLE}");
    RepositoryImporter importerWithCompatibilityImportPath = createRepositoryImporter(jobEntryInterface, stepMeta2, false);
    importerWithCompatibilityImportPath.setBaseDirectory(baseDirectory);
    importerWithCompatibilityImportPath.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta2).setDirectories(new String[] { ROOT_PATH + "/myDir/${USER_VARIABLE}" });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Test(org.junit.Test)

Example 10 with JobEntryInterface

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

the class RepositoryImporterTest method testImportTrans_patchTransEntries_when_directory_path_starts_with_variable.

@Test
public void testImportTrans_patchTransEntries_when_directory_path_starts_with_variable() throws KettleException {
    JobEntryInterface jobEntryInterface = createJobEntry("");
    StepMetaInterface stepMeta = createStepMeta("${USER_VARIABLE}/myDir");
    RepositoryImporter importer = createRepositoryImporter(jobEntryInterface, stepMeta, true);
    importer.setBaseDirectory(baseDirectory);
    importer.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta).setDirectories(new String[] { "${USER_VARIABLE}/myDir" });
    StepMetaInterface stepMeta2 = createStepMeta("${USER_VARIABLE}/myDir");
    RepositoryImporter importerWithCompatibilityImportPath = createRepositoryImporter(jobEntryInterface, stepMeta2, false);
    importerWithCompatibilityImportPath.setBaseDirectory(baseDirectory);
    importerWithCompatibilityImportPath.importTransformation(entityNode, feedback);
    verify((HasRepositoryDirectories) stepMeta2).setDirectories(new String[] { ROOT_PATH + "/${USER_VARIABLE}/myDir" });
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) 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