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

    https://github.com/apache/nifi/pull/1877#discussion_r124033334
  
    --- Diff: 
nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/schema/access/SchemaAccessUtils.java
 ---
    @@ -114,46 +116,35 @@ private static boolean isSchemaRegistryRequired(final 
String schemaAccessValue)
                     || 
HWX_SCHEMA_REF_ATTRIBUTES.getValue().equalsIgnoreCase(schemaAccessValue);
         }
     
    -    public static SchemaAccessStrategy getSchemaAccessStrategy(final 
String allowableValue, final SchemaRegistry schemaRegistry, final 
ProcessContext context) {
    -        if 
(allowableValue.equalsIgnoreCase(SCHEMA_NAME_PROPERTY.getValue())) {
    -            return new SchemaNamePropertyStrategy(schemaRegistry, 
context.getProperty(SCHEMA_NAME));
    -        } else if 
(allowableValue.equalsIgnoreCase(SCHEMA_TEXT_PROPERTY.getValue())) {
    -            return new 
AvroSchemaTextStrategy(context.getProperty(SCHEMA_TEXT));
    -        } else if 
(allowableValue.equalsIgnoreCase(HWX_CONTENT_ENCODED_SCHEMA.getValue())) {
    -            return new 
HortonworksEncodedSchemaReferenceStrategy(schemaRegistry);
    -        } else if 
(allowableValue.equalsIgnoreCase(HWX_SCHEMA_REF_ATTRIBUTES.getValue())) {
    -            return new 
HortonworksAttributeSchemaReferenceStrategy(schemaRegistry);
    -        }
    -
    -        return null;
    +    public static boolean isFlowFileRequired(final String 
schemaAccessValue) {
    +        return 
HWX_SCHEMA_REF_ATTRIBUTES.getValue().equalsIgnoreCase(schemaAccessValue);
         }
     
    -    public static SchemaAccessStrategy getSchemaAccessStrategy(final 
String allowableValue, final SchemaRegistry schemaRegistry, final 
ConfigurationContext context) {
    -        if 
(allowableValue.equalsIgnoreCase(SCHEMA_NAME_PROPERTY.getValue())) {
    -            return new SchemaNamePropertyStrategy(schemaRegistry, 
context.getProperty(SCHEMA_NAME));
    -        } else if 
(allowableValue.equalsIgnoreCase(SCHEMA_TEXT_PROPERTY.getValue())) {
    -            return new 
AvroSchemaTextStrategy(context.getProperty(SCHEMA_TEXT));
    -        } else if 
(allowableValue.equalsIgnoreCase(HWX_CONTENT_ENCODED_SCHEMA.getValue())) {
    +    private static SchemaAccessStrategy getSchemaAccessStrategy(
    +            final String strategy, final SchemaRegistry schemaRegistry, 
final Function<PropertyDescriptor, PropertyValue> getProperty) {
    +        if (strategy.equalsIgnoreCase(SCHEMA_NAME_PROPERTY.getValue())) {
    +            return new SchemaNamePropertyStrategy(schemaRegistry, 
getProperty.apply(SCHEMA_NAME));
    +        } else if 
(strategy.equalsIgnoreCase(SCHEMA_TEXT_PROPERTY.getValue())) {
    +            return new 
AvroSchemaTextStrategy(getProperty.apply(SCHEMA_TEXT));
    +        } else if 
(strategy.equalsIgnoreCase(HWX_CONTENT_ENCODED_SCHEMA.getValue())) {
                 return new 
HortonworksEncodedSchemaReferenceStrategy(schemaRegistry);
    -        } else if 
(allowableValue.equalsIgnoreCase(HWX_SCHEMA_REF_ATTRIBUTES.getValue())) {
    +        } else if 
(strategy.equalsIgnoreCase(HWX_SCHEMA_REF_ATTRIBUTES.getValue())) {
                 return new 
HortonworksAttributeSchemaReferenceStrategy(schemaRegistry);
             }
     
             return null;
         }
     
    -    public static SchemaAccessStrategy getSchemaAccessStrategy(final 
String allowableValue, final SchemaRegistry schemaRegistry, final 
ValidationContext context) {
    -        if 
(allowableValue.equalsIgnoreCase(SCHEMA_NAME_PROPERTY.getValue())) {
    -            return new SchemaNamePropertyStrategy(schemaRegistry, 
context.getProperty(SCHEMA_NAME));
    -        } else if 
(allowableValue.equalsIgnoreCase(SCHEMA_TEXT_PROPERTY.getValue())) {
    -            return new 
AvroSchemaTextStrategy(context.getProperty(SCHEMA_TEXT));
    -        } else if 
(allowableValue.equalsIgnoreCase(HWX_CONTENT_ENCODED_SCHEMA.getValue())) {
    -            return new 
HortonworksEncodedSchemaReferenceStrategy(schemaRegistry);
    -        } else if 
(allowableValue.equalsIgnoreCase(HWX_SCHEMA_REF_ATTRIBUTES.getValue())) {
    -            return new 
HortonworksAttributeSchemaReferenceStrategy(schemaRegistry);
    -        }
    +    public static SchemaAccessStrategy getSchemaAccessStrategy(final 
String strategy, final SchemaRegistry schemaRegistry, final ProcessContext 
context) {
    +        return getSchemaAccessStrategy(strategy, schemaRegistry, 
context::getProperty);
    --- End diff --
    
    This is a good approach. However, on master, there is already a change that 
updates this to take just a PropertyContext, so I think this needs to just be 
rebased.


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