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

7056 Skip unknown types in a dataset which cause the whole dataset to… #7057

Merged
merged 3 commits into from
Jul 13, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ private List<DatasetField> parseFieldsFromArray(JsonArray fieldsArray, Boolean t
List<DatasetField> fields = new LinkedList<>();
for (JsonObject fieldJson : fieldsArray.getValuesAs(JsonObject.class)) {
try {
fields.add(parseField(fieldJson, testType));
DatasetField field = parseField(fieldJson, testType);
if (field != null) {
fields.add(field);
}
} catch (CompoundVocabularyException ex) {
DatasetFieldType fieldType = datasetFieldSvc.findByNameOpt(fieldJson.getString("typeName", ""));
if (lenient && (DatasetFieldConstant.geographicCoverage).equals(fieldType.getName())) {
Expand Down Expand Up @@ -566,7 +569,8 @@ public DatasetField parseField(JsonObject json, Boolean testType) throws JsonPar


if (type == null) {
throw new JsonParseException("Can't find type '" + json.getString("typeName", "") + "'");
logger.fine("Can't find type '" + json.getString("typeName", "") + "'");
return null;
}
if (testType && type.isAllowMultiples() != json.getBoolean("multiple")) {
throw new JsonParseException("incorrect multiple for field " + json.getString("typeName", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,12 @@ public void testParseEmptyDataset() throws JsonParseException {

/**
*
* Expect an exception when the dataset version JSON contains fields
* Expect no exception when the dataset version JSON contains fields
* that the {@link DatasetFieldService} doesn't know about.
* @throws JsonParseException as expected
* @throws JsonParseException should not happen here
* @throws IOException when test file IO goes wrong - this is bad.
*/
@Test(expected = JsonParseException.class)
@Test
public void testParseOvercompleteDatasetVersion() throws JsonParseException, IOException {
JsonObject dsJson;
try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/complete-dataset-version.json")) {
Expand Down