use of org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta in project pentaho-kettle by pentaho.
the class TransFileListener method processLinkedJobs.
protected TransMeta processLinkedJobs(TransMeta transMeta) {
for (StepMeta stepMeta : transMeta.getSteps()) {
if (stepMeta.getStepID().equalsIgnoreCase("JobExecutor")) {
JobExecutorMeta jem = (JobExecutorMeta) stepMeta.getStepMetaInterface();
ObjectLocationSpecificationMethod specMethod = jem.getSpecificationMethod();
// If the reference is by filename, change it to Repository By Name. Otherwise it's fine so leave it alone
if (specMethod == ObjectLocationSpecificationMethod.FILENAME) {
jem.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
String filename = jem.getFileName();
String jobname = filename.substring(filename.lastIndexOf("/") + 1, filename.lastIndexOf('.'));
String directory = filename.substring(0, filename.lastIndexOf("/"));
jem.setJobName(jobname);
jem.setDirectoryPath(directory);
}
}
}
return transMeta;
}
use of org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta in project pentaho-kettle by pentaho.
the class TransMeta method setRepositoryOnMappingSteps.
/**
* Set the Repository object on the Mapping step That way the mapping step can determine the output fields for
* repository hosted mappings... This is the exception to the rule so we don't pass this through the getFields()
* method. TODO: figure out a way to make this more generic.
*/
private void setRepositoryOnMappingSteps() {
for (StepMeta step : steps) {
if (step.getStepMetaInterface() instanceof MappingMeta) {
((MappingMeta) step.getStepMetaInterface()).setRepository(repository);
((MappingMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
}
if (step.getStepMetaInterface() instanceof SingleThreaderMeta) {
((SingleThreaderMeta) step.getStepMetaInterface()).setRepository(repository);
((SingleThreaderMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
}
if (step.getStepMetaInterface() instanceof JobExecutorMeta) {
((JobExecutorMeta) step.getStepMetaInterface()).setRepository(repository);
((JobExecutorMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
}
if (step.getStepMetaInterface() instanceof TransExecutorMeta) {
((TransExecutorMeta) step.getStepMetaInterface()).setRepository(repository);
((TransExecutorMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
}
}
}
use of org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta in project pentaho-kettle by pentaho.
the class TransFileListenerTest method testProcessLinkedJobsWithFilename.
@Test
public void testProcessLinkedJobsWithFilename() {
JobExecutorMeta jobExecutorMeta = spy(new JobExecutorMeta());
jobExecutorMeta.setFileName("/path/to/Job1.kjb");
jobExecutorMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
StepMeta jobExecutorStep = mock(StepMeta.class);
when(jobExecutorStep.getStepID()).thenReturn("JobExecutor");
when(jobExecutorStep.getStepMetaInterface()).thenReturn(jobExecutorMeta);
TransMeta parent = mock(TransMeta.class);
when(parent.getSteps()).thenReturn(Arrays.asList(jobExecutorStep));
TransMeta result = transFileListener.processLinkedJobs(parent);
boolean found = false;
for (StepMeta stepMeta : result.getSteps()) {
if (stepMeta.getStepID().equalsIgnoreCase("JobExecutor")) {
found = true;
JobExecutorMeta resultExecMeta = (JobExecutorMeta) stepMeta.getStepMetaInterface();
assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
assertEquals(resultExecMeta.getDirectoryPath(), "/path/to");
assertEquals(resultExecMeta.getJobName(), "Job1");
}
}
assertTrue(found);
}
use of org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta in project pentaho-kettle by pentaho.
the class TransFileListenerTest method testProcessLinkedJobsWithNoFilename.
@Test
public void testProcessLinkedJobsWithNoFilename() {
JobExecutorMeta jobExecutorMeta = spy(new JobExecutorMeta());
jobExecutorMeta.setFileName(null);
jobExecutorMeta.setDirectoryPath("/path/to");
jobExecutorMeta.setJobName("Job1");
jobExecutorMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
StepMeta transExecutorStep = mock(StepMeta.class);
when(transExecutorStep.getStepID()).thenReturn("JobExecutor");
when(transExecutorStep.getStepMetaInterface()).thenReturn(jobExecutorMeta);
TransMeta parent = mock(TransMeta.class);
when(parent.getSteps()).thenReturn(Arrays.asList(transExecutorStep));
TransMeta result = transFileListener.processLinkedJobs(parent);
boolean found = false;
for (StepMeta stepMeta : result.getSteps()) {
if (stepMeta.getStepID().equalsIgnoreCase("JobExecutor")) {
found = true;
JobExecutorMeta resultExecMeta = (JobExecutorMeta) stepMeta.getStepMetaInterface();
assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
assertEquals(resultExecMeta.getDirectoryPath(), "/path/to");
assertEquals(resultExecMeta.getJobName(), "Job1");
}
}
assertTrue(found);
}
Aggregations