Skip to content

Commit 14603c2

Browse files
committed
adjusted the ddi exporter to accommodate productionPlace having been 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
1 parent b6c2599 commit 14603c2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/main/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtil.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,13 @@ private static void writeProducersElement(XMLStreamWriter xmlw, DatasetVersionDT
10061006
}
10071007
}
10081008
}
1009-
writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate));
1010-
writeFullElement(xmlw, "prodPlac", dto2Primitive(version, DatasetFieldConstant.productionPlace));
1009+
writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate));
1010+
// productionPlace was made multiple as of 5.14:
1011+
// (a quick backward compatibility check was added to dto2PrimitiveList(),
1012+
// see the method for details)
1013+
for (String productionPlace : dto2PrimitiveList(version, DatasetFieldConstant.productionPlace)) {
1014+
writeFullElement(xmlw, "prodPlac", productionPlace);
1015+
}
10111016
writeSoftwareElement(xmlw, version);
10121017

10131018
writeGrantElement(xmlw, version);
@@ -1557,7 +1562,15 @@ private static List<String> dto2PrimitiveList(DatasetVersionDTO datasetVersionDT
15571562
MetadataBlockDTO value = entry.getValue();
15581563
for (FieldDTO fieldDTO : value.getFields()) {
15591564
if (datasetFieldTypeName.equals(fieldDTO.getTypeName())) {
1560-
return fieldDTO.getMultiplePrimitive();
1565+
// This hack is here to make sure the export does not blow
1566+
// up on an instance that upgraded to a Dataverse version
1567+
// where a certain primitive has been made multiple, but has
1568+
// not yet update the block.
1569+
if (fieldDTO.getMultiple()) {
1570+
return fieldDTO.getMultiplePrimitive();
1571+
} else {
1572+
return Arrays.asList(fieldDTO.getSinglePrimitive());
1573+
}
15611574
}
15621575
}
15631576
}

0 commit comments

Comments
 (0)