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

    https://github.com/apache/nifi/pull/319#discussion_r59995999
  
    --- 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();
    +        }
    --- End diff --
    
    Joe, instead of repeating the entire definition of the descriptor, have you 
considered a base builder and then finish descriptor based on condition. For 
example
    ```
    Builder somePropBuilder = new PropertyDescriptor.Builder()
                .name(propertyDescriptorName)
                .required(false)
                
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
                .expressionLanguageSupported(true)
                .dynamic(true);
    
    if(!stateful){
            return somePropBuilder
                   .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
                   .build();
    } else {
           return somePropBuilder
                   
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING,
 true))
                   .build();
    }
    ```



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