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

Changed handling of bad data level (#252) #253

Merged
merged 1 commit into from
Feb 9, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## NAACCR XML Version History

**Version 10.2**

- Changed data level errors from an exception to a validation error reported on the item.

**Version 10.1**

- Optimized read SAS macro.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/imsweb/naaccrxml/NaaccrErrorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ private NaaccrErrorUtils() {
public static final String CODE_BAD_LINE_LENGTH = "Invalid line length";
public static final String CODE_BAD_NAACCR_ID = "Unknown NAACCR ID";
public static final String CODE_BAD_NAACCR_NUM = "Wrong NAACCR Number";
public static final String CODE_BAD_DATA_LEVEL = "Invalid data level";
public static final String CODE_VAL_TOO_LONG = "Value too long";
public static final String CODE_VAL_TOO_SHORT = "Value too short";
public static final String CODE_VAL_DATA_TYPE = "Value invalid for data type";
Expand All @@ -36,6 +37,7 @@ private NaaccrErrorUtils() {
_MESSAGES.put(CODE_BAD_LINE_LENGTH, "invalid line length, expected ${0} but got ${1}");
_MESSAGES.put(CODE_BAD_NAACCR_ID, "unknown NAACCR ID: ${0}");
_MESSAGES.put(CODE_BAD_NAACCR_NUM, "NAACCR Number '${0}' does not correspond to NAACCR ID '${1}'");
_MESSAGES.put(CODE_BAD_DATA_LEVEL, "invalid data level, expected ${0} but got ${1}");
_MESSAGES.put(CODE_VAL_TOO_LONG, "value too long, expected at most ${0} character(s) but got ${1}");
_MESSAGES.put(CODE_VAL_TOO_SHORT, "value too short, expected exactly ${0} character(s) but got ${1}");
_MESSAGES.put(CODE_VAL_DATA_TYPE, "invalid value according to data type '${0}'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ else if (NaaccrXmlDictionaryUtils.NAACCR_PADDING_RIGHT_ZERO.equals(itemDef.getPa
value = StringUtils.rightPad(value, itemDef.getLength(), '0');
}
else if (!NaaccrXmlDictionaryUtils.NAACCR_PADDING_LEFT_BLANK.equals(itemDef.getPadding()) && !NaaccrXmlDictionaryUtils.NAACCR_PADDING_RIGHT_BLANK.equals(itemDef.getPadding())
&& !NaaccrXmlDictionaryUtils.NAACCR_PADDING_NONE.equals(itemDef.getPadding()))
&& !NaaccrXmlDictionaryUtils.NAACCR_PADDING_NONE.equals(itemDef.getPadding()))
throw new IllegalStateException("Unknown padding option: " + itemDef.getPadding());
}

Expand Down Expand Up @@ -356,7 +356,7 @@ else if (def.getDataType() != null) {
if (NaaccrXmlUtils.NAACCR_XML_TAG_PATIENT.equals(parentTag) && NaaccrXmlDictionaryUtils.getPatToTumorChangedNaaccr18And21Ids().contains(rawId))
return item;

reportSyntaxError("invalid parent XML tag for '" + def.getNaaccrId() + "'; was expecting '" + def.getParentXmlElement() + "' but got '" + parentTag + "'");
reportError(item, lineNumber, currentPath, def, item.getValue(), NaaccrErrorUtils.CODE_BAD_DATA_LEVEL, def.getParentXmlElement(), parentTag);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/imsweb/naaccrxml/XsdSchemaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class XsdSchemaTest {
private static final String _XSD_FILE = "xsd/naaccr_data_1.7.xsd";

@Test
@SuppressWarnings("resource")
public void testXsdAgainstLibrary() throws IOException {
Path dir = Paths.get(TestingUtils.getWorkingDirectory() + "/src/test/resources/data/validity");

Expand Down

This file was deleted.

Loading