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);
}
}
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;
}
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}" });
}
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}" });
}
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" });
}
Aggregations