[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527230592 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527230291 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527230022 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527229886 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527228060 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527227687 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/pom.xml ## @@ -78,5 +78,59 @@ 1.13.0-SNAPSHOT test + +org.apache.nifi +nifi-record-path +1.13.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-record-serialization-service-api +provided + + +org.apache.nifi +nifi-json-utils +1.13.0-SNAPSHOT +test + + +org.apache.nifi +nifi-record-serialization-service-api +1.13.0-SNAPSHOT + + +org.apache.nifi +nifi-record-serialization-services +1.13.0-SNAPSHOT Review comment: Changed the scope to test This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527227527 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527227213 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r527226152 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.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.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", +value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.description("The graph client service for connecting to a graph database.") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519516186 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/util/SimpleEntry.java ## @@ -0,0 +1,36 @@ +package org.apache.nifi.processors.graph.util; + +import java.util.Map; + +final class SimpleEntry implements Map.Entry { Review comment: Yup, was able to use that! Thanks for that suggestion. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519515396 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/util/InMemoryGraphClient.java ## @@ -0,0 +1,96 @@ +package org.apache.nifi.processors.graph.util; + +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.graph.GraphQueryResultCallback; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphFactory; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class InMemoryGraphClient extends AbstractControllerService implements GraphClientService { Review comment: At this time, I cannot use that code because this will eventually need to be compliant with https://github.com/apache/nifi/pull/4204 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519515134 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519515196 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519515107 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519514393 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519514393 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519514204 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513933 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513836 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513799 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513593 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { Review comment: Removed This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513619 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") +.identifiesControllerService(GraphClientService.class) +.addValidator(Validator.VALID) +.required(true) +.build(); + +public static final PropertyDescriptor READER_SERVICE = new PropertyDescriptor.Builder() +.name("reader-service") +.displayName("Record Reader") +.description("The record reader to use with this processor.") +.identifiesControllerService(RecordReaderFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +public static final PropertyDescriptor WRITER_SERVICE = new PropertyDescriptor.Builder() +.name("writer-service") +.displayName("Failed Record Writer") +.description("The record writer to use for writing failed records.") +.identifiesControllerService(RecordSetWriterFactory.class) +.required(true) +.addValidator(Validator.VALID) +.build(); + +private static String loadScript(String path) { +try { +return IOUtils.toString(ExecuteGraphQueryRecord.class.getResourceAsStream(path), StandardCharsets.UTF_8); +} catch (Exception ex) { +throw new ProcessException(ex); +} +} + +public static final PropertyDescriptor SUBMISSION_SCRIPT = new PropertyDescriptor.Builder() +.name("record-script") +.displayName("Graph Record Script") +.description("Script to perform the business logic on graph, using flow file attributes and custom properties " + +"as variable-value pairs in its logic.") +
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513501 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/main/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecord.java ## @@ -0,0 +1,265 @@ +package org.apache.nifi.processors.graph; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.graph.GraphClientService; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.record.path.FieldValue; +import org.apache.nifi.record.path.RecordPath; +import org.apache.nifi.record.path.RecordPathResult; +import org.apache.nifi.record.path.util.RecordPathCache; +import org.apache.nifi.serialization.RecordReader; +import org.apache.nifi.serialization.RecordReaderFactory; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.serialization.record.Record; + +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +@Tags({"graph, gremlin"}) +@CapabilityDescription("This uses a flowfile as input to perform graph mutations.") +@WritesAttributes({ +@WritesAttribute(attribute = ExecuteGraphQueryRecord.GRAPH_OPERATION_TIME, description = "The amount of time it took to execute all of the graph operations."), +@WritesAttribute(attribute = ExecuteGraphQueryRecord.RECORD_COUNT, description = "The amount of record processed") +}) +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "A FlowFile property to be used as a parameter in the graph script", value = "The variable name to be set", expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, +description = "Uses a record path to set a variable as a parameter in the graph script") +public class ExecuteGraphQueryRecord extends AbstractGraphExecutor { + +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("client-service") +.displayName("Client Service") Review comment: Description added This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi] levilentz commented on a change in pull request #4638: NIFI-7906: parameterized graph query
levilentz commented on a change in pull request #4638: URL: https://github.com/apache/nifi/pull/4638#discussion_r519513474 ## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/pom.xml ## @@ -78,5 +78,43 @@ 1.13.0-SNAPSHOT test + +org.apache.nifi +nifi-record-path +1.13.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-record-serialization-service-api +compile Review comment: Changed This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org