Search in sources :

Example 6 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class TransExecutorStepAnalyzer method connectToSubTransInputFields.

/**
 * Add links from all incoming stream fields to the fields in the sub transformation
 * @param meta
 * @param subTransMeta
 * @param subTransNode
 * @param descriptor
 */
protected void connectToSubTransInputFields(TransExecutorMeta meta, TransMeta subTransMeta, IMetaverseNode subTransNode, IComponentDescriptor descriptor) {
    Set<StepField> incomingFields = getInputs().getFieldNames();
    for (StepField field : incomingFields) {
        IMetaverseNode inputNode = getInputs().findNode(field);
        linkUsedFieldToSubTrans(inputNode, subTransMeta, subTransNode, descriptor);
    }
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepField(org.pentaho.metaverse.api.StepField)

Example 7 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class LineageClientIT method testGetOriginSteps.

@Test
public void testGetOriginSteps() throws Exception {
    Set<StepField> originStepsSet;
    Map<String, Set<StepField>> originSteps;
    originSteps = client.getOriginSteps(transMeta, "Select values", Arrays.asList("HELLO"));
    assertNotNull(originSteps);
    assertEquals(1, originSteps.size());
    originStepsSet = originSteps.get("HELLO");
    assertNotNull(originStepsSet);
    assertEquals(2, originStepsSet.size());
    // We're not sure which step will be in which order, but both fields are named COUNTRY
    for (StepField stepField : originStepsSet) {
        assertEquals("COUNTRY", stepField.getFieldName());
    }
    originSteps = client.getOriginSteps(transMeta, "Passthru", Arrays.asList("COUNTRY", "COUNTRY_1"));
    assertNotNull(originSteps);
    assertEquals(2, originSteps.size());
    for (Set<StepField> originStepsSetValues : originSteps.values()) {
        assertNotNull(originStepsSetValues);
        assertEquals(2, originStepsSetValues.size());
        // We're not sure which step will be in which order, but both fields are named COUNTRY
        for (StepField stepField : originStepsSetValues) {
            assertEquals("COUNTRY", stepField.getFieldName());
        }
    }
    originSteps = client.getOriginSteps(transMeta, "Select values", Arrays.asList("COUNTRY", "COUNTRY_1", "HELLO"));
    assertNotNull(originSteps);
    assertEquals(1, originSteps.size());
    for (String stepName : originSteps.keySet()) {
        // Only HELLO will return values
        if (!"HELLO".equals(stepName)) {
            assertEquals(0, originSteps.get(stepName).size());
        } else {
            Set<StepField> originStepsSetValues = originSteps.get(stepName);
            assertNotNull(originStepsSetValues);
            assertEquals(2, originStepsSetValues.size());
            // We're not sure which step will be in which order, but both fields are named COUNTRY
            for (StepField stepField : originStepsSetValues) {
                assertEquals("COUNTRY", stepField.getFieldName());
            }
        }
    }
}
Also used : Set(java.util.Set) StepField(org.pentaho.metaverse.api.StepField) Test(org.junit.Test)

Example 8 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class ExcelInputStepAnalyzer method getUsedFields.

@Override
protected Set<StepField> getUsedFields(ExcelInputMeta meta) {
    Set<StepField> usedFields = new HashSet<>();
    if (meta.isAcceptingFilenames() && StringUtils.isNotEmpty(meta.getAcceptingStepName())) {
        StepField stepField = new StepField(meta.getAcceptingStepName(), meta.getAcceptingField());
        usedFields.add(stepField);
    }
    return usedFields;
}
Also used : StepField(org.pentaho.metaverse.api.StepField) HashSet(java.util.HashSet)

Example 9 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class TextFileInputStepAnalyzer method getUsedFields.

@Override
protected Set<StepField> getUsedFields(TextFileInputMeta meta) {
    Set<StepField> usedFields = new HashSet<>();
    if (meta.isAcceptingFilenames() && StringUtils.isNotEmpty(meta.getAcceptingStepName())) {
        StepField stepField = new StepField(meta.getAcceptingStepName(), meta.getAcceptingField());
        usedFields.add(stepField);
    }
    return usedFields;
}
Also used : StepField(org.pentaho.metaverse.api.StepField) HashSet(java.util.HashSet)

Example 10 with StepField

use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.

the class FilterRowsStepAnalyzer method getUsedFields.

@Override
protected Set<StepField> getUsedFields(FilterRowsMeta meta) {
    // add uses links to all of the fields that are part of the filter condition
    Set<StepField> usedFields = new HashSet<>();
    final Condition condition = meta.getCondition();
    if (condition != null) {
        for (String usedField : condition.getUsedFields()) {
            usedFields.addAll(createStepFields(usedField, getInputs()));
        }
    }
    return usedFields;
}
Also used : Condition(org.pentaho.di.core.Condition) StepField(org.pentaho.metaverse.api.StepField) HashSet(java.util.HashSet)

Aggregations

StepField (org.pentaho.metaverse.api.StepField)53 Test (org.junit.Test)33 HashSet (java.util.HashSet)23 StepNodes (org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)11 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)10 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)10 Matchers.anyString (org.mockito.Matchers.anyString)6 Before (org.junit.Before)4 SelectMetadataChange (org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange)4 Set (java.util.Set)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 MetaverseObjectFactory (org.pentaho.metaverse.api.MetaverseObjectFactory)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)2 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Graph (com.tinkerpop.blueprints.Graph)1 Vertex (com.tinkerpop.blueprints.Vertex)1