Search in sources :

Example 1 with JobExecutorMeta

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;
}
Also used : ObjectLocationSpecificationMethod(org.pentaho.di.core.ObjectLocationSpecificationMethod) JobExecutorMeta(org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 2 with JobExecutorMeta

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);
        }
    }
}
Also used : JobExecutorMeta(org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta) TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) MappingMeta(org.pentaho.di.trans.steps.mapping.MappingMeta) SingleThreaderMeta(org.pentaho.di.trans.steps.singlethreader.SingleThreaderMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 3 with JobExecutorMeta

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);
}
Also used : JobExecutorMeta(org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 4 with JobExecutorMeta

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);
}
Also used : JobExecutorMeta(org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Aggregations

StepMeta (org.pentaho.di.trans.step.StepMeta)4 JobExecutorMeta (org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta)4 Test (org.junit.Test)2 TransMeta (org.pentaho.di.trans.TransMeta)2 ObjectLocationSpecificationMethod (org.pentaho.di.core.ObjectLocationSpecificationMethod)1 MappingMeta (org.pentaho.di.trans.steps.mapping.MappingMeta)1 SingleThreaderMeta (org.pentaho.di.trans.steps.singlethreader.SingleThreaderMeta)1 TransExecutorMeta (org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta)1