use of org.pentaho.metaverse.api.analyzer.kettle.step.ExternalResourceStepAnalyzer.RESOURCE in project pentaho-metaverse by pentaho.
the class AnnotationDrivenStepMetaAnalyzer method linkResourceFieldToNode.
private void linkResourceFieldToNode(Map<AnnotatedClassField<Metaverse.Node>, IMetaverseNode> resourceNodes, Metaverse.NodeLink nodeLink, AnnotatedClassFields annoFields) {
IMetaverseNode resourceFieldNode = null;
// see if the link is pointing to an input/output field node
StepNodes stepNodes = isOutLink(nodeLink) ? getOutputs() : getInputs();
if (stepNodes != null && !stepNodes.getFieldNames().isEmpty()) {
resourceFieldNode = stepNodes.findNode(RESOURCE, nodeLink.nodeName());
}
if (resourceFieldNode == null) {
// link is probably to a resource node that isn't an input or output field
final StepNodes newStepNodeObj = new StepNodes();
resourceNodes.entrySet().stream().filter(mapEntry -> mapEntry.getValue().getProperty(PROPERTY_TYPE).equals(RESOURCE)).forEach(mapEntry -> newStepNodeObj.addNode(RESOURCE, mapEntry.getValue().getName(), mapEntry.getValue()));
stepNodes = newStepNodeObj;
resourceFieldNode = stepNodes.findNode(RESOURCE, nodeLink.nodeName());
}
IMetaverseNode childNode = resourceFieldNode;
if (childNode != null) {
annoFields.node(nodeLink.parentNodeName()).map(resourceNodes::get).ifPresent(parentNode -> addLink(nodeLink, childNode, parentNode));
} else {
String parentNodeLink = nodeLink.parentNodelink();
String fromNode = nodeLink.nodeName();
String toNode = nodeLink.parentNodeName();
log.warn(Messages.getErrorString("ERROR.AnnotationDrivenStepMetaAnalyzer.LinkError", parentNodeLink, fromNode, toNode));
}
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.ExternalResourceStepAnalyzer.RESOURCE in project pentaho-metaverse by pentaho.
the class AnnotationDrivenStepMetaAnalyzer method getOutputRowMetaInterfaces.
/**
* Adds any linked resource nodes to the output row meta.
* Applicable to something like a Message field being sent to an external queue.
*/
@Override
protected Map<String, RowMetaInterface> getOutputRowMetaInterfaces(BaseStepMeta meta) {
Map<String, RowMetaInterface> rowMetas = super.getOutputRowMetaInterfaces(meta);
AnnotatedClassFields nodeTree = new AnnotatedClassFields(meta);
RowMeta resourceRowMeta = new RowMeta();
new AnnotatedClassFields(meta).links().filter(field -> nodeTree.node(field.annotation.nodeName()).get().annotation.link().equals(LINK_OUTPUTS)).forEach(field -> resourceRowMeta.addValueMeta(new ValueMetaNone(field.name)));
if (resourceRowMeta.size() > 0) {
rowMetas.put(RESOURCE, resourceRowMeta);
}
return rowMetas;
}
Aggregations