Search in sources :

Example 1 with IStepAnalyzerProvider

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

the class AbstractStepMetaJsonSerializer method getFieldLineageMetadataProvider.

protected IFieldLineageMetadataProvider getFieldLineageMetadataProvider(T meta) {
    IStepAnalyzerProvider provider = getStepAnalyzerProvider();
    if (provider == null) {
        // try to get it from PentahoSystem
        provider = PentahoSystem.get(IStepAnalyzerProvider.class);
    }
    if (provider != null) {
        Set<Class<?>> types = new HashSet<Class<?>>();
        types.add(meta.getClass());
        List<IStepAnalyzer> analyzers = provider.getAnalyzers(types);
        if (analyzers != null) {
            for (IStepAnalyzer analyzer : analyzers) {
                // try to set up the analyzer with parent step & trans meta
                if (analyzer instanceof StepAnalyzer) {
                    StepAnalyzer bsa = (StepAnalyzer) analyzer;
                    try {
                        bsa.validateState(null, meta);
                        bsa.loadInputAndOutputStreamFields(meta);
                    } catch (MetaverseAnalyzerException e) {
                    // eat it
                    }
                }
                if (analyzer instanceof IFieldLineageMetadataProvider) {
                    return (IFieldLineageMetadataProvider) analyzer;
                }
            }
        }
    }
    return new GenericStepMetaAnalyzer();
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) StepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.StepAnalyzer) IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) IStepAnalyzerProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider) HashSet(java.util.HashSet) GenericStepMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)

Example 2 with IStepAnalyzerProvider

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

the class AbstractStepMetaJsonSerializerTest method testGetStepFieldMapper.

@Test
public void testGetStepFieldMapper() throws Exception {
    IStepAnalyzerProvider provider = mock(IStepAnalyzerProvider.class);
    IStepAnalyzer<DummyTransMeta> analyzer = mock(IStepAnalyzer.class, withSettings().extraInterfaces(IFieldLineageMetadataProvider.class));
    List<IStepAnalyzer> analyzers = new ArrayList<IStepAnalyzer>(1);
    analyzers.add(analyzer);
    when(provider.getAnalyzers(any(Set.class))).thenReturn(analyzers);
    serializer.setStepAnalyzerProvider(provider);
    IFieldLineageMetadataProvider handler = serializer.getFieldLineageMetadataProvider(spyMeta);
    assertFalse(handler instanceof GenericStepMetaAnalyzer);
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) IStepAnalyzerProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) GenericStepMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer) Test(org.junit.Test)

Example 3 with IStepAnalyzerProvider

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

the class AbstractStepMetaJsonSerializerTest method testGetStepFieldMapper_noProviderAvailable.

@Test
public void testGetStepFieldMapper_noProviderAvailable() throws Exception {
    IStepAnalyzerProvider provider = mock(IStepAnalyzerProvider.class);
    when(provider.getAnalyzers(any(Set.class))).thenReturn(null);
    serializer.setStepAnalyzerProvider(provider);
    IFieldLineageMetadataProvider handler = serializer.getFieldLineageMetadataProvider(spyMeta);
    assertTrue(handler instanceof GenericStepMetaAnalyzer);
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) HashSet(java.util.HashSet) Set(java.util.Set) IStepAnalyzerProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider) GenericStepMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)3 GenericStepMetaAnalyzer (org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)3 IFieldLineageMetadataProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider)3 IStepAnalyzerProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider)3 Set (java.util.Set)2 Test (org.junit.Test)2 IStepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer)2 ArrayList (java.util.ArrayList)1 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)1 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)1 StepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.StepAnalyzer)1