<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Apache NiFi custom processor expression language in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122707#M22530</link>
    <description>&lt;P&gt;Thank you very much for this answer!&lt;/P&gt;</description>
    <pubDate>Sat, 12 Mar 2016 03:41:41 GMT</pubDate>
    <dc:creator>matthias_stala</dc:creator>
    <dc:date>2016-03-12T03:41:41Z</dc:date>
    <item>
      <title>Apache NiFi custom processor expression language</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122705#M22528</link>
      <description>&lt;P&gt;I'm trying to make a custom processor in Apache NiFi that can add an attribute/string to the JSON object in the flowfile content. At the moment it works when I just use a string but it's not working when I use NiFi's expression language although I have it supported in my code. &lt;/P&gt;&lt;P&gt;The expression language is 100% correct as it works in another processor and I've also tried different attributes to make sure it's not the attribute.
The property: &lt;/P&gt;&lt;PRE&gt;public static final PropertyDescriptor ADD_ATTRIBUTE = new PropertyDescriptor
        .Builder().name("Add Attribute")
        .description("Example Property")
        .required(true)
        .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
        .expressionLanguageSupported(true)
        .build();&lt;/PRE&gt;&lt;P&gt;Later in my code when I want to get the value and put in the JSON object I use: &lt;/P&gt;&lt;PRE&gt;jsonObject.put("hostname", context.getProperty(ADD_ATTRIBUTE).evaluateAttributeExpressions().getValue());&lt;/PRE&gt;&lt;P&gt; I also made a Unit Test and it works when I assign a text value to the testrunner.setProperty. However I don't know how I can assign an attribute to the testrunner or how I can use expression language in my test.
Thanks in advance for any suggestions or a solution!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 16:08:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122705#M22528</guid>
      <dc:creator>matthias_stala</dc:creator>
      <dc:date>2016-03-11T16:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Apache NiFi custom processor expression language</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122706#M22529</link>
      <description>&lt;P&gt;If the expression refers to attributes on a flow file, you will need to pass a reference to the flow file into evaluateAttributeExpressions: &lt;/P&gt;&lt;PRE&gt;FlowFile flowFile = session.get();
jsonObject.put("hostname", context.getProperty(ADD_ATTRIBUTE).evaluateAttributeExpressions(flowFile).getValue());&lt;/PRE&gt;&lt;P&gt;If the property contains an attribute name (rather than an Expression containing an attribute name) and you want the value from the flow file:&lt;/P&gt;&lt;PRE&gt;jsonObject.put("hostname", flowFile.getAttribute(context.getProperty(ADD_ATTRIBUTE).getValue()));&lt;/PRE&gt;&lt;P&gt;If the attribute value itself contains Expression Language and you want to evaluate it, take a look at the following class:&lt;/P&gt;&lt;PRE&gt;org.apache.nifi.attribute.expression.language.Query&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Mar 2016 21:51:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122706#M22529</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2016-03-11T21:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Apache NiFi custom processor expression language</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122707#M22530</link>
      <description>&lt;P&gt;Thank you very much for this answer!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2016 03:41:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122707#M22530</guid>
      <dc:creator>matthias_stala</dc:creator>
      <dc:date>2016-03-12T03:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Apache NiFi custom processor expression language</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122708#M22531</link>
      <description>&lt;P&gt;Matt, how would the properties set in custom properties file be accessed within the custom controller service's onConfigured method? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 07:13:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122708#M22531</guid>
      <dc:creator>ajviradia</dc:creator>
      <dc:date>2017-06-20T07:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Apache NiFi custom processor expression language</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122709#M22532</link>
      <description>&lt;P&gt;That sounds like a different issue altogether, perhaps you'd get more/better responses if you create a new question in HCC to deal with it.  The short answer is: your ControllerService implementation can have a method annotated with @OnEnabled, looks like you're calling yours onConfigured(). That method can take a &lt;A target="_blank" href="https://github.com/apache/nifi/blob/rel/nifi-1.3.0/nifi-api/src/main/java/org/apache/nifi/controller/ConfigurationContext.java"&gt;ConfigurationContext&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;@OnEnabled
public void onConfigured(final ConfigurationContext context) throws InitializationException {
// Do stuff here 
}&lt;/PRE&gt;&lt;P&gt;And you can call getProperty(), getProperties(), etc. on it&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 02:34:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122709#M22532</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-06-21T02:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Apache NiFi custom processor expression language</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122710#M22533</link>
      <description>&lt;P&gt;Matt, &lt;/P&gt;&lt;P&gt;Appreciate if you provide an example on how to use the org.apache.nifi.attribute.expression.language.Query using Groovy.  Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 11:21:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Apache-NiFi-custom-processor-expression-language/m-p/122710#M22533</guid>
      <dc:creator>erwynsanchez</dc:creator>
      <dc:date>2017-10-23T11:21:09Z</dc:date>
    </item>
  </channel>
</rss>

