Skip to content

Commit

Permalink
fix: fix bug in OAI-ORE exporter related to nested compound fields
Browse files Browse the repository at this point in the history
  • Loading branch information
vera committed Jan 27, 2025
1 parent 8f697d2 commit 263586c
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions src/main/java/edu/harvard/iq/dataverse/util/bagit/OREMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,39 +444,45 @@ public static JsonValue getJsonLDForField(DatasetField field, Boolean excludeEma

for (DatasetField dsf : dscv.getChildDatasetFields()) {
DatasetFieldType dsft = dsf.getDatasetFieldType();
if (excludeEmail && DatasetFieldType.FieldType.EMAIL.equals(dsft.getFieldType())) {
continue;
}
// which may have multiple values
if (!dsf.isEmpty()) {
// Add context entry
// ToDo - also needs to recurse here?
JsonLDTerm subFieldName = dsft.getJsonLDTerm();
if (subFieldName.inNamespace()) {
localContext.putIfAbsent(subFieldName.getNamespace().getPrefix(),
subFieldName.getNamespace().getUrl());
} else {
localContext.putIfAbsent(subFieldName.getLabel(), subFieldName.getUrl());
JsonLDTerm subFieldName = dsft.getJsonLDTerm();

if (dsft.isCompound()) {
JsonValue compoundChildVals = getJsonLDForField(dsf, excludeEmail, cvocMap, localContext);
child.add(subFieldName.getLabel(), compoundChildVals);
} else {
if (excludeEmail && DatasetFieldType.FieldType.EMAIL.equals(dsft.getFieldType())) {
continue;
}
// which may have multiple values
if (!dsf.isEmpty()) {
// Add context entry
// ToDo - also needs to recurse here?
if (subFieldName.inNamespace()) {
localContext.putIfAbsent(subFieldName.getNamespace().getPrefix(),
subFieldName.getNamespace().getUrl());
} else {
localContext.putIfAbsent(subFieldName.getLabel(), subFieldName.getUrl());
}

List<String> values = dsf.getValues_nondisplay();
List<String> values = dsf.getValues_nondisplay();

JsonArrayBuilder childVals = Json.createArrayBuilder();
JsonArrayBuilder childVals = Json.createArrayBuilder();

for (String val : dsf.getValues_nondisplay()) {
logger.fine("Child name: " + dsft.getName());
if (cvocMap.containsKey(dsft.getId())) {
logger.fine("Calling addcvocval for: " + dsft.getName());
addCvocValue(val, childVals, cvocMap.get(dsft.getId()), localContext);
for (String val : dsf.getValues_nondisplay()) {
logger.fine("Child name: " + dsft.getName());
if (cvocMap.containsKey(dsft.getId())) {
logger.fine("Calling addcvocval for: " + dsft.getName());
addCvocValue(val, childVals, cvocMap.get(dsft.getId()), localContext);
} else {
childVals.add(val);
}
}
if (values.size() > 1) {
child.add(subFieldName.getLabel(), childVals);
} else {
childVals.add(val);
child.add(subFieldName.getLabel(), childVals.build().get(0));
}
}
if (values.size() > 1) {
child.add(subFieldName.getLabel(), childVals);
} else {
child.add(subFieldName.getLabel(), childVals.build().get(0));
}
}
}
vals.add(child);
Expand Down

0 comments on commit 263586c

Please sign in to comment.