Search in sources :

Example 1 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 2 with StepField

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

the class MetaInjectAnalyzer method getUsedFields.

@Override
protected Set<StepField> getUsedFields(MetaInjectMeta meta) {
    final Set<StepField> usedFields = new HashSet();
    final Iterator<Map.Entry<TargetStepAttribute, SourceStepField>> fieldMappingsIter = meta.getTargetSourceMapping().entrySet().iterator();
    while (fieldMappingsIter.hasNext()) {
        final Map.Entry<TargetStepAttribute, SourceStepField> entry = fieldMappingsIter.next();
        final SourceStepField value = entry.getValue();
        final Iterator<StepField> stepFields = createStepFields(value.getField(), getInputs()).iterator();
        while (stepFields.hasNext()) {
            final StepField stepField = stepFields.next();
            usedFields.add(stepField);
        }
    }
    return usedFields;
}
Also used : StepField(org.pentaho.metaverse.api.StepField) SourceStepField(org.pentaho.di.trans.steps.metainject.SourceStepField) TargetStepAttribute(org.pentaho.di.trans.steps.metainject.TargetStepAttribute) Map(java.util.Map) SourceStepField(org.pentaho.di.trans.steps.metainject.SourceStepField) HashSet(java.util.HashSet)

Example 3 with StepField

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

the class JsonInputAnalyzerTest method testGetUsedFields_fileNameFromField.

@Test
public void testGetUsedFields_fileNameFromField() throws Exception {
    when(meta.isAcceptingFilenames()).thenReturn(true);
    when(meta.getAcceptingField()).thenReturn("filename");
    Set<String> stepNames = new HashSet<>();
    stepNames.add("previousStep");
    Set<StepField> usedFields = analyzer.getUsedFields(meta);
    assertNotNull(usedFields);
    assertEquals(1, usedFields.size());
    StepField used = usedFields.iterator().next();
    assertEquals("previousStep", used.getStepName());
    assertEquals("filename", used.getFieldName());
}
Also used : StepField(org.pentaho.metaverse.api.StepField) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with StepField

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

the class ConnectionExternalResourceStepAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    analyzer = spy(new ConnectionExternalResourceStepAnalyzer<BaseStepMeta>() {

        @Override
        protected IMetaverseNode createTableNode(IExternalResourceInfo resource) throws MetaverseAnalyzerException {
            return tableNode;
        }

        @Override
        public String getResourceInputNodeType() {
            return "INPUT_TYPE";
        }

        @Override
        public String getResourceOutputNodeType() {
            return "OUTPUT_TYPE";
        }

        @Override
        public boolean isOutput() {
            return false;
        }

        @Override
        public boolean isInput() {
            return true;
        }

        @Override
        protected Set<StepField> getUsedFields(BaseStepMeta meta) {
            Set<StepField> stepFields = new HashSet<>();
            stepFields.add(new StepField("prevStep", "filename"));
            return stepFields;
        }

        @Override
        public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
            return null;
        }
    });
    when(analyzer.getMetaverseBuilder()).thenReturn(builder);
    analyzer.descriptor = descriptor;
    when(descriptor.getContext()).thenReturn(context);
    analyzer.parentTransMeta = parentTransMeta;
    analyzer.parentStepMeta = parentStepMeta;
    analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) MetaverseObjectFactory(org.pentaho.metaverse.api.MetaverseObjectFactory) StepField(org.pentaho.metaverse.api.StepField) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 5 with StepField

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

the class StepAnalyzerTest method testMapChange.

@Test
public void testMapChange() throws Exception {
    doReturn(outputs).when(analyzer).getOutputs();
    doReturn(inputs).when(analyzer).getInputs();
    Operation operation = new Operation("testOperation", "testOperation");
    StepField original = new StepField("previousStep", "address");
    StepField changed = new StepField("nextStep", "address");
    ComponentDerivationRecord cdr = new ComponentDerivationRecord(original, changed);
    cdr.addOperation(operation);
    ComponentDerivationRecord spyCdr = spy(cdr);
    analyzer.mapChange(spyCdr);
    // get operations to verify it is not null, then agains to toString it
    verify(spyCdr, times(1)).getOperations();
    verify(analyzer).linkChangeNodes(any(IMetaverseNode.class), any(IMetaverseNode.class));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepField(org.pentaho.metaverse.api.StepField) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operation(org.pentaho.metaverse.api.model.Operation) Test(org.junit.Test)

Aggregations

StepField (org.pentaho.metaverse.api.StepField)55 Test (org.junit.Test)33 HashSet (java.util.HashSet)24 ClonableStepAnalyzerTest (org.pentaho.metaverse.analyzer.kettle.step.ClonableStepAnalyzerTest)11 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)11 StepNodes (org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)11 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