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();
}
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);
}
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);
}
Aggregations