use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.
the class StepAnalyzerProviderTest method TestAddAndSetAnalyzers.
@Test
public void TestAddAndSetAnalyzers() {
final IStepAnalyzer analyzer1 = mock(IStepAnalyzer.class);
final IStepAnalyzer analyzer2 = mock(IStepAnalyzer.class);
List<IStepAnalyzer> analyzers = new ArrayList();
analyzers.add(analyzer1);
analyzers.add(analyzer2);
provider.setStepAnalyzers(analyzers);
assertEquals(2, provider.getAnalyzers().size());
// verify that duplicate analyzers aren't added to the list
provider.setStepAnalyzers(analyzers);
assertEquals(2, provider.getAnalyzers().size());
provider.setStepAnalyzers(null);
assertNull(provider.getAnalyzers());
// verify that "clonable" analyzers are added to the main analyzers list
provider.setClonableStepAnalyzers(analyzers);
assertEquals(2, provider.getAnalyzers().size());
// and that duplicate clonable analyzers aren't added to the list
provider.setClonableStepAnalyzers(analyzers);
assertEquals(2, provider.getAnalyzers().size());
provider.setClonableStepAnalyzers(null);
assertNull(provider.getAnalyzers());
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer in project pentaho-metaverse by pentaho.
the class TransformationAnalyzer method getStepAnalyzers.
protected Set<IStepAnalyzer> getStepAnalyzers(final StepMeta stepMeta) {
Set<IStepAnalyzer> stepAnalyzers = new HashSet<IStepAnalyzer>();
// Attempt to discover a BaseStepMeta from the given StepMeta
BaseStepMeta baseStepMeta = getBaseStepMetaFromStepMeta(stepMeta);
stepAnalyzerProvider = getStepAnalyzerProvider();
if (stepAnalyzerProvider != null) {
if (baseStepMeta == null) {
stepAnalyzers.addAll(stepAnalyzerProvider.getAnalyzers());
} else {
Set<Class<?>> analyzerClassSet = new HashSet<Class<?>>(1);
analyzerClassSet.add(baseStepMeta.getClass());
stepAnalyzers.addAll(stepAnalyzerProvider.getAnalyzers(analyzerClassSet));
}
} else {
stepAnalyzers.add(new GenericStepMetaAnalyzer());
}
return stepAnalyzers;
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer 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.IStepAnalyzer 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.IStepAnalyzer in project pentaho-metaverse by pentaho.
the class AnalyzerInfoService method getSupportedSteps.
/**
* Gets a list of all implementations of {@link BaseStepMeta} with a custom {@link IStepAnalyzer}
* that produces lineage. Any step not found in this list will fall back to using
* {@link org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer}.
*
* <p><b>Example Request:</b><br />
* GET pentaho-di/osgi/cxf/lineage/info/steps
* </p>
*
* @return List of {@link AnalyzerInfo}
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.js">
* [ { meta: "CalculatorMeta" }, { meta: "CsvInputMeta" }, { meta: "ExcelInputMeta" } ]
* </pre>
*/
@GET
@Path("/steps")
@Produces({ MediaType.APPLICATION_JSON })
@StatusCodes({ @ResponseCode(code = OK, condition = "Successfully listed the supported steps"), @ResponseCode(code = SERVER_ERROR, condition = "Server Error.") })
public Response getSupportedSteps() {
List<AnalyzerInfo> analyzers = new ArrayList<>();
for (IStepAnalyzer analyzer : getStepAnalyzerProvider().getAnalyzers()) {
Set<Class<? extends BaseStepMeta>> supportedSteps = analyzer.getSupportedSteps();
for (Class<? extends BaseStepMeta> supportedStep : supportedSteps) {
AnalyzerInfo info = new AnalyzerInfo(supportedStep.getSimpleName());
analyzers.add(info);
}
}
Collections.sort(analyzers, new AnalyzerInfoComparator());
return Response.ok(analyzers).build();
}
Aggregations