andrewmlim commented on code in PR #6044:
URL: https://github.com/apache/nifi/pull/6044#discussion_r878443489


##########
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/docs/org.apache.nifi.processors.script.ExecuteScript/additionalDetails.html:
##########
@@ -0,0 +1,698 @@
+<!DOCTYPE html>
+<html lang="en" xmlns="http://www.w3.org/1999/html";>
+<!--
+      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.
+    -->
+
+<head>
+    <meta charset="utf-8"/>
+    <title>ExecuteScript</title>
+    <link rel="stylesheet" href="../../../../../css/component-usage.css" 
type="text/css"/>
+    <style>
+h2 {margin-top: 4em}
+h3 {margin-top: 3em}
+td {text-align: left}
+    </style>
+</head>
+
+<body>
+
+<h1>ExecuteScript</h1>
+
+<h3>Description</h3>
+<p>
+    The ExecuteScript Processor provides the ability to use a scripting 
language in order to leverage the NiFi API to perform tasks such as the 
following:
+</p>
+<ul>
+    <li>Read content and/or attributes from an incoming Flowfile</li>
+    <li>Create a new FlowFile (with or without a parent)</li>
+    <li>Write content and/or attributes to an outgoing FlowFile</li>
+    <li>Interact with the ProcessSession to transfer FlowFiles to 
relationships</li>
+    <li>Read/write to the State Manager to keep track of variables across 
executions of the processor</li>
+</ul>
+
+<p>
+    <b>Notes:</b>
+<ul>
+    <li>The engine listed as "python" in the list of available script engines 
is actually Jython, not Python. When using Jython, you cannot import pure 
(CPython) modules such as pandas</li>
+    <li>Lua does not allow for referencing static members of a class, so the 
REL_SUCCESS and REL_FAILURE relationships are made available via script 
bindings (aka variables), see the Variable Bindings section for more 
details</li>
+    <li>ExecuteScript uses the JSR-223 Script Engine API to evaluate scripts, 
so the use of idiomatic language structure is sometimes limited. For example, 
in the case of Groovy, there is a separate ExecuteGroovyScript processor that 
allows you to do many more idiomatic Groovy tasks. For example it's easier to 
interact with Controller Services via ExecuteGroovyScript vs. ExecuteScript 
(see the ExecuteGroovyScript documentation for more details)</li>
+    <li>JavaScript is provided by the Nashorn engine, which is not available 
in later Java versions, so it may not show up in the Script Engines list 
depending on the JRE used</li>
+</ul>
+</p>
+<h3>Variable Bindings</h3>
+<p>
+    The Processor expects a user defined script that is evaluated when the 
processor is triggered. The following variables are available to the scripts:
+</p>
+<table>
+    <tr>
+        <th>Variable Name</th>
+        <th>Description</th>
+        <th>Variable Class</th>
+    </tr>
+    <tr>
+        <td><b>session</b></td>
+        <td>This is a reference to the ProcessSession assigned to the 
processor. The session allows you to perform operations on FlowFiles such as 
create(), putAttribute(), and transfer(), as well as read() and write()</td>
+        <td><a 
href="https://www.javadoc.io/doc/org.apache.nifi/nifi-api/latest/org/apache/nifi/processor/ProcessSession.html";>ProcessSession</a></td>
+    </tr>
+    <tr>
+        <td><b>context</b></td>
+        <td>This is a reference to the ProcessContext for the processor. It 
can be used to retrieve processor properties, relationships, Controller 
Services, and the StateManager.</td>
+        <td><a 
href="https://www.javadoc.io/doc/org.apache.nifi/nifi-api/latest/org/apache/nifi/processor/ProcessContext.html";>ProcessContext</a></td>
+    </tr>
+    <tr>
+        <td><b>log</b></td>
+        <td>This is a reference to the ComponentLog for the processor. Use it 
to log messages to NiFi, such as log.info('Hello world!')</td>
+        <td><a 
href="https://www.javadoc.io/doc/org.apache.nifi/nifi-api/latest/org/apache/nifi/logging/ComponentLog.html";>ComponentLog</a></td>
+    </tr>
+    <tr>
+        <td><b>REL_SUCCESS</b></td>
+        <td>This is a reference to the "success" relationship defined for the 
processor. It could also be inherited by referencing the static member of the 
parent class (ExecuteScript), but some engines such as Lua do not allow for 
referencing static members, so this is a convenience variable. It also saves 
having to use the fully-qualified name for the relationship.</td>
+        <td><a 
href="https://www.javadoc.io/doc/org.apache.nifi/nifi-api/latest/org/apache/nifi/processor/Relationship.html";>Relationship</a></td>
+    </tr>
+    <tr>
+        <td><b>REL_FAILURE</b></td>
+        <td>This is a reference to the "failure" relationship defined for the 
processor. As with REL_SUCCESS, it could also be inherited by referencing the 
static member of the parent class (ExecuteScript), but some engines such as Lua 
do not allow for referencing static members, so this is a convenience variable. 
It also saves having to use the fully-qualified name for the relationship.</td>
+        <td><a 
href="https://www.javadoc.io/doc/org.apache.nifi/nifi-api/latest/org/apache/nifi/processor/Relationship.html";>Relationship</a></td>
+    </tr>
+    <tr>
+        <td><i>Dynamic Properties</i></td>
+        <td>Any dynamic (user-defined) properties defined in ExecuteScript are 
passed to the script engine as variables set to the PropertyValue object 
corresponding to the dynamic property. This allows you to get the String value 
of the property, but also to evaluate the property with respect to NiFi 
Expression Language, cast the value as an appropriate data type (such as 
Boolean, e.g.), etc. Because the dynamic property name becomes the variable 
name for the script, you must be aware of the variable naming properties for 
the chosen script engine. For example, Groovy does not allow periods (.) in 
variable names, so an error will occur if "my.property" was a dynamic property 
name.

Review Comment:
   Change "(such as Boolean, e.g.)" to "(e.g., Boolean)"



-- 
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]

Reply via email to