Skip to content

Commit

Permalink
#8868 update handling of undefined mdl
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Aug 12, 2022
1 parent 1e52809 commit f793858
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public void setMetadataLanguage(String ml) {
}
}

public static boolean isMetadataLanguageSet(String mdLang) {
return mdLang!=null && !mdLang.equals(UNDEFINED_METADATA_LANGUAGE_CODE);
}


/* Dataverse collections can be configured to allow use of Curation labels and have this inheritable value to decide which set of labels to use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class DublinCoreExporter implements Exporter {



@Override
public String getProviderName() {
return "oai_dc";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static void dtoddi(DatasetDTO datasetDto, OutputStream outputStream) thr
xmlw.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlw.writeAttribute("xsi:schemaLocation", DDIExporter.DEFAULT_XML_NAMESPACE + " " + DDIExporter.DEFAULT_XML_SCHEMALOCATION);
writeAttribute(xmlw, "version", DDIExporter.DEFAULT_XML_VERSION);
if(isMetadataLanguageSet(datasetDto.getMetadataLanguage())) {
if(DvObjectContainer.isMetadataLanguageSet(datasetDto.getMetadataLanguage())) {
writeAttribute(xmlw, "xml:lang", datasetDto.getMetadataLanguage());
}
createStdyDscr(xmlw, datasetDto);
Expand All @@ -151,7 +151,7 @@ public static void datasetJson2ddi(JsonObject datasetDtoAsJson, DatasetVersion v
xmlw.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlw.writeAttribute("xsi:schemaLocation", DDIExporter.DEFAULT_XML_NAMESPACE + " " + DDIExporter.DEFAULT_XML_SCHEMALOCATION);
writeAttribute(xmlw, "version", DDIExporter.DEFAULT_XML_VERSION);
if(isMetadataLanguageSet(datasetDto.getMetadataLanguage())) {
if(DvObjectContainer.isMetadataLanguageSet(datasetDto.getMetadataLanguage())) {
writeAttribute(xmlw, "xml:lang", datasetDto.getMetadataLanguage());
}
createStdyDscr(xmlw, datasetDto);
Expand All @@ -161,14 +161,6 @@ public static void datasetJson2ddi(JsonObject datasetDtoAsJson, DatasetVersion v
xmlw.writeEndElement(); // codeBook
xmlw.flush();
}


private static boolean isMetadataLanguageSet(String mdLang) {
if(mdLang!=null && !mdLang.equals(DvObjectContainer.UNDEFINED_METADATA_LANGUAGE_CODE)) {
return true;
}
return false;
}

/**
* @todo This is just a stub, copied from DDIExportServiceBean. It should
Expand Down Expand Up @@ -944,7 +936,7 @@ private static void writeDistributorsElement(XMLStreamWriter xmlw, DatasetVersio
}
if (!distributorName.isEmpty()) {
xmlw.writeStartElement("distrbtr");
if(isMetadataLanguageSet(lang)) {
if(DvObjectContainer.isMetadataLanguageSet(lang)) {
writeAttribute(xmlw, "xml:lang", lang);
}
if (!distributorAffiliation.isEmpty()) {
Expand Down Expand Up @@ -1064,7 +1056,7 @@ private static void writeAbstractElement(XMLStreamWriter xmlw, DatasetVersionDTO
if(!descriptionDate.isEmpty()){
writeAttribute(xmlw,"date",descriptionDate);
}
if(isMetadataLanguageSet(lang)) {
if(DvObjectContainer.isMetadataLanguageSet(lang)) {
writeAttribute(xmlw, "xml:lang", lang);
}
xmlw.writeCharacters(descriptionText);
Expand Down Expand Up @@ -1538,7 +1530,7 @@ private static void writeFullElement (XMLStreamWriter xmlw, String name, String
//For the simplest Elements we can
if (!StringUtilisEmpty(value)) {
xmlw.writeStartElement(name);
if(isMetadataLanguageSet(lang)) {
if(DvObjectContainer.isMetadataLanguageSet(lang)) {
writeAttribute(xmlw, "xml:lang", lang);
}
xmlw.writeCharacters(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public JsonObjectBuilder getOREMapBuilder(boolean aggregationOnly) throws Except

aggBuilder.add(JsonLDTerm.schemaOrg("isPartOf").getLabel(), getDataverseDescription(dataset.getOwner()));
String mdl = dataset.getMetadataLanguage();
if(!mdl.equals(DvObjectContainer.UNDEFINED_METADATA_LANGUAGE_CODE)) {
if (DvObjectContainer.isMetadataLanguageSet(mdl)) {
aggBuilder.add(JsonLDTerm.schemaOrg("inLanguage").getLabel(), mdl);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,19 @@ public static JsonObjectBuilder json(BuiltinUser user) {
}

public static JsonObjectBuilder json(Dataset ds) {
return jsonObjectBuilder()
JsonObjectBuilder bld = jsonObjectBuilder()
.add("id", ds.getId())
.add("identifier", ds.getIdentifier())
.add("persistentUrl", ds.getPersistentURL())
.add("protocol", ds.getProtocol())
.add("authority", ds.getAuthority())
.add("publisher", BrandingUtil.getInstallationBrandName())
.add("publicationDate", ds.getPublicationDateFormattedYYYYMMDD())
.add("storageIdentifier", ds.getStorageIdentifier())
.add("metadataLanguage", ds.getMetadataLanguage());
.add("storageIdentifier", ds.getStorageIdentifier());
if (DvObjectContainer.isMetadataLanguageSet(ds.getMetadataLanguage())) {
bld.add("metadataLanguage", ds.getMetadataLanguage());
}
return bld;
}

public static JsonObjectBuilder json(DatasetVersion dsv) {
Expand Down

0 comments on commit f793858

Please sign in to comment.