Search in sources :

Example 1 with TransExecutorMeta

use of org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta 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 2 with TransExecutorMeta

use of org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testTransExecutorStepNode.

@Test
public void testTransExecutorStepNode() throws Exception {
    TransExecutorStepNode transExecutorStepNode = root.getTransExecutorStepNode();
    assertNotNull(transExecutorStepNode);
    TransExecutorMeta meta = (TransExecutorMeta) getStepMeta(transExecutorStepNode);
    assertEquals(meta.getParentStepMeta().getName(), transExecutorStepNode.getName());
    assertEquals(meta.getOutputRowsSourceStep(), transExecutorStepNode.getOutputRowsTargetStepName());
    assertEquals(meta.getResultFilesTargetStep(), transExecutorStepNode.getResultFilesTargetStepName());
    assertEquals(meta.getExecutionResultTargetStep(), transExecutorStepNode.getExecutionResultsTargetStepName());
    assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getOutputRowsSourceStep()));
    assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getResultFilesTargetStep()));
    assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getExecutionResultTargetStep()));
    RowMetaInterface incomingRow = meta.getParentStepMeta().getParentTransMeta().getPrevStepFields(meta.getParentStepMeta());
    int incomingFieldCount = incomingRow.size();
    Iterable<StreamFieldNode> streamFieldNodes = transExecutorStepNode.getOutputStreamFields();
    int countOutputStreamFieldNode = getIterableSize(streamFieldNodes);
    List<String> outputFields = Arrays.asList(meta.getOutputRowsField());
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertNotNull(streamFieldNode.getKettleType());
        if (outputFields.contains(streamFieldNode.getName())) {
            // this field came back to us from the sub trans via a result, lets make sure they link up
            assertEquals(transExecutorStepNode.getTransToExecute(), streamFieldNode.getFieldNodesThatDeriveMe().iterator().next().getStepThatOutputsMe().getTransNode());
        }
    }
    streamFieldNodes = transExecutorStepNode.getStreamFieldNodesDeletes();
    int countDeletedStreamFieldNode = getIterableSize(streamFieldNodes);
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertNotNull(streamFieldNode.getKettleType());
    }
    assertNotNull(transExecutorStepNode.getTransToExecute());
    streamFieldNodes = transExecutorStepNode.getStreamFieldNodesUses();
    int countUsedStreamFieldNode = getIterableSize(streamFieldNodes);
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertNotNull(streamFieldNode.getKettleType());
        // these should link up to stream fields in the sub trans via the "get rows from result" step
        for (StreamFieldNode derived : streamFieldNode.getFieldNodesDerivedFromMe()) {
            // the trans that is to be executed should contain the step that creates a field derived from the incoming field
            assertEquals(transExecutorStepNode.getTransToExecute(), derived.getStepThatInputsMe().getTransNode());
        }
    }
    assertEquals(incomingFieldCount, countUsedStreamFieldNode);
}
Also used : TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) TransExecutorStepNode(org.pentaho.metaverse.frames.TransExecutorStepNode) Test(org.junit.Test)

Example 3 with TransExecutorMeta

use of org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta in project pentaho-kettle by pentaho.

the class TransFileListenerTest method testProcessLinkedTransWithFilename.

@Test
public void testProcessLinkedTransWithFilename() {
    TransExecutorMeta transExecutorMeta = spy(new TransExecutorMeta());
    transExecutorMeta.setFileName("/path/to/Transformation2.ktr");
    transExecutorMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
    StepMeta transExecutorStep = mock(StepMeta.class);
    when(transExecutorStep.getStepID()).thenReturn("TransExecutor");
    when(transExecutorStep.getStepMetaInterface()).thenReturn(transExecutorMeta);
    TransMeta parent = mock(TransMeta.class);
    when(parent.getSteps()).thenReturn(Arrays.asList(transExecutorStep));
    TransMeta result = transFileListener.processLinkedTrans(parent);
    boolean found = false;
    for (StepMeta stepMeta : result.getSteps()) {
        if (stepMeta.getStepID().equalsIgnoreCase("TransExecutor")) {
            found = true;
            TransExecutorMeta resultExecMeta = (TransExecutorMeta) stepMeta.getStepMetaInterface();
            assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
            assertEquals(resultExecMeta.getDirectoryPath(), "/path/to");
            assertEquals(resultExecMeta.getTransName(), "Transformation2");
        }
    }
    assertTrue(found);
}
Also used : TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 4 with TransExecutorMeta

use of org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta in project pentaho-kettle by pentaho.

the class TransFileListenerTest method testProcessLinkedTransWithNoFilename.

@Test
public void testProcessLinkedTransWithNoFilename() {
    TransExecutorMeta transExecutorMeta = spy(new TransExecutorMeta());
    transExecutorMeta.setFileName(null);
    transExecutorMeta.setDirectoryPath("/path/to");
    transExecutorMeta.setTransName("Transformation2");
    transExecutorMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    StepMeta transExecutorStep = mock(StepMeta.class);
    when(transExecutorStep.getStepID()).thenReturn("TransExecutor");
    when(transExecutorStep.getStepMetaInterface()).thenReturn(transExecutorMeta);
    TransMeta parent = mock(TransMeta.class);
    when(parent.getSteps()).thenReturn(Arrays.asList(transExecutorStep));
    TransMeta result = transFileListener.processLinkedTrans(parent);
    boolean found = false;
    for (StepMeta stepMeta : result.getSteps()) {
        if (stepMeta.getStepID().equalsIgnoreCase("TransExecutor")) {
            found = true;
            TransExecutorMeta resultExecMeta = (TransExecutorMeta) stepMeta.getStepMetaInterface();
            assertEquals(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod());
            assertEquals(resultExecMeta.getDirectoryPath(), "/path/to");
            assertEquals(resultExecMeta.getTransName(), "Transformation2");
        }
    }
    assertTrue(found);
}
Also used : TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 5 with TransExecutorMeta

use of org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta in project pentaho-kettle by pentaho.

the class TransFileListener method processLinkedTrans.

protected TransMeta processLinkedTrans(TransMeta transMeta) {
    for (StepMeta stepMeta : transMeta.getSteps()) {
        if (stepMeta.getStepID().equalsIgnoreCase("TransExecutor")) {
            TransExecutorMeta tem = (TransExecutorMeta) stepMeta.getStepMetaInterface();
            ObjectLocationSpecificationMethod specMethod = tem.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) {
                tem.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                String filename = tem.getFileName();
                String jobname = filename.substring(filename.lastIndexOf("/") + 1, filename.lastIndexOf('.'));
                String directory = filename.substring(0, filename.lastIndexOf("/"));
                tem.setTransName(jobname);
                tem.setDirectoryPath(directory);
            }
        }
    }
    return transMeta;
}
Also used : ObjectLocationSpecificationMethod(org.pentaho.di.core.ObjectLocationSpecificationMethod) TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Aggregations

TransExecutorMeta (org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta)5 StepMeta (org.pentaho.di.trans.step.StepMeta)4 Test (org.junit.Test)3 TransMeta (org.pentaho.di.trans.TransMeta)2 ObjectLocationSpecificationMethod (org.pentaho.di.core.ObjectLocationSpecificationMethod)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 JobExecutorMeta (org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta)1 MappingMeta (org.pentaho.di.trans.steps.mapping.MappingMeta)1 SingleThreaderMeta (org.pentaho.di.trans.steps.singlethreader.SingleThreaderMeta)1 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)1 TransExecutorStepNode (org.pentaho.metaverse.frames.TransExecutorStepNode)1