use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzerTest method testGetUsedFields.
@Test
public void testGetUsedFields() throws Exception {
IMetaverseNode outNode = mock(IMetaverseNode.class);
StepNodes inputs = new StepNodes();
inputs.addNode("previousStep", "one", outNode);
inputs.addNode("previousStep", "two", outNode);
doReturn(inputs).when(spyAnalyzer).getInputs();
Set<StepField> usedFields = spyAnalyzer.getUsedFields(meta);
assertEquals(inputs.getFieldNames(), usedFields);
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzerTest method testIsPassthrough.
@Test
public void testIsPassthrough() throws Exception {
StepField stepField = new StepField("previousStep", "one");
assertFalse(spyAnalyzer.isPassthrough(stepField));
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class StepAnalyzer method getPassthroughChanges.
/**
* Get ComponentDerivationRecords for each of the fields considered to be a passthrough
*
* @return
*/
protected Set<ComponentDerivationRecord> getPassthroughChanges() {
Set<ComponentDerivationRecord> passthroughs = new HashSet<>();
if (getInputs() != null) {
Set<StepField> incomingFieldNames = getInputs().getFieldNames();
for (StepField incomingFieldName : incomingFieldNames) {
if (isPassthrough(incomingFieldName)) {
ComponentDerivationRecord change = new ComponentDerivationRecord(incomingFieldName.getFieldName(), incomingFieldName.getFieldName());
change.setOriginalEntityStepName(incomingFieldName.getStepName());
passthroughs.add(change);
}
}
}
return passthroughs;
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class StepAnalyzer method analyze.
@Override
public IMetaverseNode analyze(IComponentDescriptor descriptor, T meta) throws MetaverseAnalyzerException {
setDescriptor(descriptor);
baseStepMeta = meta;
validateState(descriptor, meta);
// Add yourself
rootNode = createNodeFromDescriptor(descriptor);
String stepType = null;
try {
stepType = PluginRegistry.getInstance().findPluginWithId(StepPluginType.class, parentStepMeta.getStepID()).getName();
} catch (Throwable t) {
stepType = parentStepMeta.getStepID();
}
rootNode.setProperty("pluginId", parentStepMeta.getStepID());
rootNode.setProperty("stepType", stepType);
rootNode.setProperty("copies", meta.getParentStepMeta().getCopies());
rootNode.setProperty("_analyzer", this.getClass().getSimpleName());
metaverseBuilder.addNode(rootNode);
inputs = processInputs(meta);
outputs = processOutputs(meta);
Set<StepField> usedFields = getUsedFields(meta);
if (CollectionUtils.isNotEmpty(usedFields)) {
processUsedFields(usedFields);
}
Set<ComponentDerivationRecord> changes = getChanges();
for (ComponentDerivationRecord change : changes) {
mapChange(change);
}
customAnalyze(meta, rootNode);
return rootNode;
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
analyzer = spy(new ExternalResourceStepAnalyzer<BaseStepMeta>() {
@Override
public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
return null;
}
@Override
protected Set<StepField> getUsedFields(BaseStepMeta meta) {
Set<StepField> stepFields = new HashSet<>();
stepFields.add(new StepField("prevStep", "filename"));
return stepFields;
}
@Override
public IMetaverseNode createResourceNode(IExternalResourceInfo resource) throws MetaverseException {
return resourceNode;
}
@Override
public String getResourceInputNodeType() {
return "INPUT_TYPE";
}
@Override
public String getResourceOutputNodeType() {
return "OUTPUT_TYPE";
}
@Override
public boolean isOutput() {
return false;
}
@Override
public boolean isInput() {
return true;
}
});
when(analyzer.getMetaverseBuilder()).thenReturn(builder);
analyzer.descriptor = descriptor;
analyzer.parentTransMeta = parentTransMeta;
analyzer.parentStepMeta = parentStepMeta;
analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
}
Aggregations