[
https://issues.apache.org/jira/browse/NIFI-3404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16023299#comment-16023299
]
ASF GitHub Bot commented on NIFI-3404:
--------------------------------------
Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1830#discussion_r118317913
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/LookupAttribute.java
---
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.processors.standard;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.apache.nifi.annotation.behavior.DynamicProperty;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
+import org.apache.nifi.annotation.behavior.SideEffectFree;
+import org.apache.nifi.annotation.behavior.SupportsBatching;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.expression.AttributeExpression;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.lookup.LookupFailureException;
+import org.apache.nifi.lookup.LookupService;
+import org.apache.nifi.lookup.StringLookupService;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.ProcessorInitializationContext;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@EventDriven
+@SideEffectFree
+@SupportsBatching
+@InputRequirement(Requirement.INPUT_REQUIRED)
+@Tags({"lookup", "cache", "enrich", "join", "mutable", "attributes",
"Attribute Expression Language"})
+@CapabilityDescription("Lookup attributes from a lookup service")
+@DynamicProperty(name = "The name of the attribute to add to the FlowFile",
+ value = "The name of the key or property to retrieve from the lookup
service",
+ supportsExpressionLanguage = true,
+ description = "Adds a FlowFile attribute specified by the dynamic
property's key with the value found in the lookup service using the the dynamic
property's value")
+@WritesAttribute(attribute = "See additional details", description = "This
processor may write zero or more attributes as described in additional details")
+public class LookupAttribute extends AbstractProcessor {
+
+ public static final String MULTI_STRATEGY = "multi-criteria";
+
+ public static final String KEY_VALUE_STRATEGY = "key-value";
+
+ public static final PropertyDescriptor LOOKUP_SERVICE =
+ new PropertyDescriptor.Builder()
+ .name("lookup-service")
+ .displayName("Lookup Service")
+ .description("The lookup service to use for attribute lookups")
+ .identifiesControllerService(StringLookupService.class)
+ .required(true)
+ .build();
+
+ static final PropertyDescriptor LOOKUP_STRATEGY = new
PropertyDescriptor.Builder()
+ .name("lookup-strategy")
+ .displayName("Lookup Strategy")
+ .description("The strategy to use to retrieve results from the " +
+ "lookup service. If " + MULTI_STRATEGY + " then the
conjunction " +
+ "of all the dynamic properties will be used for coordinate " +
+ "lookups and a destination attribute must be provided. " +
+ "Otherwise, for " + KEY_VALUE_STRATEGY + " each dynamic
property " +
+ "specifies a destination attribute name and a target key for "
+
+ "lookup.")
+ .allowableValues(MULTI_STRATEGY, KEY_VALUE_STRATEGY)
+ .defaultValue(KEY_VALUE_STRATEGY)
+ .required(true)
+ .build();
+
+ static final PropertyDescriptor DESTINATION_ATTRIBUTE = new
PropertyDescriptor.Builder()
+ .name("destination-attribute")
+ .displayName("Destination Attribute")
+ .description("The attribute to store the lookup result in if using
" +
+ "the " + MULTI_STRATEGY + " lookup strategy.")
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .expressionLanguageSupported(true)
+ .required(false)
+ .build();
+
+ public static final PropertyDescriptor INCLUDE_EMPTY_VALUES =
+ new PropertyDescriptor.Builder()
+ .name("include-empty-values")
+ .displayName("Include Empty Values")
+ .description("Include null or blank values for keys that are
null or blank")
+ .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
+ .allowableValues("true", "false")
+ .defaultValue("true")
+ .required(true)
+ .build();
+
+ public static final Relationship REL_SUCCESS = new
Relationship.Builder()
--- End diff --
Should this be "matched" instead of "success"? Seems like it better goes
with the "unmatched" relationship in terms of behavior.
> Add lookup processor for enrichments/joins to reference data
> ------------------------------------------------------------
>
> Key: NIFI-3404
> URL: https://issues.apache.org/jira/browse/NIFI-3404
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Joey Frazee
> Assignee: Joey Frazee
>
> NiFi doesn't currently have an easy, concise way of doing enrichment, joining
> against reference data sets or performing attribute lookups against external
> data sources.
> Since enrichments and joins are basic streaming use cases, and since
> attributes and EL are often used to parameterize processor properties, there
> is a need for an easy way to do enrichments, joins and lookups without having
> to write code or create a lengthy data flow.
> There's been some discussion of this on the mailing list [1] and I've started
> work on a LookupAttribute [2] processor that delegates the work to controller
> services.
> 1.
> https://lists.apache.org/thread.html/74321ff0e9e0b7339e43ad53b36119315dc5094991605edfb12b34d0@%3Cdev.nifi.apache.org%3E
> 2. https://github.com/jfrazee/nifi-lookup-service
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)