Search in sources :

Example 1 with RESOURCE

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));
    }
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) KettleAnalyzerUtil(org.pentaho.metaverse.api.analyzer.kettle.KettleAnalyzerUtil) KettleException(org.pentaho.di.core.exception.KettleException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Messages(org.pentaho.metaverse.api.messages.Messages) SubtransAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.SubtransAnalyzer) LoggerFactory(org.slf4j.LoggerFactory) StepField(org.pentaho.metaverse.api.StepField) LINK_OUTPUTS(org.pentaho.dictionary.DictionaryConst.LINK_OUTPUTS) TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PROPERTY_TYPE(org.pentaho.dictionary.DictionaryConst.PROPERTY_TYPE) StepWithMappingMeta(org.pentaho.di.trans.StepWithMappingMeta) TransMeta(org.pentaho.di.trans.TransMeta) Collectors.toMap(java.util.stream.Collectors.toMap) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) VariableSpace(org.pentaho.di.core.variables.VariableSpace) StepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.StepAnalyzer) Collectors.toSet(java.util.stream.Collectors.toSet) Logger(org.slf4j.Logger) DictionaryHelper(org.pentaho.dictionary.DictionaryHelper) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) Set(java.util.Set) BaseStreamStepMeta(org.pentaho.di.trans.streaming.common.BaseStreamStepMeta) Collectors(java.util.stream.Collectors) ISubTransAwareMeta(org.pentaho.di.trans.ISubTransAwareMeta) IClonableStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IClonableStepAnalyzer) List(java.util.List) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) Optional(java.util.Optional) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Direction(com.tinkerpop.blueprints.Direction) Collections(java.util.Collections) Arrays.stream(java.util.Arrays.stream) RESOURCE(org.pentaho.metaverse.api.analyzer.kettle.step.ExternalResourceStepAnalyzer.RESOURCE) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes)

Example 2 with RESOURCE

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;
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) KettleAnalyzerUtil(org.pentaho.metaverse.api.analyzer.kettle.KettleAnalyzerUtil) KettleException(org.pentaho.di.core.exception.KettleException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Messages(org.pentaho.metaverse.api.messages.Messages) SubtransAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.SubtransAnalyzer) LoggerFactory(org.slf4j.LoggerFactory) StepField(org.pentaho.metaverse.api.StepField) LINK_OUTPUTS(org.pentaho.dictionary.DictionaryConst.LINK_OUTPUTS) TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PROPERTY_TYPE(org.pentaho.dictionary.DictionaryConst.PROPERTY_TYPE) StepWithMappingMeta(org.pentaho.di.trans.StepWithMappingMeta) TransMeta(org.pentaho.di.trans.TransMeta) Collectors.toMap(java.util.stream.Collectors.toMap) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) VariableSpace(org.pentaho.di.core.variables.VariableSpace) StepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.StepAnalyzer) Collectors.toSet(java.util.stream.Collectors.toSet) Logger(org.slf4j.Logger) DictionaryHelper(org.pentaho.dictionary.DictionaryHelper) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) Set(java.util.Set) BaseStreamStepMeta(org.pentaho.di.trans.streaming.common.BaseStreamStepMeta) Collectors(java.util.stream.Collectors) ISubTransAwareMeta(org.pentaho.di.trans.ISubTransAwareMeta) IClonableStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IClonableStepAnalyzer) List(java.util.List) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) Optional(java.util.Optional) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Direction(com.tinkerpop.blueprints.Direction) Collections(java.util.Collections) Arrays.stream(java.util.Arrays.stream) RESOURCE(org.pentaho.metaverse.api.analyzer.kettle.step.ExternalResourceStepAnalyzer.RESOURCE) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Direction (com.tinkerpop.blueprints.Direction)2 Arrays.asList (java.util.Arrays.asList)2 Arrays.stream (java.util.Arrays.stream)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Collectors.toMap (java.util.stream.Collectors.toMap)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 KettleException (org.pentaho.di.core.exception.KettleException)2 RowMeta (org.pentaho.di.core.row.RowMeta)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 ValueMetaNone (org.pentaho.di.core.row.value.ValueMetaNone)2 VariableSpace (org.pentaho.di.core.variables.VariableSpace)2 ISubTransAwareMeta (org.pentaho.di.trans.ISubTransAwareMeta)2 StepWithMappingMeta (org.pentaho.di.trans.StepWithMappingMeta)2 TransMeta (org.pentaho.di.trans.TransMeta)2