pgyori commented on code in PR #9000:
URL: https://github.com/apache/nifi/pull/9000#discussion_r1657162185
##########
nifi-extension-bundles/nifi-py4j-bundle/nifi-py4j-integration-tests/src/test/java/org.apache.nifi.py4j/PythonControllerInteractionIT.java:
##########
@@ -567,6 +567,28 @@ public void testRouteToFailureWithAttributes() {
out.assertAttributeEquals("failureReason", "Intentional failure of
unit test");
}
+ @Test
+ public void testCreateFlowFile() throws IOException {
+ final String processorName = "CreateFlowFile";
+ final String propertyName = "FlowFile Contents";
+ final String relationship1 = "success";
+ final String relationship2 = "multiline";
Review Comment:
You are right, thanks! Renaming.
##########
nifi-extension-bundles/nifi-py4j-bundle/nifi-python-extension-api/src/main/python/src/nifiapi/flowfilesource.py:
##########
@@ -0,0 +1,65 @@
+# 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.
+
+from abc import ABC, abstractmethod
+from nifiapi.__jvm__ import JvmHolder
+from nifiapi.properties import ProcessContext
+
+
+class FlowFileSource(ABC):
+ # These will be set by the PythonProcessorAdapter when the component is
created
+ identifier = None
+ logger = None
+
+ def __init__(self):
+ self.arrayList = JvmHolder.jvm.java.util.ArrayList
+
+ def setContext(self, context):
+ self.process_context = ProcessContext(context)
+
+ def createFlowFile(self):
+ return self.create(self.process_context)
+
+ @abstractmethod
+ def create(self, context):
+ pass
+
+class FlowFileSourceResult:
+ class Java:
+ implements = ['org.apache.nifi.python.processor.FlowFileSourceResult']
+
+ def __init__(self, relationship, attributes = None, contents = None):
+ self.relationship = relationship
+ self.attributes = attributes
+ if contents is not None and isinstance(contents, str):
+ self.contents = str.encode(contents)
+ else:
+ self.contents = contents
+
+ def getRelationship(self):
+ return self.relationship
+
+ def getContents(self):
+ return self.contents
+
+ def getAttributes(self):
+ if self.attributes is None:
+ return None
+
+ map = JvmHolder.jvm.java.util.HashMap()
+ for key, value in self.attributes.items():
+ map.put(key, value)
+
+ return map
Review Comment:
Fair point, I did not realize that. Thank you!
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]