pvillard31 commented on code in PR #8229:
URL: https://github.com/apache/nifi/pull/8229#discussion_r1452628163
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java:
##########
@@ -619,18 +632,83 @@ public NifiCsvListReader(Reader reader, CsvPreference
preferences) {
super(reader, preferences);
}
- @Override
- public List<Object> read(CellProcessor... processors) throws
IOException {
+ public List<Object> read(boolean getAllViolations, CellProcessor...
processors) throws IOException {
if( processors == null ) {
throw new NullPointerException("Processors should not be
null");
}
if( readRow() ) {
- super.executeProcessors(new
ArrayList<Object>(getColumns().size()), processors);
+ executeProcessors(new ArrayList<Object>(getColumns().size()),
processors, getAllViolations);
return new ArrayList<Object>(getColumns());
}
return null; // EOF
}
+ protected List<Object> executeProcessors(List<Object>
processedColumns, CellProcessor[] processors, boolean getAllViolations) {
+ this.executeCellProcessors(processedColumns, getColumns(),
processors, getLineNumber(), getRowNumber(), getAllViolations);
+ return processedColumns;
+ }
+
+ private void executeCellProcessors(final List<Object> destination,
final List<?> source,
+ final CellProcessor[] processors, final int lineNo, final int
rowNo, boolean getAllViolations) {
+
+ if( destination == null ) {
+ throw new NullPointerException("destination should not be
null");
+ } else if( source == null ) {
+ throw new NullPointerException("source should not be
null");
+ } else if( processors == null ) {
+ throw new NullPointerException("processors should not be
null");
+ }
Review Comment:
This code is copied from the Utils class of the underlying library we're
using and I didn't want to change its code. That's the reason it is this way. I
don't mind changing it though.
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java:
##########
@@ -619,18 +632,83 @@ public NifiCsvListReader(Reader reader, CsvPreference
preferences) {
super(reader, preferences);
}
- @Override
- public List<Object> read(CellProcessor... processors) throws
IOException {
+ public List<Object> read(boolean getAllViolations, CellProcessor...
processors) throws IOException {
if( processors == null ) {
throw new NullPointerException("Processors should not be
null");
}
if( readRow() ) {
- super.executeProcessors(new
ArrayList<Object>(getColumns().size()), processors);
+ executeProcessors(new ArrayList<Object>(getColumns().size()),
processors, getAllViolations);
return new ArrayList<Object>(getColumns());
}
return null; // EOF
}
+ protected List<Object> executeProcessors(List<Object>
processedColumns, CellProcessor[] processors, boolean getAllViolations) {
+ this.executeCellProcessors(processedColumns, getColumns(),
processors, getLineNumber(), getRowNumber(), getAllViolations);
+ return processedColumns;
+ }
+
+ private void executeCellProcessors(final List<Object> destination,
final List<?> source,
+ final CellProcessor[] processors, final int lineNo, final int
rowNo, boolean getAllViolations) {
+
+ if( destination == null ) {
+ throw new NullPointerException("destination should not be
null");
+ } else if( source == null ) {
+ throw new NullPointerException("source should not be
null");
+ } else if( processors == null ) {
+ throw new NullPointerException("processors should not be
null");
+ }
+
+ // the context used when cell processors report exceptions
+ final CsvContext context = new CsvContext(lineNo, rowNo, 1);
+ context.setRowSource(new ArrayList<Object>(source));
Review Comment:
While I agree specifying the type is not required, isn't it making the code
more readable?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]