Search in sources :

Example 1 with IFieldMapping

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

the class AbstractStepMetaJsonSerializer method writeFieldMappings.

protected void writeFieldMappings(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
    json.writeArrayFieldStart(JSON_PROPERTY_MAPPINGS);
    IFieldLineageMetadataProvider mapper = getFieldLineageMetadataProvider(meta);
    try {
        Set<IFieldMapping> fieldMappings = mapper.getFieldMappings(meta);
        if (fieldMappings != null) {
            for (IFieldMapping fieldMapping : fieldMappings) {
                json.writeObject(fieldMapping);
            }
        }
    } catch (MetaverseAnalyzerException e) {
        LOGGER.warn(Messages.getString("WARNING.Serialization.Step.WriteFieldMappings", meta.getParentStepMeta().getName()), e);
    }
    json.writeEndArray();
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IFieldMapping(org.pentaho.metaverse.api.model.kettle.IFieldMapping)

Example 2 with IFieldMapping

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

the class AbstractStepMetaJsonSerializerTest method testWriteFieldMappings.

@Test
public void testWriteFieldMappings() throws Exception {
    Set<IFieldMapping> mappings = new HashSet<IFieldMapping>();
    FieldMapping fieldMapping1 = new FieldMapping("full name", "first name");
    FieldMapping fieldMapping2 = new FieldMapping("full name", "last name");
    mappings.add(fieldMapping1);
    mappings.add(fieldMapping2);
    IFieldLineageMetadataProvider mapper = mock(IFieldLineageMetadataProvider.class);
    AbstractStepMetaJsonSerializer spy = spy(serializer);
    when(spy.getFieldLineageMetadataProvider(spyMeta)).thenReturn(mapper);
    when(mapper.getFieldMappings(spyMeta)).thenReturn(mappings);
    spy.writeFieldMappings(spyMeta, json, provider);
    verify(json).writeObject(fieldMapping1);
    verify(json).writeObject(fieldMapping2);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) IFieldMapping(org.pentaho.metaverse.api.model.kettle.IFieldMapping) FieldMapping(org.pentaho.metaverse.api.model.kettle.FieldMapping) IFieldMapping(org.pentaho.metaverse.api.model.kettle.IFieldMapping) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

IFieldLineageMetadataProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider)2 IFieldMapping (org.pentaho.metaverse.api.model.kettle.IFieldMapping)2 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)1 FieldMapping (org.pentaho.metaverse.api.model.kettle.FieldMapping)1