woutifier-t commented on a change in pull request #3977: NIFI-7007 Add update
functionality to the PutCassandraRecord processor.
URL: https://github.com/apache/nifi/pull/3977#discussion_r375287233
##########
File path:
nifi-nar-bundles/nifi-cassandra-bundle/nifi-cassandra-processors/src/main/java/org/apache/nifi/processors/cassandra/PutCassandraRecord.java
##########
@@ -362,6 +381,38 @@ private Long convertFieldObjectToLong(String name, Object
value) {
return ((Number) value).longValue();
}
+ @Override
+ protected Collection<ValidationResult> customValidate(ValidationContext
validationContext) {
+ Set<ValidationResult> results = (Set<ValidationResult>)
super.customValidate(validationContext);
+
+ String statementType =
validationContext.getProperty(STATEMENT_TYPE).getValue();
+
+ if (UPDATE_TYPE.getValue().equalsIgnoreCase(statementType)) {
+ // Check that update keys and update method are set
+ String updateKeys =
validationContext.getProperty(UPDATE_KEYS).getValue();
+ String updateMethod =
validationContext.getProperty(UPDATE_METHOD).getValue();
+ if (StringUtils.isEmpty(updateKeys)) {
+ results.add(new ValidationResult.Builder().subject("Update
statement configuration").valid(false).explanation(
+ "if the Statement Type is set to Update, then the
Update Keys must be specified as well").build());
+ }
+ if (StringUtils.isEmpty(updateMethod)) {
+ results.add(new ValidationResult.Builder().subject("Update
statement configuration").valid(false).explanation(
+ "if the Statement Type is set to Update, then the
Update Method must be specified as well").build());
+ }
+
+ // Check that if the update method is set to increment or
decrement that the batch statement type is set to
+ // unlogged or counter (or USE_ATTR_TYPE, which we cannot check at
this point).
+ String batchStatementType =
validationContext.getProperty(BATCH_STATEMENT_TYPE).getValue();
+ if (!Set.of(COUNTER_TYPE.getValue(), UNLOGGED_TYPE.getValue(),
BATCH_STATEMENT_TYPE_USE_ATTR_TYPE.getValue()).contains(batchStatementType)) {
Review comment:
Done, thanks for noticing this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services