Search in sources :

Example 1 with PROPERTY_TYPE

use of org.pentaho.dictionary.DictionaryConst.PROPERTY_TYPE 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)

Aggregations

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