From 20a1fc24d712e1be2f26a203cbbf8c789bdf940f Mon Sep 17 00:00:00 2001 From: Tim Reardon Date: Fri, 12 May 2017 14:43:03 -0400 Subject: [PATCH] NIFI-3885 DynamoDB Processor EL Support Add EL support to remaining Dynamo processor properties Signed-off-by: James Wing This closes #1793. --- .../aws/dynamodb/AbstractDynamoDBProcessor.java | 8 ++++++-- .../nifi/processors/aws/dynamodb/DeleteDynamoDB.java | 8 ++++---- .../nifi/processors/aws/dynamodb/GetDynamoDB.java | 10 +++++----- .../nifi/processors/aws/dynamodb/PutDynamoDB.java | 12 ++++++------ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/AbstractDynamoDBProcessor.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/AbstractDynamoDBProcessor.java index e1a31a90e7..3a5adf7f15 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/AbstractDynamoDBProcessor.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/AbstractDynamoDBProcessor.java @@ -86,7 +86,7 @@ public abstract class AbstractDynamoDBProcessor extends AbstractAWSCredentialsPr public static final PropertyDescriptor TABLE = new PropertyDescriptor.Builder() .name("Table Name") .required(true) - .expressionLanguageSupported(false) + .expressionLanguageSupported(true) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .description("The DynamoDB table name") .build(); @@ -127,6 +127,7 @@ public abstract class AbstractDynamoDBProcessor extends AbstractAWSCredentialsPr public static final PropertyDescriptor HASH_KEY_NAME = new PropertyDescriptor.Builder() .name("Hash Key Name") .required(true) + .expressionLanguageSupported(true) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .description("The hash key name of the item") .build(); @@ -134,6 +135,7 @@ public abstract class AbstractDynamoDBProcessor extends AbstractAWSCredentialsPr public static final PropertyDescriptor RANGE_KEY_NAME = new PropertyDescriptor.Builder() .name("Range Key Name") .required(false) + .expressionLanguageSupported(true) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .description("The range key name of the item") .build(); @@ -141,6 +143,7 @@ public abstract class AbstractDynamoDBProcessor extends AbstractAWSCredentialsPr public static final PropertyDescriptor JSON_DOCUMENT = new PropertyDescriptor.Builder() .name("Json Document attribute") .required(true) + .expressionLanguageSupported(true) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .description("The Json document to be retrieved from the dynamodb item") .build(); @@ -148,7 +151,7 @@ public abstract class AbstractDynamoDBProcessor extends AbstractAWSCredentialsPr public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() .name("Batch items for each request (between 1 and 50)") .required(false) - .expressionLanguageSupported(false) + .expressionLanguageSupported(true) .addValidator(StandardValidators.createLongValidator(1, 50, true)) .defaultValue("1") .description("The items to be retrieved in one batch") @@ -159,6 +162,7 @@ public abstract class AbstractDynamoDBProcessor extends AbstractAWSCredentialsPr .description("Character set of data in the document") .addValidator(StandardValidators.CHARACTER_SET_VALIDATOR) .required(true) + .expressionLanguageSupported(true) .defaultValue(Charset.defaultCharset().name()) .build(); diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/DeleteDynamoDB.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/DeleteDynamoDB.java index a82de34fb6..ee614a6039 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/DeleteDynamoDB.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/DeleteDynamoDB.java @@ -83,18 +83,18 @@ public class DeleteDynamoDB extends AbstractWriteDynamoDBProcessor { @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { - List flowFiles = session.get(context.getProperty(BATCH_SIZE).asInteger()); + List flowFiles = session.get(context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger()); if (flowFiles == null || flowFiles.size() == 0) { return; } Map keysToFlowFileMap = new HashMap<>(); - final String table = context.getProperty(TABLE).getValue(); + final String table = context.getProperty(TABLE).evaluateAttributeExpressions().getValue(); - final String hashKeyName = context.getProperty(HASH_KEY_NAME).getValue(); + final String hashKeyName = context.getProperty(HASH_KEY_NAME).evaluateAttributeExpressions().getValue(); final String hashKeyValueType = context.getProperty(HASH_KEY_VALUE_TYPE).getValue(); - final String rangeKeyName = context.getProperty(RANGE_KEY_NAME).getValue(); + final String rangeKeyName = context.getProperty(RANGE_KEY_NAME).evaluateAttributeExpressions().getValue(); final String rangeKeyValueType = context.getProperty(RANGE_KEY_VALUE_TYPE).getValue(); TableWriteItems tableWriteItems = new TableWriteItems(table); diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/GetDynamoDB.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/GetDynamoDB.java index 808600c23e..73c9f9a075 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/GetDynamoDB.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/GetDynamoDB.java @@ -100,19 +100,19 @@ public class GetDynamoDB extends AbstractDynamoDBProcessor { @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { - List flowFiles = session.get(context.getProperty(BATCH_SIZE).asInteger()); + List flowFiles = session.get(context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger()); if (flowFiles == null || flowFiles.size() == 0) { return; } Map keysToFlowFileMap = new HashMap<>(); - final String table = context.getProperty(TABLE).getValue(); + final String table = context.getProperty(TABLE).evaluateAttributeExpressions().getValue(); TableKeysAndAttributes tableKeysAndAttributes = new TableKeysAndAttributes(table); - final String hashKeyName = context.getProperty(HASH_KEY_NAME).getValue(); - final String rangeKeyName = context.getProperty(RANGE_KEY_NAME).getValue(); - final String jsonDocument = context.getProperty(JSON_DOCUMENT).getValue(); + final String hashKeyName = context.getProperty(HASH_KEY_NAME).evaluateAttributeExpressions().getValue(); + final String rangeKeyName = context.getProperty(RANGE_KEY_NAME).evaluateAttributeExpressions().getValue(); + final String jsonDocument = context.getProperty(JSON_DOCUMENT).evaluateAttributeExpressions().getValue(); for (FlowFile flowFile : flowFiles) { final Object hashKeyValue = getValue(context, HASH_KEY_VALUE_TYPE, HASH_KEY_VALUE, flowFile); diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/PutDynamoDB.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/PutDynamoDB.java index 83fea37a57..a6b1764661 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/PutDynamoDB.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/PutDynamoDB.java @@ -95,21 +95,21 @@ public class PutDynamoDB extends AbstractWriteDynamoDBProcessor { @Override public void onTrigger(final ProcessContext context, final ProcessSession session) { - List flowFiles = session.get(context.getProperty(BATCH_SIZE).asInteger()); + List flowFiles = session.get(context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger()); if (flowFiles == null || flowFiles.size() == 0) { return; } Map keysToFlowFileMap = new HashMap<>(); - final String table = context.getProperty(TABLE).getValue(); + final String table = context.getProperty(TABLE).evaluateAttributeExpressions().getValue(); - final String hashKeyName = context.getProperty(HASH_KEY_NAME).getValue(); + final String hashKeyName = context.getProperty(HASH_KEY_NAME).evaluateAttributeExpressions().getValue(); final String hashKeyValueType = context.getProperty(HASH_KEY_VALUE_TYPE).getValue(); - final String rangeKeyName = context.getProperty(RANGE_KEY_NAME).getValue(); + final String rangeKeyName = context.getProperty(RANGE_KEY_NAME).evaluateAttributeExpressions().getValue(); final String rangeKeyValueType = context.getProperty(RANGE_KEY_VALUE_TYPE).getValue(); - final String jsonDocument = context.getProperty(JSON_DOCUMENT).getValue(); - final String charset = context.getProperty(DOCUMENT_CHARSET).getValue(); + final String jsonDocument = context.getProperty(JSON_DOCUMENT).evaluateAttributeExpressions().getValue(); + final String charset = context.getProperty(DOCUMENT_CHARSET).evaluateAttributeExpressions().getValue(); TableWriteItems tableWriteItems = new TableWriteItems(table);