Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/319#discussion_r59996046
  
    --- Diff: 
nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java
 ---
    @@ -187,24 +167,83 @@ public UpdateAttribute() {
         protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
             List<PropertyDescriptor> descriptors = new ArrayList<>();
             descriptors.add(DELETE_ATTRIBUTES);
    +        descriptors.add(STORE_STATE);
    +        descriptors.add(STATEFUL_VARIABLES_INIT_VALUE);
             return Collections.unmodifiableList(descriptors);
         }
     
         @Override
         protected PropertyDescriptor 
getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    -        return new PropertyDescriptor.Builder()
    -                .name(propertyDescriptorName)
    -                .required(false)
    -                
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING,
 true))
    -                
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
    -                .expressionLanguageSupported(true)
    -                .dynamic(true)
    -                .build();
    +        if(!stateful){
    +            return new PropertyDescriptor.Builder()
    +                    .name(propertyDescriptorName)
    +                    .required(false)
    +                    
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
    +                    .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +                    .expressionLanguageSupported(true)
    +                    .dynamic(true)
    +                    .build();
    +        } else {
    +            return new PropertyDescriptor.Builder()
    +                    .name(propertyDescriptorName)
    +                    .required(false)
    +                    
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING,
 true))
    +                    
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
    +                    .expressionLanguageSupported(true)
    +                    .dynamic(true)
    +                    .build();
    +        }
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, 
final String oldValue, final String newValue) {
    +        super.onPropertyModified(descriptor, oldValue, newValue);
    +
    +        if (descriptor.equals(STORE_STATE)) {
    +            if ("true".equalsIgnoreCase(newValue)) {
    +                stateful = true;
    +            } else {
    +                stateful = false;
    +            }
    +        }
    --- End diff --
    
    Isn't it the same as saying 
    ```
    stateful = "true".equalsIgnoreCase(newValue);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to