Skip to content

Commit

Permalink
adjusted the ddi exporter to accommodate productionPlace having been …
Browse files Browse the repository at this point in the history
…made

multiple in PR #9254; would be great to put together a process for developers
who need to make changes to fields in metadata blocks that would help
them to know of all the places where changes like this need to be made.
(not the first time, when something breaks, in ddi export specifically, after
a field is made multiple). #3648
  • Loading branch information
landreev committed Apr 19, 2023
1 parent b6c2599 commit 14603c2
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,13 @@ private static void writeProducersElement(XMLStreamWriter xmlw, DatasetVersionDT
}
}
}
writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate));
writeFullElement(xmlw, "prodPlac", dto2Primitive(version, DatasetFieldConstant.productionPlace));
writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate));
// productionPlace was made multiple as of 5.14:
// (a quick backward compatibility check was added to dto2PrimitiveList(),
// see the method for details)
for (String productionPlace : dto2PrimitiveList(version, DatasetFieldConstant.productionPlace)) {
writeFullElement(xmlw, "prodPlac", productionPlace);
}
writeSoftwareElement(xmlw, version);

writeGrantElement(xmlw, version);
Expand Down Expand Up @@ -1557,7 +1562,15 @@ private static List<String> dto2PrimitiveList(DatasetVersionDTO datasetVersionDT
MetadataBlockDTO value = entry.getValue();
for (FieldDTO fieldDTO : value.getFields()) {
if (datasetFieldTypeName.equals(fieldDTO.getTypeName())) {
return fieldDTO.getMultiplePrimitive();
// This hack is here to make sure the export does not blow
// up on an instance that upgraded to a Dataverse version
// where a certain primitive has been made multiple, but has
// not yet update the block.
if (fieldDTO.getMultiple()) {
return fieldDTO.getMultiplePrimitive();
} else {
return Arrays.asList(fieldDTO.getSinglePrimitive());
}
}
}
}
Expand Down

0 comments on commit 14603c2

Please sign in to comment.