Search in sources :

Example 6 with ComponentDerivationRecord

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

the class StringsReplaceStepAnalyzer method getChangeRecords.

@Override
public Set<ComponentDerivationRecord> getChangeRecords(final ReplaceStringMeta stringsReplaceMeta) throws MetaverseAnalyzerException {
    renameIndex.clear();
    Set<ComponentDerivationRecord> changeRecords = new HashSet<ComponentDerivationRecord>();
    for (int i = 0; i < stringsReplaceMeta.getFieldInStream().length; i++) {
        ComponentDerivationRecord changeRecord = buildChangeRecord(stringsReplaceMeta, i);
        changeRecords.add(changeRecord);
    }
    return changeRecords;
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) HashSet(java.util.HashSet)

Example 7 with ComponentDerivationRecord

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

the class AbstractStepMetaJsonSerializer method writeFieldTransforms.

protected void writeFieldTransforms(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
    json.writeArrayFieldStart(JSON_PROPERTY_TRANSFORMS);
    IFieldLineageMetadataProvider mapper = getFieldLineageMetadataProvider(meta);
    try {
        Set<ComponentDerivationRecord> changes = mapper.getChangeRecords(meta);
        if (changes != null) {
            for (ComponentDerivationRecord change : changes) {
                if (change.hasDelta()) {
                    json.writeObject(change);
                }
            }
        }
    } catch (MetaverseAnalyzerException e) {
        LOGGER.warn(Messages.getString("WARNING.Serialization.Step.WriteFieldTransforms", meta.getParentStepMeta().getName()), e);
    }
    json.writeEndArray();
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)

Example 8 with ComponentDerivationRecord

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

the class SplitFieldsStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(meta);
    assertEquals(3, changeRecords.size());
    for (ComponentDerivationRecord changeRecord : changeRecords) {
        assertEquals("splitField", changeRecord.getOriginalEntityName());
        assertTrue(ArrayUtils.contains(outputFields, changeRecord.getChangedEntityName()));
        Operations operations = changeRecord.getOperations();
        // Only data operations
        assertEquals(1, operations.size());
        List<IOperation> dataOperations = operations.get(ChangeType.DATA);
        assertEquals(1, dataOperations.size());
    }
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 9 with ComponentDerivationRecord

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

the class StringsCutStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(stringsCutMeta);
    assertEquals(changeRecords.size(), 3);
    List<String> inFields = Arrays.asList(stringsCutMeta.getFieldInStream());
    for (ComponentDerivationRecord change : changeRecords) {
        assertTrue(inFields.contains(change.getOriginalEntityName()));
        assertEquals(1, change.getOperations(ChangeType.DATA).size());
        assertNull(change.getOperations(ChangeType.METADATA));
    }
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with ComponentDerivationRecord

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

the class StringsReplaceStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(stringsReplaceMeta);
    assertEquals(changeRecords.size(), 3);
    List<String> inFields = Arrays.asList(stringsReplaceMeta.getFieldInStream());
    for (ComponentDerivationRecord change : changeRecords) {
        assertTrue(inFields.contains(change.getOriginalEntityName()));
        assertEquals(1, change.getOperations(ChangeType.DATA).size());
        assertNull(change.getOperations(ChangeType.METADATA));
    }
}
Also used : ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)43 Test (org.junit.Test)23 HashSet (java.util.HashSet)21 StepField (org.pentaho.metaverse.api.StepField)11 Operation (org.pentaho.metaverse.api.model.Operation)11 Matchers.anyString (org.mockito.Matchers.anyString)5 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)5 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)5 IOperation (org.pentaho.metaverse.api.model.IOperation)3 Operations (org.pentaho.metaverse.api.model.Operations)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 SelectMetadataChange (org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange)2 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)2 IFieldLineageMetadataProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider)2 StepNodes (org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Condition (org.pentaho.di.core.Condition)1 CalculatorMetaFunction (org.pentaho.di.trans.steps.calculator.CalculatorMetaFunction)1 NumberRangeRule (org.pentaho.di.trans.steps.numberrange.NumberRangeRule)1