(nifi) branch support/nifi-1.x updated: NIFI-12408 Added Pretty Print Property to AttributesToJSON
This is an automated email from the ASF dual-hosted git repository. exceptionfactory pushed a commit to branch support/nifi-1.x in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/support/nifi-1.x by this push: new 96b0b122bb NIFI-12408 Added Pretty Print Property to AttributesToJSON 96b0b122bb is described below commit 96b0b122bbb79c8daa910ba611cfb99478e0460c Author: dan-s1 AuthorDate: Wed Dec 13 18:27:17 2023 + NIFI-12408 Added Pretty Print Property to AttributesToJSON This closes #8156 Signed-off-by: David Handermann (cherry picked from commit 1ddb5c185a35fe42370211f4cf1c9113f74e9f00) --- .../nifi/processors/standard/AttributesToJSON.java | 25 +- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java index 91a5448380..b35eab51b5 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java @@ -19,6 +19,7 @@ package org.apache.nifi.processors.standard; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.annotation.behavior.EventDriven; import org.apache.nifi.annotation.behavior.InputRequirement; @@ -161,18 +162,29 @@ public class AttributesToJSON extends AbstractProcessor { .defaultValue(AttributesToJSON.JsonHandlingStrategy.ESCAPED.getValue()) .build(); +public static final PropertyDescriptor PRETTY_PRINT = new PropertyDescriptor.Builder() +.name("Pretty Print") +.displayName("Pretty Print") +.description("Apply pretty print formatting to the output.") +.required(true) +.allowableValues("true", "false") +.defaultValue("false") +.dependsOn(DESTINATION, DESTINATION_CONTENT) +.build(); + public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success") .description("Successfully converted attributes to JSON").build(); public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure") .description("Failed to convert attributes to JSON").build(); +private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private List properties; private Set relationships; -private static final ObjectMapper objectMapper = new ObjectMapper(); private volatile Set attributesToRemove; private volatile Set attributes; private volatile Boolean nullValueForEmptyString; private volatile boolean destinationContent; +private volatile ObjectWriter objectWriter; private volatile Pattern pattern; private volatile JsonHandlingStrategy jsonHandlingStrategy; @@ -185,6 +197,7 @@ public class AttributesToJSON extends AbstractProcessor { properties.add(INCLUDE_CORE_ATTRIBUTES); properties.add(NULL_VALUE_FOR_EMPTY_STRING); properties.add(JSON_HANDLING_STRATEGY); +properties.add(PRETTY_PRINT); this.properties = Collections.unmodifiableList(properties); final Set relationships = new HashSet<>(); @@ -267,6 +280,8 @@ public class AttributesToJSON extends AbstractProcessor { attributes = buildAtrs(context.getProperty(ATTRIBUTES_LIST).getValue()); nullValueForEmptyString = context.getProperty(NULL_VALUE_FOR_EMPTY_STRING).asBoolean(); destinationContent = DESTINATION_CONTENT.equals(context.getProperty(DESTINATION).getValue()); +final boolean prettyPrint = context.getProperty(PRETTY_PRINT).asBoolean(); +objectWriter = destinationContent && prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter() : OBJECT_MAPPER.writer(); jsonHandlingStrategy = JsonHandlingStrategy.valueOf(context.getProperty(JSON_HANDLING_STRATEGY).getValue()); if(context.getProperty(ATTRIBUTES_REGEX).isSet()) { @@ -284,17 +299,17 @@ public class AttributesToJSON extends AbstractProcessor { final Map atrList = buildAttributesMapForFlowFile(original, attributes, attributesToRemove, nullValueForEmptyString, pattern); try { -Map formattedAttributes = getFormattedAttributes(atrList); +final Map formattedAttributes = getFormattedAttributes(atrList); if (destinationContent) { FlowFile conFlowfile =
(nifi) branch main updated: NIFI-12408 Added Pretty Print Property to AttributesToJSON
This is an automated email from the ASF dual-hosted git repository. exceptionfactory pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new 1ddb5c185a NIFI-12408 Added Pretty Print Property to AttributesToJSON 1ddb5c185a is described below commit 1ddb5c185a35fe42370211f4cf1c9113f74e9f00 Author: dan-s1 AuthorDate: Wed Dec 13 18:27:17 2023 + NIFI-12408 Added Pretty Print Property to AttributesToJSON This closes #8156 Signed-off-by: David Handermann --- .../nifi/processors/standard/AttributesToJSON.java | 25 +- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java index 72d71d1f5c..17adfeab33 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToJSON.java @@ -19,6 +19,7 @@ package org.apache.nifi.processors.standard; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.SideEffectFree; @@ -159,18 +160,29 @@ public class AttributesToJSON extends AbstractProcessor { .defaultValue(AttributesToJSON.JsonHandlingStrategy.ESCAPED.getValue()) .build(); +public static final PropertyDescriptor PRETTY_PRINT = new PropertyDescriptor.Builder() +.name("Pretty Print") +.displayName("Pretty Print") +.description("Apply pretty print formatting to the output.") +.required(true) +.allowableValues("true", "false") +.defaultValue("false") +.dependsOn(DESTINATION, DESTINATION_CONTENT) +.build(); + public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success") .description("Successfully converted attributes to JSON").build(); public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure") .description("Failed to convert attributes to JSON").build(); +private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private List properties; private Set relationships; -private static final ObjectMapper objectMapper = new ObjectMapper(); private volatile Set attributesToRemove; private volatile Set attributes; private volatile Boolean nullValueForEmptyString; private volatile boolean destinationContent; +private volatile ObjectWriter objectWriter; private volatile Pattern pattern; private volatile JsonHandlingStrategy jsonHandlingStrategy; @@ -183,6 +195,7 @@ public class AttributesToJSON extends AbstractProcessor { properties.add(INCLUDE_CORE_ATTRIBUTES); properties.add(NULL_VALUE_FOR_EMPTY_STRING); properties.add(JSON_HANDLING_STRATEGY); +properties.add(PRETTY_PRINT); this.properties = Collections.unmodifiableList(properties); final Set relationships = new HashSet<>(); @@ -265,6 +278,8 @@ public class AttributesToJSON extends AbstractProcessor { attributes = buildAtrs(context.getProperty(ATTRIBUTES_LIST).getValue()); nullValueForEmptyString = context.getProperty(NULL_VALUE_FOR_EMPTY_STRING).asBoolean(); destinationContent = DESTINATION_CONTENT.equals(context.getProperty(DESTINATION).getValue()); +final boolean prettyPrint = context.getProperty(PRETTY_PRINT).asBoolean(); +objectWriter = destinationContent && prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter() : OBJECT_MAPPER.writer(); jsonHandlingStrategy = JsonHandlingStrategy.valueOf(context.getProperty(JSON_HANDLING_STRATEGY).getValue()); if(context.getProperty(ATTRIBUTES_REGEX).isSet()) { @@ -282,17 +297,17 @@ public class AttributesToJSON extends AbstractProcessor { final Map atrList = buildAttributesMapForFlowFile(original, attributes, attributesToRemove, nullValueForEmptyString, pattern); try { -Map formattedAttributes = getFormattedAttributes(atrList); +final Map formattedAttributes = getFormattedAttributes(atrList); if (destinationContent) { FlowFile conFlowfile = session.write(original, (in, out) -> { try (OutputStream outputStream = new
(nifi) branch support/nifi-1.x updated: NIFI-12371 Support tombstone messages in non-record Kafka processors
This is an automated email from the ASF dual-hosted git repository. exceptionfactory pushed a commit to branch support/nifi-1.x in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/support/nifi-1.x by this push: new 82bac859ef NIFI-12371 Support tombstone messages in non-record Kafka processors 82bac859ef is described below commit 82bac859ef1a1989557737fe94bdc0ece4e1778c Author: Pierre Villard AuthorDate: Fri Nov 10 13:08:59 2023 -0600 NIFI-12371 Support tombstone messages in non-record Kafka processors This closes #8076 Signed-off-by: David Handermann (cherry picked from commit ee2368e0ae684d8a3ca2e62ce89422a2e260bdce) --- .../apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java | 3 ++- .../apache/nifi/processors/kafka/pubsub/ConsumerLease.java| 2 ++ .../apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java | 3 +++ .../apache/nifi/processors/kafka/pubsub/PublisherLease.java | 11 --- .../nifi/kafka/shared/attribute/KafkaFlowFileAttribute.java | 2 ++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java index 8bd3398747..019f7daa55 100644 --- a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java +++ b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java @@ -75,7 +75,8 @@ import java.util.regex.Pattern; @WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_OFFSET, description = "The offset of the message in the partition of the topic."), @WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TIMESTAMP, description = "The timestamp of the message in the partition of the topic."), @WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_PARTITION, description = "The partition of the topic the message or message bundle is from"), -@WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TOPIC, description = "The topic the message or message bundle is from") +@WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TOPIC, description = "The topic the message or message bundle is from"), +@WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TOMBSTONE, description = "Set to true if the consumed message is a tombstone message") }) @InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) @DynamicProperty(name = "The name of a Kafka configuration property.", value = "The value of a given Kafka configuration property.", diff --git a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java index 3883842694..863006b4db 100644 --- a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java +++ b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java @@ -474,6 +474,8 @@ public abstract class ConsumerLease implements Closeable, ConsumerRebalanceListe final byte[] value = record.value(); if (value != null) { flowFile = session.write(flowFile, out -> out.write(value)); +} else { +flowFile = session.putAttribute(flowFile, KafkaFlowFileAttribute.KAFKA_TOMBSTONE, Boolean.TRUE.toString()); } flowFile = session.putAllAttributes(flowFile, getAttributes(record)); tracker.updateFlowFile(flowFile); diff --git a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java index acab0fe1cd..cf047f3d23 100644 --- a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java +++ b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java @@ -25,6 +25,7 @@ import org.apache.kafka.common.errors.ProducerFencedException; import org.apache.kafka.common.serialization.ByteArraySerializer; import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.ReadsAttribute; import
(nifi) branch main updated: NIFI-12371 Support tombstone messages in non-record Kafka processors
This is an automated email from the ASF dual-hosted git repository. exceptionfactory pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new ee2368e0ae NIFI-12371 Support tombstone messages in non-record Kafka processors ee2368e0ae is described below commit ee2368e0ae684d8a3ca2e62ce89422a2e260bdce Author: Pierre Villard AuthorDate: Fri Nov 10 20:08:59 2023 +0100 NIFI-12371 Support tombstone messages in non-record Kafka processors This closes #8076 Signed-off-by: David Handermann --- .../apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java | 3 ++- .../apache/nifi/processors/kafka/pubsub/ConsumerLease.java| 2 ++ .../apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java | 3 +++ .../apache/nifi/processors/kafka/pubsub/PublisherLease.java | 11 --- .../nifi/kafka/shared/attribute/KafkaFlowFileAttribute.java | 2 ++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java index a5c6b15891..ff75453bc0 100644 --- a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java +++ b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumeKafka_2_6.java @@ -74,7 +74,8 @@ import java.util.regex.Pattern; @WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_OFFSET, description = "The offset of the message in the partition of the topic."), @WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TIMESTAMP, description = "The timestamp of the message in the partition of the topic."), @WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_PARTITION, description = "The partition of the topic the message or message bundle is from"), -@WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TOPIC, description = "The topic the message or message bundle is from") +@WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TOPIC, description = "The topic the message or message bundle is from"), +@WritesAttribute(attribute = KafkaFlowFileAttribute.KAFKA_TOMBSTONE, description = "Set to true if the consumed message is a tombstone message") }) @InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) @DynamicProperty(name = "The name of a Kafka configuration property.", value = "The value of a given Kafka configuration property.", diff --git a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java index 698ecc36a5..b197d97c41 100644 --- a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java +++ b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/ConsumerLease.java @@ -474,6 +474,8 @@ public abstract class ConsumerLease implements Closeable, ConsumerRebalanceListe final byte[] value = record.value(); if (value != null) { flowFile = session.write(flowFile, out -> out.write(value)); +} else { +flowFile = session.putAttribute(flowFile, KafkaFlowFileAttribute.KAFKA_TOMBSTONE, Boolean.TRUE.toString()); } flowFile = session.putAllAttributes(flowFile, getAttributes(record)); tracker.updateFlowFile(flowFile); diff --git a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java index b6b84ce1e0..9a8e5971ab 100644 --- a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java +++ b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-2-6-processors/src/main/java/org/apache/nifi/processors/kafka/pubsub/PublishKafka_2_6.java @@ -27,6 +27,7 @@ import org.apache.kafka.common.errors.ProducerFencedException; import org.apache.kafka.common.serialization.ByteArraySerializer; import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.ReadsAttribute; import org.apache.nifi.annotation.behavior.WritesAttribute; import
(nifi) branch support/nifi-1.x updated: NIFI-12518 Upgraded Calcite Avatica from 1.23.0 to 1.24.0
This is an automated email from the ASF dual-hosted git repository. exceptionfactory pushed a commit to branch support/nifi-1.x in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/support/nifi-1.x by this push: new 8770271dc8 NIFI-12518 Upgraded Calcite Avatica from 1.23.0 to 1.24.0 8770271dc8 is described below commit 8770271dc8cbd61a224b19bc537ef248468c051f Author: exceptionfactory AuthorDate: Fri Dec 15 13:37:21 2023 -0600 NIFI-12518 Upgraded Calcite Avatica from 1.23.0 to 1.24.0 This closes #8164 Signed-off-by: Mike Thomsen (cherry picked from commit 6f456ebbd4c72b3ebb6c18afbea43b5a18f7de88) --- nifi-nar-bundles/nifi-hive-bundle/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-hive-bundle/pom.xml b/nifi-nar-bundles/nifi-hive-bundle/pom.xml index f5dd60ef98..e72bc6c363 100644 --- a/nifi-nar-bundles/nifi-hive-bundle/pom.xml +++ b/nifi-nar-bundles/nifi-hive-bundle/pom.xml @@ -136,7 +136,7 @@ 2.6.2 3.1.3 ${hive3.version} -1.23.0 +1.24.0 1.36.0 1.6.0
(nifi) branch main updated: NIFI-12446 Refactor FilterAttribute to align with code conventions
This is an automated email from the ASF dual-hosted git repository. exceptionfactory pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new 4f399c9bb9 NIFI-12446 Refactor FilterAttribute to align with code conventions 4f399c9bb9 is described below commit 4f399c9bb973c98b98f21d271cb64c5665ae6ce6 Author: EndzeitBegins <1115+endzeitbeg...@users.noreply.github.com> AuthorDate: Thu Dec 14 21:04:04 2023 +0100 NIFI-12446 Refactor FilterAttribute to align with code conventions This closes #8161 Signed-off-by: David Handermann --- .../nifi/processors/standard/FilterAttribute.java | 183 - .../processors/standard/TestFilterAttribute.java | 14 +- 2 files changed, 111 insertions(+), 86 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FilterAttribute.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FilterAttribute.java index de612196fd..d37e28742d 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FilterAttribute.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FilterAttribute.java @@ -24,7 +24,7 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.Tags; import org.apache.nifi.annotation.documentation.UseCase; import org.apache.nifi.annotation.lifecycle.OnScheduled; -import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.DescribedValue; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.flowfile.FlowFile; @@ -36,7 +36,6 @@ import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -52,87 +51,64 @@ import java.util.stream.Collectors; @UseCase( description = "Retain all FlowFile attributes matching a regular expression", configuration = """ -Set "Filter mode" to "Retain". -Set "Attribute matching strategy" to "Use regular expression". -Specify the "Regular expression to filter attributes", e.g. "my-property|a-prefix[.].*". +Set "Filter Mode" to "Retain". +Set "Attribute Matching Strategy" to "Use regular expression". +Specify the "Filtered Attributes Pattern", e.g. "my-property|a-prefix[.].*". """ ) @UseCase( description = "Remove only a specified set of FlowFile attributes", configuration = """ -Set "Filter mode" to "Remove". -Set "Attribute matching strategy" to "Enumerate attributes". -Specify the set of "Set of attributes to filter" using the delimiter comma ',', e.g. "my-property,other,filename". +Set "Filter Mode" to "Remove". +Set "Attribute Matching Strategy" to "Enumerate attributes". +Specify the set of "Filtered Attributes" using the delimiter comma ',', e.g. "my-property,other,filename". """ ) public class FilterAttribute extends AbstractProcessor { public static final Relationship REL_SUCCESS = new Relationship.Builder() -.description("All successful FlowFiles are routed to this relationship").name("success").build(); - -private final static Set relationships = Collections.singleton(REL_SUCCESS); - - -public static final AllowableValue FILTER_MODE_VALUE_RETAIN = new AllowableValue( -"RETAIN", -"Retain", -"Retains only the attributes matching the filter, all other attributes are removed." -); +.name("success") +.description("All successful FlowFiles are routed to this relationship") +.build(); -public static final AllowableValue FILTER_MODE_VALUE_REMOVE = new AllowableValue( -"REMOVE", -"Remove", -"Removes the attributes matching the filter, all other attributes are retained." -); +private final static Set relationships = Set.of(REL_SUCCESS); public static final PropertyDescriptor FILTER_MODE = new PropertyDescriptor.Builder() -.name("FILTER_MODE") -.displayName("Filter mode") +.name("Filter Mode") +.displayName("Filter Mode") .description("Specifies the strategy to apply on filtered attributes. Either 'Remove' or 'Retain' only the matching attributes.")
(nifi) branch support/nifi-1.x updated: NIFI-12520: ExtractHL7Attributes processor ignores repeatable field values
This is an automated email from the ASF dual-hosted git repository. turcsanyi pushed a commit to branch support/nifi-1.x in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/support/nifi-1.x by this push: new 6a3301dfbf NIFI-12520: ExtractHL7Attributes processor ignores repeatable field values 6a3301dfbf is described below commit 6a3301dfbf4456c3ab1c6bca4ab797f302c8621d Author: Mark Bathori AuthorDate: Fri Dec 15 22:41:17 2023 +0100 NIFI-12520: ExtractHL7Attributes processor ignores repeatable field values This closes #8167. Signed-off-by: Peter Turcsanyi (cherry picked from commit 16d170fdfdbc12723746ae1f7ae8568246227ab2) --- .../nifi/processors/hl7/ExtractHL7Attributes.java | 20 ++-- .../processors/hl7/TestExtractHL7Attributes.java | 129 ++--- 2 files changed, 101 insertions(+), 48 deletions(-) diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java index aa7a867d9c..063d8e9b3b 100644 --- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java +++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java @@ -281,8 +281,8 @@ public class ExtractHL7Attributes extends AbstractProcessor { final Map fields = new TreeMap<>(); final String[] segmentNames = segment.getNames(); for (int i = 1; i <= segment.numFields(); i++) { -final Type field = segment.getField(i, 0); -if (!isEmpty(field)) { +final Type[] fieldValues = segment.getField(i); +if (fieldValues != null && fieldValues.length != 0) { final String fieldName; //Some user defined segments (e.g. Z segments) will not have corresponding names returned //from segment.getNames() above. If we encounter one of these, do the next best thing @@ -294,13 +294,17 @@ public class ExtractHL7Attributes extends AbstractProcessor { fieldName = String.valueOf(i); } -final String fieldKey = new StringBuilder() -.append(segmentKey) -.append(".") -.append(fieldName) -.toString(); +final String fieldKey = String.format("%s.%s", segmentKey, fieldName); -fields.put(fieldKey, field); +//Checks if the field is repeatable, if the max cardinality value is 0 or more than 1 then the field is repeatable +if (segment.getMaxCardinality(i) == 1) { +fields.put(fieldKey, fieldValues[0]); +} else { +for (int j = 0; j < fieldValues.length; j++) { +final String repeatableFieldKey = String.format("%s_%s", fieldKey, j + 1); +fields.put(repeatableFieldKey, fieldValues[j]); +} +} } } return fields; diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java index e1b5fdc51d..8f02e3b05f 100644 --- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java +++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java @@ -22,7 +22,6 @@ import org.apache.nifi.util.TestRunners; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.SortedMap; @@ -105,17 +104,17 @@ public class TestExtractHL7Attributes { expectedAttributes.put("MSH.12", "2.3"); expectedAttributes.put("ORC_1.1", "NW"); -expectedAttributes.put("ORC_1.2", "987654321^EPC"); +expectedAttributes.put("ORC_1.2_1", "987654321^EPC"); expectedAttributes.put("ORC_1.3", "123456789^EPC"); expectedAttributes.put("ORC_1.9", "2016100300"); -expectedAttributes.put("ORC_1.12", "SMITH"); +expectedAttributes.put("ORC_1.12_1", "SMITH"); expectedAttributes.put("OBR_1.1", "1"); -expectedAttributes.put("OBR_1.2", "341856649^HNAM_ORDERID"); +expectedAttributes.put("OBR_1.2_1", "341856649^HNAM_ORDERID"); expectedAttributes.put("OBR_1.3", "00"); expectedAttributes.put("OBR_1.4",
(nifi) branch main updated: NIFI-12520: ExtractHL7Attributes processor ignores repeatable field values
This is an automated email from the ASF dual-hosted git repository. turcsanyi pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new 16d170fdfd NIFI-12520: ExtractHL7Attributes processor ignores repeatable field values 16d170fdfd is described below commit 16d170fdfdbc12723746ae1f7ae8568246227ab2 Author: Mark Bathori AuthorDate: Fri Dec 15 22:41:17 2023 +0100 NIFI-12520: ExtractHL7Attributes processor ignores repeatable field values This closes #8167. Signed-off-by: Peter Turcsanyi --- .../nifi/processors/hl7/ExtractHL7Attributes.java | 15 ++- .../processors/hl7/TestExtractHL7Attributes.java | 129 ++--- 2 files changed, 101 insertions(+), 43 deletions(-) diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java index 08cf0a2825..34288e6ce2 100644 --- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java +++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java @@ -278,8 +278,8 @@ public class ExtractHL7Attributes extends AbstractProcessor { final Map fields = new TreeMap<>(); final String[] segmentNames = segment.getNames(); for (int i = 1; i <= segment.numFields(); i++) { -final Type field = segment.getField(i, 0); -if (!isEmpty(field)) { +final Type[] fieldValues = segment.getField(i); +if (fieldValues != null && fieldValues.length != 0) { final String fieldName; //Some user defined segments (e.g. Z segments) will not have corresponding names returned //from segment.getNames() above. If we encounter one of these, do the next best thing @@ -292,7 +292,16 @@ public class ExtractHL7Attributes extends AbstractProcessor { } final String fieldKey = "%s.%s".formatted(segmentKey, fieldName); -fields.put(fieldKey, field); + +//Checks if the field is repeatable, if the max cardinality value is 0 or more than 1 then the field is repeatable +if (segment.getMaxCardinality(i) == 1) { +fields.put(fieldKey, fieldValues[0]); +} else { +for (int j = 0; j < fieldValues.length; j++) { +final String repeatableFieldKey = "%s_%s".formatted(fieldKey, j + 1); +fields.put(repeatableFieldKey, fieldValues[j]); +} +} } } return fields; diff --git a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java index e1b5fdc51d..8f02e3b05f 100644 --- a/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java +++ b/nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/test/java/org/apache/nifi/processors/hl7/TestExtractHL7Attributes.java @@ -22,7 +22,6 @@ import org.apache.nifi.util.TestRunners; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.SortedMap; @@ -105,17 +104,17 @@ public class TestExtractHL7Attributes { expectedAttributes.put("MSH.12", "2.3"); expectedAttributes.put("ORC_1.1", "NW"); -expectedAttributes.put("ORC_1.2", "987654321^EPC"); +expectedAttributes.put("ORC_1.2_1", "987654321^EPC"); expectedAttributes.put("ORC_1.3", "123456789^EPC"); expectedAttributes.put("ORC_1.9", "2016100300"); -expectedAttributes.put("ORC_1.12", "SMITH"); +expectedAttributes.put("ORC_1.12_1", "SMITH"); expectedAttributes.put("OBR_1.1", "1"); -expectedAttributes.put("OBR_1.2", "341856649^HNAM_ORDERID"); +expectedAttributes.put("OBR_1.2_1", "341856649^HNAM_ORDERID"); expectedAttributes.put("OBR_1.3", "00"); expectedAttributes.put("OBR_1.4", "648088^Basic Metabolic Panel"); expectedAttributes.put("OBR_1.7", "2015010100"); -expectedAttributes.put("OBR_1.16", "1620^Johnson^Corey^A"); +expectedAttributes.put("OBR_1.16_1", "1620^Johnson^Corey^A"); expectedAttributes.put("OBR_1.22", "2015010100"); expectedAttributes.put("OBR_1.25", "F");
(nifi) branch main updated: NIFI-12518 Upgraded Calcite Avatica from 1.23.0 to 1.24.0
This is an automated email from the ASF dual-hosted git repository. mthomsen pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new 6f456ebbd4 NIFI-12518 Upgraded Calcite Avatica from 1.23.0 to 1.24.0 6f456ebbd4 is described below commit 6f456ebbd4c72b3ebb6c18afbea43b5a18f7de88 Author: exceptionfactory AuthorDate: Fri Dec 15 13:37:21 2023 -0600 NIFI-12518 Upgraded Calcite Avatica from 1.23.0 to 1.24.0 This closes #8164 Signed-off-by: Mike Thomsen --- nifi-code-coverage/pom.xml| 2 +- nifi-nar-bundles/nifi-hive-bundle/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nifi-code-coverage/pom.xml b/nifi-code-coverage/pom.xml index 6f3d72d0ce..0c8b891d5d 100644 --- a/nifi-code-coverage/pom.xml +++ b/nifi-code-coverage/pom.xml @@ -29,7 +29,7 @@ 1.10.14 1.6.0 -1.23.0 +1.24.0 diff --git a/nifi-nar-bundles/nifi-hive-bundle/pom.xml b/nifi-nar-bundles/nifi-hive-bundle/pom.xml index c5c85d232a..24e6bad26a 100644 --- a/nifi-nar-bundles/nifi-hive-bundle/pom.xml +++ b/nifi-nar-bundles/nifi-hive-bundle/pom.xml @@ -116,7 +116,7 @@ 3.1.3 ${hive3.version} -1.23.0 +1.24.0 1.36.0 1.6.0