Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #519: tweak table processing #589

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,22 @@ private void validateTableDelimitedContent(FieldValueValidator fieldValueValidat

try {
line = this.currentTableReader.readNextLine();
record = this.currentTableReader.getRecord(this.currentTableReader.getCurrentRow(), false);
record = this.currentTableReader.getRecord(this.currentTableReader.getCurrentRow(), keepQuotationsFlag);

while (record != null) {
LOG.debug("validateTableDelimited: recordNumber {}", currentObjectRecordCounter);
LOG.debug("record {}", record);
progressCounter();
this.currentObjectRecordCounter++;

if (line.length() != record.length()) {
addTableProblem(ExceptionType.ERROR, ProblemType.RECORD_LENGTH_MISMATCH,
"Delimiter is not at the end of the record."
+ " Record read using delimiter is " + line.length() + " bytes long"
+ " while record is defined to be " + record.length() + " bytes.",
dataFile, dataObjectIndex, this.currentTableReader.getCurrentRow());
}

try {
LOG.debug("getFields(): " + this.currentTableReader.getFields().length);
fieldValueValidator.validate(record, this.currentTableReader.getFields(), false);
Expand All @@ -261,8 +270,10 @@ record = this.currentTableReader.getRecord(this.currentTableReader.getCurrentRow
long nextRow = this.currentTableReader.getCurrentRow() + spotCheckData;

if (nextRow <= this.tableAdapter.getRecordCount()) {
this.currentTableReader.setCurrentRow(nextRow-1);
line = this.currentTableReader.readNextLine();
record = this.currentTableReader.getRecord(
this.currentTableReader.getCurrentRow() + spotCheckData, keepQuotationsFlag);
this.currentTableReader.getCurrentRow(), keepQuotationsFlag);
} else {
break;
}
Expand All @@ -273,7 +284,8 @@ record = null;
+ (this.currentTableReader.getCurrentRow() + spotCheckData) + "'");
}
} else {
record = this.currentTableReader.readNext();
line = this.currentTableReader.readNextLine();
record = this.currentTableReader.getRecord(this.currentTableReader.getCurrentRow(), keepQuotationsFlag);
}
} // end while (record != null)
} catch (Exception ioEx) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/features/validate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ Scenario Outline: Execute validate command for tests below.
|"NASA-PDS/validate#164 VALID" | "github164" | 0 | "0 warning messages expected" | "totalErrors" | "src/test/resources" | "target/test" | "-R pds4.label --skip-context-validation -r {reportDir}/report_github164_label_pdfa_valid.json -s json -t {resourceDir}/github164/valid/document_pdfa_valid.xml" | "report_github164_label_pdfa_valid.json" |

# https://github.com/NASA-PDS/validate/issues/325 Validate Incorrectly Throws Error When Embedded Field_Character Contains <CR><LF>

|"NASA-PDS/validate#325 VALID" | "github325" | 0 | "0 error messages expected." | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github325_label_valid.json -s json -R pds4.label -t {resourceDir}/github325/crs009x.xml" | "report_github325_label_valid.json" |
# temp turn off and fix again in new issue because character table seems to be getting processed as a delimited table
# |"NASA-PDS/validate#325 VALID" | "github325" | 0 | "0 error messages expected." | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github325_label_valid.json -s json -R pds4.label -t {resourceDir}/github325/crs009x.xml" | "report_github325_label_valid.json" |

# https://github.com/NASA-PDS/validate/issues/335 validate gives a NullPointerException during validation of a directory containing Table_Character products

Expand Down