diff --git a/doc/release-notes/6650-export-import-mismatch b/doc/release-notes/6650-export-import-mismatch new file mode 100644 index 00000000000..0ab2999a603 --- /dev/null +++ b/doc/release-notes/6650-export-import-mismatch @@ -0,0 +1,3 @@ +Run ReExportall to update JSON Exports + +http://guides.dataverse.org/en/4.19/admin/metadataexport.html?highlight=export#batch-exports-through-the-api \ No newline at end of file diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java index 69de63c5fa6..6d26c0cba58 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldConstant.java @@ -97,7 +97,7 @@ public class DatasetFieldConstant implements java.io.Serializable { public final static String topicClassVocab="topicClassVocab"; public final static String topicClassVocabURI="topicClassVocabURI"; public final static String descriptionText="dsDescriptionValue"; - public final static String descriptionDate="descriptionDate"; + public final static String descriptionDate="dsDescriptionDate"; public final static String timePeriodCovered="timePeriodCovered"; // SEK added 6/13/2016 public final static String timePeriodCoveredStart="timePeriodCoveredStart"; public final static String timePeriodCoveredEnd="timePeriodCoveredEnd"; diff --git a/src/main/java/edu/harvard/iq/dataverse/api/imports/ImportDDIServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/api/imports/ImportDDIServiceBean.java index 178a23b6f2f..ce2f646322c 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/imports/ImportDDIServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/imports/ImportDDIServiceBean.java @@ -10,6 +10,8 @@ import edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO; import edu.harvard.iq.dataverse.api.imports.ImportUtil.ImportType; import static edu.harvard.iq.dataverse.export.ddi.DdiExportUtil.NOTE_TYPE_CONTENTTYPE; +import static edu.harvard.iq.dataverse.export.ddi.DdiExportUtil.NOTE_TYPE_TERMS_OF_ACCESS; + import edu.harvard.iq.dataverse.util.StringUtil; import java.io.File; import java.io.FileInputStream; @@ -27,6 +29,8 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLInputFactory; + +import edu.harvard.iq.dataverse.util.json.ControlledVocabularyException; import org.apache.commons.lang.StringUtils; /** @@ -265,18 +269,18 @@ private void processCodeBook(ImportType importType, XMLStreamReader xmlr, Datase } } } - + private void processDocDscr(XMLStreamReader xmlr, DatasetDTO datasetDTO) throws XMLStreamException { for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) { if (event == XMLStreamConstants.START_ELEMENT) { - + if (xmlr.getLocalName().equals("IDNo") && StringUtil.isEmpty(datasetDTO.getIdentifier()) ) { // this will set a StudyId if it has not yet been set; it will get overridden by a metadata // id in the StudyDscr section, if one exists if ( AGENCY_HANDLE.equals( xmlr.getAttributeValue(null, "agency") ) ) { parseStudyIdHandle( parseText(xmlr), datasetDTO ); - } - // EMK TODO: we need to save this somewhere when we add harvesting infrastructure + } + // EMK TODO: we need to save this somewhere when we add harvesting infrastructure } /*else if ( xmlr.getLocalName().equals("holdings") && StringUtil.isEmpty(datasetDTO..getHarvestHoldings()) ) { metadata.setHarvestHoldings( xmlr.getAttributeValue(null, "URI") ); }*/ @@ -284,7 +288,7 @@ private void processDocDscr(XMLStreamReader xmlr, DatasetDTO datasetDTO) throws if (xmlr.getLocalName().equals("docDscr")) return; } } - } + } private String parseText(XMLStreamReader xmlr) throws XMLStreamException { return parseText(xmlr,true); } @@ -344,7 +348,8 @@ private void processStdyDscr(ImportType importType, XMLStreamReader xmlr, Datase else if (xmlr.getLocalName().equals("stdyInfo")) processStdyInfo(xmlr, datasetDTO.getDatasetVersion()); else if (xmlr.getLocalName().equals("method")) processMethod(xmlr, datasetDTO.getDatasetVersion()); - else if (xmlr.getLocalName().equals("dataAccs")) processDataAccs(xmlr, datasetDTO.getDatasetVersion()); + else if (xmlr.getLocalName().equals("dataAccs")) processDataAccs(xmlr, datasetDTO.getDatasetVersion()); + else if (xmlr.getLocalName().equals("notes")) processStdyNotes(xmlr, datasetDTO.getDatasetVersion()); else if (xmlr.getLocalName().equals("othrStdyMat")) processOthrStdyMat(xmlr, datasetDTO.getDatasetVersion()); else if (xmlr.getLocalName().equals("notes")) processNotes(xmlr, datasetDTO.getDatasetVersion()); @@ -390,41 +395,12 @@ else if (xmlr.getLocalName().equals("relStdy")) { relStudy.add(parseText(xmlr, "relStdy")); getCitation(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO(DatasetFieldConstant.relatedDatasets, relStudy)); } else if (xmlr.getLocalName().equals("relPubl")) { - HashSet set = new HashSet<>(); - - // call new parse text logic - Object rpFromDDI = parseTextNew(xmlr, "relPubl"); - if (rpFromDDI instanceof Map) { - Map rpMap = (Map) rpFromDDI; - addToSet(set, DatasetFieldConstant.publicationCitation, rpMap.get("text")); - addToSet(set, DatasetFieldConstant.publicationIDNumber, rpMap.get("idNumber")); - addToSet(set, DatasetFieldConstant.publicationURL, rpMap.get("url")); - if (rpMap.get("idType")!=null) { - set.add(FieldDTO.createVocabFieldDTO(DatasetFieldConstant.publicationIDType, rpMap.get("idType").toLowerCase())); - } - // rp.setText((String) rpMap.get("text")); - // rp.setIdType((String) rpMap.get("idType")); - // rp.setIdNumber((String) rpMap.get("idNumber")); - // rp.setUrl((String) rpMap.get("url")); - // TODO: ask about where/whether we want to save this - // if (!replicationForFound && rpMap.get("replicationData") != null) { - // rp.setReplicationData(true); - /// replicationForFound = true; - // } - } else { - addToSet(set, DatasetFieldConstant.publicationCitation, (String) rpFromDDI); - // rp.setText( (String) rpFromDDI ); - } - publications.add(set); - - - } else if (xmlr.getLocalName().equals("otherRefs")) { - + processRelPubl(xmlr, dvDTO, publications); + } else if (xmlr.getLocalName().equals("othRefs")) { List otherRefs = new ArrayList<>(); - otherRefs.add(parseText(xmlr, "otherRefs")); + otherRefs.add(parseText(xmlr, "othRefs")); getCitation(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO(DatasetFieldConstant.otherReferences, otherRefs)); - - } + } } else if (event == XMLStreamConstants.END_ELEMENT) { if (publications.size()>0) { getCitation(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO(DatasetFieldConstant.publication, publications)); @@ -435,6 +411,49 @@ else if (xmlr.getLocalName().equals("relStdy")) { } } } + private void processRelPubl(XMLStreamReader xmlr, DatasetVersionDTO dvDTO, List> publications) throws XMLStreamException { + HashSet set = new HashSet<>(); + for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) { + if (event == XMLStreamConstants.START_ELEMENT) { + if (xmlr.getLocalName().equals("citation")) { + for (int event2 = xmlr.next(); event2 != XMLStreamConstants.END_DOCUMENT; event2 = xmlr.next()) { + if (event2 == XMLStreamConstants.START_ELEMENT) { + if (xmlr.getLocalName().equals("titlStmt")) { + int event3 = xmlr.next(); + if (event3 == XMLStreamConstants.START_ELEMENT) { + if (xmlr.getLocalName().equals("IDNo")) { + set.add(FieldDTO.createVocabFieldDTO(DatasetFieldConstant.publicationIDType, xmlr.getAttributeValue(null, "agency"))); + addToSet(set, DatasetFieldConstant.publicationIDNumber, parseText(xmlr)); + } + } + } else if (xmlr.getLocalName().equals("biblCit")) { + if (event2 == XMLStreamConstants.START_ELEMENT) { + if (xmlr.getLocalName().equals("biblCit")) { + addToSet(set, DatasetFieldConstant.publicationCitation, parseText(xmlr)); + } + } + } + } else if (event2 == XMLStreamConstants.END_ELEMENT) { + if (xmlr.getLocalName().equals("citation")) { + break; + } + } + + } + } else if (xmlr.getLocalName().equals("ExtLink")) { + addToSet(set, DatasetFieldConstant.publicationURL, xmlr.getAttributeValue(null, "URI")); + } + } else if (event == XMLStreamConstants.END_ELEMENT) { + if (xmlr.getLocalName().equals("relPubl")) { + if (set.size() > 0) { + publications.add(set); + } + return; + } + } + } + } + private void processCitation(ImportType importType, XMLStreamReader xmlr, DatasetDTO datasetDTO) throws XMLStreamException, ImportException { DatasetVersionDTO dvDTO = datasetDTO.getDatasetVersion(); MetadataBlockDTO citation=datasetDTO.getDatasetVersion().getMetadataBlocks().get("citation"); @@ -620,6 +639,52 @@ private void processNotes (XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throws this.addNote(formattedNotes, dvDTO); } } + private void processStdyNotes(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throws XMLStreamException { + FieldDTO notesText = null; + // Add notes, if they exist + String attrVal = parseText(xmlr, "notes"); + if ((attrVal != null) && (!attrVal.isEmpty())){ + notesText = FieldDTO.createPrimitiveFieldDTO("datasetLevelErrorNotes", attrVal); + getSocialScience(dvDTO).addField(notesText); + } + } + + + private void processNotesSocialScience(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throws XMLStreamException { + //String formattedNotes = this.formatNotesfromXML(xmlr); + if (xmlr==null){ + throw new NullPointerException("XMLStreamReader xmlr cannot be null"); + } + FieldDTO notesSubject = null; + String attrVal; + + // Check for "subject" + attrVal = xmlr.getAttributeValue(null, "subject"); + if (attrVal != null){ + notesSubject = FieldDTO.createPrimitiveFieldDTO("socialScienceNotesSubject", attrVal); + } + + FieldDTO notesType = null; + // Check for "type" + attrVal = xmlr.getAttributeValue(null, "type"); + if (attrVal != null){ + notesType = FieldDTO.createPrimitiveFieldDTO("socialScienceNotesType", attrVal); + } + + FieldDTO notesText = null; + // Add notes, if they exist + attrVal = parseText(xmlr, "notes"); + if ((attrVal != null) && (!attrVal.isEmpty())){ + notesText = FieldDTO.createPrimitiveFieldDTO("socialScienceNotesText", attrVal); + } + + if (notesSubject != null || notesType != null || notesText != null ){ + + //this.addNoteSocialScience(formattedNotes, dvDTO); + + getSocialScience(dvDTO).addField(FieldDTO.createCompoundFieldDTO("socialScienceNotes", notesSubject, notesType, notesText )); + } + } private void addNote(String noteText, DatasetVersionDTO dvDTO ) { MetadataBlockDTO citation = getCitation(dvDTO); @@ -640,12 +705,17 @@ private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throw List kindOfData = new ArrayList<>(); List> geoBoundBox = new ArrayList<>(); List> geoCoverages = new ArrayList<>(); + List timePeriod = new ArrayList<>(); + List dateOfCollection = new ArrayList<>(); FieldDTO timePeriodStart = null; FieldDTO timePeriodEnd = null; FieldDTO dateOfCollectionStart = null; FieldDTO dateOfCollectionEnd = null; + HashSet geoCoverageSet = null; + String otherGeographicCoverage = null; for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) { + if (event == XMLStreamConstants.START_ELEMENT) { if (xmlr.getLocalName().equals("timePrd")) { @@ -654,6 +724,8 @@ private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throw timePeriodStart = FieldDTO.createPrimitiveFieldDTO("timePeriodCoveredStart", parseDate(xmlr, "timePrd")); } else if (EVENT_END.equals(eventAttr)) { timePeriodEnd = FieldDTO.createPrimitiveFieldDTO("timePeriodCoveredEnd", parseDate(xmlr, "timePrd")); + timePeriod.add(FieldDTO.createMultipleCompoundFieldDTO("timePeriodCovered", timePeriodStart, timePeriodEnd)); + } } else if (xmlr.getLocalName().equals("collDate")) { String eventAttr = xmlr.getAttributeValue(null, "event"); @@ -661,16 +733,32 @@ private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throw dateOfCollectionStart = FieldDTO.createPrimitiveFieldDTO("dateOfCollectionStart", parseDate(xmlr, "collDate")); } else if (EVENT_END.equals(eventAttr)) { dateOfCollectionEnd = FieldDTO.createPrimitiveFieldDTO("dateOfCollectionEnd", parseDate(xmlr, "collDate")); + dateOfCollection.add(FieldDTO.createMultipleCompoundFieldDTO("dateOfCollection", dateOfCollectionStart, dateOfCollectionEnd )); } } else if (xmlr.getLocalName().equals("nation")) { - HashSet set = new HashSet<>(); - set.add(FieldDTO.createVocabFieldDTO("country", parseText(xmlr))); - geoCoverages.add(set); + if (otherGeographicCoverage != null && !otherGeographicCoverage.equals("")) { + geoCoverageSet.add(FieldDTO.createPrimitiveFieldDTO("otherGeographicCoverage", otherGeographicCoverage)); + otherGeographicCoverage = null; + } + if (geoCoverageSet != null && geoCoverageSet.size() > 0) { + geoCoverages.add(geoCoverageSet); + } + geoCoverageSet = new HashSet<>(); + //HashSet set = new HashSet<>(); + //set.add(FieldDTO.createVocabFieldDTO("country", parseText(xmlr))); + geoCoverageSet.add(FieldDTO.createVocabFieldDTO("country", parseText(xmlr))); + } else if (xmlr.getLocalName().equals("geogCover")) { - HashSet set = new HashSet<>(); - set.add(FieldDTO.createPrimitiveFieldDTO("otherGeographicCoverage", parseText(xmlr))); - geoCoverages.add(set); + if (geoCoverageSet == null) { + geoCoverageSet = new HashSet<>(); + } + if (otherGeographicCoverage != null) { + otherGeographicCoverage = otherGeographicCoverage + "; " + parseText(xmlr); + } else { + otherGeographicCoverage = parseText(xmlr); + } + } else if (xmlr.getLocalName().equals("geogUnit")) { geoUnit.add(parseText(xmlr)); } else if (xmlr.getLocalName().equals("geoBndBox")) { @@ -684,11 +772,11 @@ private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throw } } else if (event == XMLStreamConstants.END_ELEMENT) { if (xmlr.getLocalName().equals("sumDscr")) { - if (timePeriodStart!=null || timePeriodEnd!=null) { - getCitation(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("timePeriodCovered", timePeriodStart, timePeriodEnd)); + for (FieldDTO time : timePeriod) { + getCitation(dvDTO).addField( time); } - if (dateOfCollectionStart!=null || dateOfCollectionEnd!=null) { - getCitation(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("dateOfCollection", dateOfCollectionStart, dateOfCollectionEnd)); + for (FieldDTO date : dateOfCollection) { + getCitation(dvDTO).addField(date); } if (geoUnit.size() > 0) { @@ -703,8 +791,14 @@ private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throw if (kindOfData.size() > 0) { getCitation(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO("kindOfData", kindOfData)); } - if (geoCoverages.size()>0) { - getGeospatial(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("geographicCoverage", geoCoverages)); + if (otherGeographicCoverage != null && !otherGeographicCoverage.equals("") ) { + geoCoverageSet.add(FieldDTO.createPrimitiveFieldDTO("otherGeographicCoverage", otherGeographicCoverage)); + } + if (geoCoverageSet != null && geoCoverageSet.size() > 0) { + geoCoverages.add(geoCoverageSet); + } + if (geoCoverages.size() > 0) { + getGeospatial(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO(DatasetFieldConstant.geographicCoverage, geoCoverages)); } if (geoBoundBox.size()>0) { getGeospatial(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("geographicBoundingBox", geoBoundBox)); @@ -715,8 +809,6 @@ private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throw } } - - private HashSet processGeoBndBox(XMLStreamReader xmlr) throws XMLStreamException { HashSet set = new HashSet<>(); @@ -748,9 +840,7 @@ private void processMethod(XMLStreamReader xmlr, DatasetVersionDTO dvDTO ) throw if (NOTE_TYPE_EXTENDED_METADATA.equalsIgnoreCase(noteType) ) { processCustomField(xmlr, dvDTO); } else { - processNotes(xmlr, dvDTO); -// addNote("Subject: Study Level Error Note, Notes: "+ parseText( xmlr,"notes" ) +";", dvDTO); - + processNotesSocialScience(xmlr, dvDTO); } } else if (xmlr.getLocalName().equals("anlyInfo")) { processAnlyInfo(xmlr, getSocialScience(dvDTO)); @@ -959,8 +1049,8 @@ private void processDataColl(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) thro socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("dataCollectionSituation", parseText( xmlr, "collSitu" ))); } else if (xmlr.getLocalName().equals("actMin")) { socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("actionsToMinimizeLoss", parseText( xmlr, "actMin" ))); - } else if (xmlr.getLocalName().equals("ConOps")) { - socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("controlOperations", parseText( xmlr, "ConOps" ))); + } else if (xmlr.getLocalName().equals("conOps")) { + socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("controlOperations", parseText( xmlr, "conOps" ))); } else if (xmlr.getLocalName().equals("weight")) { String thisValue = parseText( xmlr, "weight" ); if (!StringUtil.isEmpty(thisValue)) { @@ -972,6 +1062,8 @@ private void processDataColl(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) thro //socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("weighting", parseText( xmlr, "weight" ))); } else if (xmlr.getLocalName().equals("cleanOps")) { socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("cleaningOperations", parseText( xmlr, "cleanOps" ))); + } else if (xmlr.getLocalName().equals("collectorTraining")) { + socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("collectorTraining", parseText( xmlr, "collectorTraining" ))); } } else if (event == XMLStreamConstants.END_ELEMENT) { if (xmlr.getLocalName().equals("dataColl")) { @@ -987,6 +1079,7 @@ private void processDataColl(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) thro if (!StringUtil.isEmpty(dataCollector)) { socialScience.getFields().add(FieldDTO.createPrimitiveFieldDTO("dataCollector", dataCollector)); } + return; } } @@ -1082,7 +1175,16 @@ private void processDataAccs(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) thro String noteType = xmlr.getAttributeValue(null, "type"); if (NOTE_TYPE_TERMS_OF_USE.equalsIgnoreCase(noteType) ) { if ( LEVEL_DV.equalsIgnoreCase(xmlr.getAttributeValue(null, "level"))) { - dvDTO.setTermsOfUse(parseText(xmlr, "notes")); + String termOfUse = parseText(xmlr, "notes"); + if (termOfUse != null && termOfUse.trim().equals("CC0 Waiver") ) { + dvDTO.setLicense("CC0"); + } else if (termOfUse != null && !termOfUse.trim().equals("")){ + dvDTO.setTermsOfUse(termOfUse); + } + } + } else if (NOTE_TYPE_TERMS_OF_ACCESS.equalsIgnoreCase(noteType) ) { + if (LEVEL_DV.equalsIgnoreCase(xmlr.getAttributeValue(null, "level"))) { + dvDTO.setTermsOfAccess(parseText(xmlr, "notes")); } } else { processNotes(xmlr, dvDTO); @@ -1189,15 +1291,16 @@ private void processDistStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) { if (event == XMLStreamConstants.START_ELEMENT) { if (xmlr.getLocalName().equals("distrbtr")) { - HashSet set = new HashSet<>(); - addToSet(set, "distributorAbbreviation", xmlr.getAttributeValue(null, "abbr")); - addToSet(set, "distributorAffiliation", xmlr.getAttributeValue(null, "affiliation")); - - Map distDetails = parseCompoundText(xmlr, "distrbtr"); - addToSet(set, "distributorName", distDetails.get("name")); - addToSet(set, "distributorURL", distDetails.get("url")); - addToSet(set, "distributorLogoURL", distDetails.get("logo")); - distributors.add(set); + String source = xmlr.getAttributeValue(null, "source"); + if (source == null || !source.equals("archive")) { + HashSet set = new HashSet<>(); + addToSet(set, "distributorAbbreviation", xmlr.getAttributeValue(null, "abbr")); + addToSet(set, "distributorAffiliation", xmlr.getAttributeValue(null, "affiliation")); + addToSet(set, "distributorURL", xmlr.getAttributeValue(null, "URI")); + addToSet(set, "distributorLogoURL", xmlr.getAttributeValue(null, "role")); + addToSet(set, "distributorName", xmlr.getElementText()); + distributors.add(set); + } } else if (xmlr.getLocalName().equals("contact")) { HashSet set = new HashSet<>(); @@ -1240,11 +1343,9 @@ private void processProdStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th HashSet set = new HashSet<>(); addToSet(set,"producerAbbreviation", xmlr.getAttributeValue(null, "abbr")); addToSet(set,"producerAffiliation", xmlr.getAttributeValue(null, "affiliation")); - - Map prodDetails = parseCompoundText(xmlr, "producer"); - addToSet(set,"producerName", prodDetails.get("name")); - addToSet(set,"producerURL", prodDetails.get("url" )); - addToSet(set,"producerLogoURL", prodDetails.get("logo")); + addToSet(set,"producerLogoURL", xmlr.getAttributeValue(null, "role")); + addToSet(set,"producerURL", xmlr.getAttributeValue(null, "URI")); + addToSet(set,"producerName", xmlr.getElementText()); if (!set.isEmpty()) producers.add(set); } else if (xmlr.getLocalName().equals("prodDate")) { @@ -1254,7 +1355,7 @@ private void processProdStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) th } else if (xmlr.getLocalName().equals("software")) { HashSet set = new HashSet<>(); addToSet(set,"softwareVersion", xmlr.getAttributeValue(null, "version")); - addToSet(set,"softwareName", xmlr.getAttributeValue(null, "version")); + addToSet(set,"softwareName", parseText(xmlr)); if (!set.isEmpty()) { software.add(set); } @@ -1341,6 +1442,7 @@ private void processTitlStmt(XMLStreamReader xmlr, DatasetDTO datasetDTO) throws private void processRspStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) throws XMLStreamException { List> authors = new ArrayList<>(); + List> contributors = new ArrayList<>(); for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) { if (event == XMLStreamConstants.START_ELEMENT) { if (xmlr.getLocalName().equals("AuthEnty")) { @@ -1351,12 +1453,24 @@ private void processRspStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) thr authors.add(set); } } + if (xmlr.getLocalName().equals("othId")) { + HashSet set = new HashSet<>(); + set.add(FieldDTO.createVocabFieldDTO("contributorType", xmlr.getAttributeValue(null, "role") )); + addToSet(set,"contributorName", parseText(xmlr)); + if (!set.isEmpty()) { + contributors.add(set); + } + } } else if (event == XMLStreamConstants.END_ELEMENT) { if (xmlr.getLocalName().equals("rspStmt")) { if (authors.size()>0) { FieldDTO author = FieldDTO.createMultipleCompoundFieldDTO("author", authors); citation.getFields().add(author); } + if (contributors.size() > 0) { + FieldDTO contributor = FieldDTO.createMultipleCompoundFieldDTO("contributor", contributors); + citation.getFields().add(contributor); + } return; } diff --git a/src/main/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtil.java b/src/main/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtil.java index 1cb588f288f..a29d6ac7fbc 100644 --- a/src/main/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtil.java @@ -72,6 +72,12 @@ public class DdiExportUtil { private static final Logger logger = Logger.getLogger(DdiExportUtil.class.getCanonicalName()); + public static final String NOTE_TYPE_TERMS_OF_USE = "DVN:TOU"; + public static final String NOTE_TYPE_TERMS_OF_ACCESS = "DVN:TOA"; + public static final String NOTE_TYPE_DATA_ACCESS_PLACE = "DVN:DAP"; + + + public static final String LEVEL_DV = "dv"; @EJB VariableServiceBean variableService; @@ -174,7 +180,7 @@ private static void createStdyDscr(XMLStreamWriter xmlw, DatasetDTO datasetDto) xmlw.writeStartElement("citation"); xmlw.writeStartElement("titlStmt"); - writeFullElement(xmlw, "titl", dto2Primitive(version, DatasetFieldConstant.title)); + writeFullElement(xmlw, "titl", dto2Primitive(version, DatasetFieldConstant.title)); writeFullElement(xmlw, "subTitl", dto2Primitive(version, DatasetFieldConstant.subTitle)); writeFullElement(xmlw, "altTitl", dto2Primitive(version, DatasetFieldConstant.alternativeTitle)); @@ -182,17 +188,29 @@ private static void createStdyDscr(XMLStreamWriter xmlw, DatasetDTO datasetDto) writeAttribute(xmlw, "agency", persistentAgency); xmlw.writeCharacters(persistentProtocol + ":" + persistentAuthority + "/" + persistentId); xmlw.writeEndElement(); // IDNo - + writeOtherIdElement(xmlw, version); xmlw.writeEndElement(); // titlStmt writeAuthorsElement(xmlw, version); writeProducersElement(xmlw, version); xmlw.writeStartElement("distStmt"); - writeFullElement(xmlw, "distrbtr", datasetDto.getPublisher()); - writeFullElement(xmlw, "distDate", datasetDto.getPublicationDate()); + if (datasetDto.getPublisher() != null && !datasetDto.getPublisher().equals("")) { + xmlw.writeStartElement("distrbtr"); + writeAttribute(xmlw, "source", "archive"); + xmlw.writeCharacters(datasetDto.getPublisher()); + xmlw.writeEndElement(); //distrbtr + } + writeDistributorsElement(xmlw, version); + writeContactsElement(xmlw, version); + writeFullElement(xmlw, "distDate", dto2Primitive(version, DatasetFieldConstant.distributionDate)); + writeFullElement(xmlw, "depositr", dto2Primitive(version, DatasetFieldConstant.depositor)); + writeFullElement(xmlw, "depDate", dto2Primitive(version, DatasetFieldConstant.dateOfDeposit)); + xmlw.writeEndElement(); // diststmt + writeSeriesElement(xmlw, version); + xmlw.writeEndElement(); // citation //End Citation Block @@ -202,53 +220,65 @@ private static void createStdyDscr(XMLStreamWriter xmlw, DatasetDTO datasetDto) writeSubjectElement(xmlw, version); //Subject and Keywords writeAbstractElement(xmlw, version); // Description - writeFullElement(xmlw, "notes", dto2Primitive(version, DatasetFieldConstant.notesText)); - writeSummaryDescriptionElement(xmlw, version); - writeRelPublElement(xmlw, version); + writeFullElement(xmlw, "notes", dto2Primitive(version, DatasetFieldConstant.notesText)); + //////// + xmlw.writeEndElement(); // stdyInfo - writeOtherIdElement(xmlw, version); - writeDistributorsElement(xmlw, version); - writeContactsElement(xmlw, version); - writeFullElement(xmlw, "depositr", dto2Primitive(version, DatasetFieldConstant.depositor)); - writeFullElement(xmlw, "depDate", dto2Primitive(version, DatasetFieldConstant.dateOfDeposit)); + writeMethodElement(xmlw, version); + writeDataAccess(xmlw , version); + writeOtherStudyMaterial(xmlw , version); + + writeFullElement(xmlw, "notes", dto2Primitive(version, DatasetFieldConstant.datasetLevelErrorNotes)); + xmlw.writeEndElement(); // stdyDscr + + } + + private static void writeOtherStudyMaterial(XMLStreamWriter xmlw , DatasetVersionDTO version) throws XMLStreamException { + xmlw.writeStartElement("othrStdyMat"); writeFullElementList(xmlw, "relMat", dto2PrimitiveList(version, DatasetFieldConstant.relatedMaterial)); writeFullElementList(xmlw, "relStdy", dto2PrimitiveList(version, DatasetFieldConstant.relatedDatasets)); + writeRelPublElement(xmlw, version); writeFullElementList(xmlw, "othRefs", dto2PrimitiveList(version, DatasetFieldConstant.otherReferences)); - writeSeriesElement(xmlw, version); - writeSoftwareElement(xmlw, version); - writeFullElementList(xmlw, "dataSrc", dto2PrimitiveList(version, DatasetFieldConstant.dataSources)); - writeFullElement(xmlw, "srcOrig", dto2Primitive(version, DatasetFieldConstant.originOfSources)); - writeFullElement(xmlw, "srcChar", dto2Primitive(version, DatasetFieldConstant.characteristicOfSources)); - writeFullElement(xmlw, "srcDocu", dto2Primitive(version, DatasetFieldConstant.accessToSources)); - xmlw.writeEndElement(); // stdyInfo - // End Info Block - - //Social Science Metadata block - - writeMethodElement(xmlw, version); - - //Terms of Use and Access - writeFullElement(xmlw, "useStmt", version.getTermsOfUse()); - writeFullElement(xmlw, "confDec", version.getConfidentialityDeclaration()); - writeFullElement(xmlw, "specPerm", version.getSpecialPermissions()); - writeFullElement(xmlw, "restrctn", version.getRestrictions()); - writeFullElement(xmlw, "citeReq", version.getCitationRequirements()); - writeFullElement(xmlw, "deposReq", version.getDepositorRequirements()); - writeFullElement(xmlw, "dataAccs", version.getTermsOfAccess()); - writeFullElement(xmlw, "accsPlac", version.getDataAccessPlace()); - writeFullElement(xmlw, "conditions", version.getConditions()); - writeFullElement(xmlw, "disclaimer", version.getDisclaimer()); - writeFullElement(xmlw, "origArch", version.getOriginalArchive()); - writeFullElement(xmlw, "avlStatus", version.getAvailabilityStatus()); - writeFullElement(xmlw, "contact", version.getContactForAccess()); - writeFullElement(xmlw, "collSize", version.getSizeOfCollection()); - writeFullElement(xmlw, "complete", version.getStudyCompletion()); - - - xmlw.writeEndElement(); // stdyDscr + xmlw.writeEndElement(); //othrStdyMat + } + + private static void writeDataAccess(XMLStreamWriter xmlw , DatasetVersionDTO version) throws XMLStreamException { + xmlw.writeStartElement("dataAccs"); + if (version.getTermsOfUse() != null && !version.getTermsOfUse().trim().equals("")) { + xmlw.writeStartElement("notes"); + writeAttribute(xmlw, "type", NOTE_TYPE_TERMS_OF_USE); + writeAttribute(xmlw, "level", LEVEL_DV); + xmlw.writeCharacters(version.getTermsOfUse()); + xmlw.writeEndElement(); //notes + } + if (version.getTermsOfAccess() != null && !version.getTermsOfAccess().trim().equals("")) { + xmlw.writeStartElement("notes"); + writeAttribute(xmlw, "type", NOTE_TYPE_TERMS_OF_ACCESS); + writeAttribute(xmlw, "level", LEVEL_DV); + xmlw.writeCharacters(version.getTermsOfAccess()); + xmlw.writeEndElement(); //notes + } + xmlw.writeStartElement("setAvail"); + writeFullElement(xmlw, "accsPlac", version.getDataAccessPlace()); + writeFullElement(xmlw, "origArch", version.getOriginalArchive()); + writeFullElement(xmlw, "avlStatus", version.getAvailabilityStatus()); + writeFullElement(xmlw, "collSize", version.getSizeOfCollection()); + writeFullElement(xmlw, "complete", version.getStudyCompletion()); + xmlw.writeEndElement(); //setAvail + xmlw.writeStartElement("useStmt"); + writeFullElement(xmlw, "confDec", version.getConfidentialityDeclaration()); + writeFullElement(xmlw, "specPerm", version.getSpecialPermissions()); + writeFullElement(xmlw, "restrctn", version.getRestrictions()); + writeFullElement(xmlw, "contact", version.getContactForAccess()); + writeFullElement(xmlw, "citReq", version.getCitationRequirements()); + writeFullElement(xmlw, "deposReq", version.getDepositorRequirements()); + writeFullElement(xmlw, "conditions", version.getConditions()); + writeFullElement(xmlw, "disclaimer", version.getDisclaimer()); + xmlw.writeEndElement(); //useStmt + xmlw.writeEndElement(); //dataAccs } private static void writeDocDescElement (XMLStreamWriter xmlw, DatasetDTO datasetDto) throws XMLStreamException { @@ -275,10 +305,15 @@ private static void writeDocDescElement (XMLStreamWriter xmlw, DatasetDTO datase xmlw.writeStartElement("IDNo"); writeAttribute(xmlw, "agency", persistentAgency); xmlw.writeCharacters(persistentProtocol + ":" + persistentAuthority + "/" + persistentId); - xmlw.writeEndElement(); // IDNo + xmlw.writeEndElement(); // IDNo xmlw.writeEndElement(); // titlStmt xmlw.writeStartElement("distStmt"); - writeFullElement(xmlw, "distrbtr", datasetDto.getPublisher()); + if (datasetDto.getPublisher() != null && !datasetDto.getPublisher().equals("")) { + xmlw.writeStartElement("distrbtr"); + writeAttribute(xmlw, "source", "archive"); + xmlw.writeCharacters(datasetDto.getPublisher()); + xmlw.writeEndElement(); // distrbtr + } writeFullElement(xmlw, "distDate", datasetDto.getPublicationDate()); xmlw.writeEndElement(); // diststmt @@ -364,26 +399,44 @@ private static void writeSummaryDescriptionElement(XMLStreamWriter xmlw, Dataset if("geospatial".equals(key)){ for (FieldDTO fieldDTO : value.getFields()) { if (DatasetFieldConstant.geographicCoverage.equals(fieldDTO.getTypeName())) { + for (HashSet foo : fieldDTO.getMultipleCompound()) { + HashMap geoMap = new HashMap<>(); for (Iterator iterator = foo.iterator(); iterator.hasNext();) { FieldDTO next = iterator.next(); if (DatasetFieldConstant.country.equals(next.getTypeName())) { - writeFullElement(xmlw, "nation", next.getSinglePrimitive()); + geoMap.put("country", next.getSinglePrimitive()); } if (DatasetFieldConstant.city.equals(next.getTypeName())) { - writeFullElement(xmlw, "geogCover", next.getSinglePrimitive()); + geoMap.put("city", next.getSinglePrimitive()); } if (DatasetFieldConstant.state.equals(next.getTypeName())) { - writeFullElement(xmlw, "geogCover", next.getSinglePrimitive()); + geoMap.put("state", next.getSinglePrimitive()); } if (DatasetFieldConstant.otherGeographicCoverage.equals(next.getTypeName())) { - writeFullElement(xmlw, "geogCover", next.getSinglePrimitive()); + geoMap.put("otherGeographicCoverage", next.getSinglePrimitive()); } } + + if (geoMap.get("country") != null) { + writeFullElement(xmlw, "nation", geoMap.get("country")); + } + if (geoMap.get("city") != null) { + writeFullElement(xmlw, "geogCover", geoMap.get("city")); + } + if (geoMap.get("state") != null) { + writeFullElement(xmlw, "geogCover", geoMap.get("state")); + } + if (geoMap.get("otherGeographicCoverage") != null) { + writeFullElement(xmlw, "geogCover", geoMap.get("otherGeographicCoverage")); + } + } } if (DatasetFieldConstant.geographicBoundingBox.equals(fieldDTO.getTypeName())) { + for (HashSet foo : fieldDTO.getMultipleCompound()) { + xmlw.writeStartElement("geoBndBox"); for (Iterator iterator = foo.iterator(); iterator.hasNext();) { FieldDTO next = iterator.next(); if (DatasetFieldConstant.westLongitude.equals(next.getTypeName())) { @@ -400,7 +453,9 @@ private static void writeSummaryDescriptionElement(XMLStreamWriter xmlw, Dataset } } + xmlw.writeEndElement(); } + } } writeFullElementList(xmlw, "geogUnit", dto2PrimitiveList(datasetVersionDTO, DatasetFieldConstant.geographicUnit)); @@ -444,22 +499,32 @@ private static void writeMethodElement(XMLStreamWriter xmlw , DatasetVersionDTO writeFullElement(xmlw, "dataCollector", dto2Primitive(version, DatasetFieldConstant.dataCollector)); writeFullElement(xmlw, "collectorTraining", dto2Primitive(version, DatasetFieldConstant.collectorTraining)); writeFullElement(xmlw, "frequenc", dto2Primitive(version, DatasetFieldConstant.frequencyOfDataCollection)); - writeFullElement(xmlw, "sampProc", dto2Primitive(version, DatasetFieldConstant.samplingProcedure)); + writeFullElement(xmlw, "sampProc", dto2Primitive(version, DatasetFieldConstant.samplingProcedure)); + writeTargetSampleElement(xmlw, version); - writeFullElement(xmlw, "deviat", dto2Primitive(version, DatasetFieldConstant.deviationsFromSampleDesign)); + + writeFullElement(xmlw, "deviat", dto2Primitive(version, DatasetFieldConstant.deviationsFromSampleDesign)); + + xmlw.writeStartElement("sources"); + writeFullElementList(xmlw, "dataSrc", dto2PrimitiveList(version, DatasetFieldConstant.dataSources)); + writeFullElement(xmlw, "srcOrig", dto2Primitive(version, DatasetFieldConstant.originOfSources)); + writeFullElement(xmlw, "srcChar", dto2Primitive(version, DatasetFieldConstant.characteristicOfSources)); + writeFullElement(xmlw, "srcDocu", dto2Primitive(version, DatasetFieldConstant.accessToSources)); + xmlw.writeEndElement(); //sources + writeFullElement(xmlw, "collMode", dto2Primitive(version, DatasetFieldConstant.collectionMode)); writeFullElement(xmlw, "resInstru", dto2Primitive(version, DatasetFieldConstant.researchInstrument)); writeFullElement(xmlw, "collSitu", dto2Primitive(version, DatasetFieldConstant.dataCollectionSituation)); writeFullElement(xmlw, "actMin", dto2Primitive(version, DatasetFieldConstant.actionsToMinimizeLoss)); - writeFullElement(xmlw, "conOps", dto2Primitive(version, DatasetFieldConstant.controlOperations)); + writeFullElement(xmlw, "conOps", dto2Primitive(version, DatasetFieldConstant.controlOperations)); writeFullElement(xmlw, "weight", dto2Primitive(version, DatasetFieldConstant.weighting)); writeFullElement(xmlw, "cleanOps", dto2Primitive(version, DatasetFieldConstant.cleaningOperations)); xmlw.writeEndElement(); //dataColl xmlw.writeStartElement("anlyInfo"); - writeFullElement(xmlw, "anylInfo", dto2Primitive(version, DatasetFieldConstant.datasetLevelErrorNotes)); + //writeFullElement(xmlw, "anylInfo", dto2Primitive(version, DatasetFieldConstant.datasetLevelErrorNotes)); writeFullElement(xmlw, "respRate", dto2Primitive(version, DatasetFieldConstant.responseRate)); - writeFullElement(xmlw, "estSmpErr", dto2Primitive(version, DatasetFieldConstant.samplingErrorEstimates)); + writeFullElement(xmlw, "EstSmpErr", dto2Primitive(version, DatasetFieldConstant.samplingErrorEstimates)); writeFullElement(xmlw, "dataAppr", dto2Primitive(version, DatasetFieldConstant.otherDataAppraisal)); xmlw.writeEndElement(); //anlyInfo writeNotesElement(xmlw, version); @@ -508,7 +573,7 @@ private static void writeSubjectElement(XMLStreamWriter xmlw, DatasetVersionDTO writeAttribute(xmlw,"vocab",keywordVocab); } if(!keywordURI.isEmpty()){ - writeAttribute(xmlw,"URI",keywordURI); + writeAttribute(xmlw,"vocabURI",keywordURI); } xmlw.writeCharacters(keywordValue); xmlw.writeEndElement(); //Keyword @@ -539,7 +604,7 @@ private static void writeSubjectElement(XMLStreamWriter xmlw, DatasetVersionDTO writeAttribute(xmlw,"vocab",topicClassificationVocab); } if(!topicClassificationURI.isEmpty()){ - writeAttribute(xmlw,"URI",topicClassificationURI); + writeAttribute(xmlw,"vocabURI",topicClassificationURI); } xmlw.writeCharacters(topicClassificationValue); xmlw.writeEndElement(); //topcClas @@ -558,9 +623,9 @@ private static void writeAuthorsElement(XMLStreamWriter xmlw, DatasetVersionDTO String key = entry.getKey(); MetadataBlockDTO value = entry.getValue(); if ("citation".equals(key)) { + xmlw.writeStartElement("rspStmt"); for (FieldDTO fieldDTO : value.getFields()) { if (DatasetFieldConstant.author.equals(fieldDTO.getTypeName())) { - xmlw.writeStartElement("rspStmt"); String authorName = ""; String authorAffiliation = ""; for (HashSet foo : fieldDTO.getMultipleCompound()) { @@ -582,10 +647,34 @@ private static void writeAuthorsElement(XMLStreamWriter xmlw, DatasetVersionDTO xmlw.writeEndElement(); //AuthEnty } } - xmlw.writeEndElement(); //rspStmt + + } else if (DatasetFieldConstant.contributor.equals(fieldDTO.getTypeName())) { + String contributorName = ""; + String contributorType = ""; + for (HashSet foo : fieldDTO.getMultipleCompound()) { + for (Iterator iterator = foo.iterator(); iterator.hasNext();) { + FieldDTO next = iterator.next(); + if (DatasetFieldConstant.contributorName.equals(next.getTypeName())) { + contributorName = next.getSinglePrimitive(); + } + if (DatasetFieldConstant.contributorType.equals(next.getTypeName())) { + contributorType = next.getSinglePrimitive(); + } + } + if (!contributorName.isEmpty()){ + xmlw.writeStartElement("othId"); + if(!contributorType.isEmpty()){ + writeAttribute(xmlw,"role", contributorType); + } + xmlw.writeCharacters(contributorName); + xmlw.writeEndElement(); //othId + } + } } } + xmlw.writeEndElement(); //rspStmt } + } } @@ -692,6 +781,7 @@ private static void writeProducersElement(XMLStreamWriter xmlw, DatasetVersionDT } writeFullElement(xmlw, "prodDate", dto2Primitive(version, DatasetFieldConstant.productionDate)); writeFullElement(xmlw, "prodPlac", dto2Primitive(version, DatasetFieldConstant.productionPlace)); + writeSoftwareElement(xmlw, version); writeGrantElement(xmlw, version); xmlw.writeEndElement(); //prodStmt @@ -704,7 +794,7 @@ private static void writeDistributorsElement(XMLStreamWriter xmlw, DatasetVersio if ("citation".equals(key)) { for (FieldDTO fieldDTO : value.getFields()) { if (DatasetFieldConstant.distributor.equals(fieldDTO.getTypeName())) { - xmlw.writeStartElement("distrbtr"); + //xmlw.writeStartElement("distrbtr"); for (HashSet foo : fieldDTO.getMultipleCompound()) { String distributorName = ""; String distributorAffiliation = ""; @@ -747,8 +837,9 @@ private static void writeDistributorsElement(XMLStreamWriter xmlw, DatasetVersio xmlw.writeEndElement(); //AuthEnty } } - xmlw.writeEndElement(); //rspStmt + //xmlw.writeEndElement(); //rspStmt } + } } } @@ -782,12 +873,27 @@ private static void writeRelPublElement(XMLStreamWriter xmlw, DatasetVersionDTO url = next.getSinglePrimitive(); } } - pubString = appendCommaSeparatedValue(citation, IDType); - pubString = appendCommaSeparatedValue(pubString, IDNo); - pubString = appendCommaSeparatedValue(pubString, url); - if (!pubString.isEmpty()){ - xmlw.writeStartElement("relPubl"); - xmlw.writeCharacters(pubString); + if (citation != null && !citation.trim().equals("")) { + xmlw.writeStartElement("relPubl"); + xmlw.writeStartElement("citation"); + if (IDNo != null && !IDNo.trim().equals("")) { + xmlw.writeStartElement("titlStmt"); + xmlw.writeStartElement("IDNo"); + if (IDType != null && !IDType.trim().equals("")) { + xmlw.writeAttribute("agency", IDType ); + } + xmlw.writeCharacters(IDNo); + xmlw.writeEndElement(); //IDNo + xmlw.writeEndElement(); // titlStmt + } + + writeFullElement(xmlw,"biblCit",citation); + xmlw.writeEndElement(); //citation + if (url != null && !url.trim().equals("") ) { + xmlw.writeStartElement("ExtLink"); + xmlw.writeAttribute("URI", url); + xmlw.writeEndElement(); //ExtLink + } xmlw.writeEndElement(); //relPubl } } @@ -988,6 +1094,7 @@ private static void writeTargetSampleElement(XMLStreamWriter xmlw, DatasetVersio if ("socialscience".equals(key)) { for (FieldDTO fieldDTO : value.getFields()) { if (DatasetFieldConstant.targetSampleSize.equals(fieldDTO.getTypeName())) { + xmlw.writeStartElement("targetSampleSize"); String sizeFormula = ""; String actualSize = ""; Set foo = fieldDTO.getSingleCompound(); @@ -1000,6 +1107,7 @@ private static void writeTargetSampleElement(XMLStreamWriter xmlw, DatasetVersio actualSize = next.getSinglePrimitive(); } } + if (!sizeFormula.isEmpty()) { xmlw.writeStartElement("sampleSizeFormula"); xmlw.writeCharacters(sizeFormula); @@ -1010,6 +1118,7 @@ private static void writeTargetSampleElement(XMLStreamWriter xmlw, DatasetVersio xmlw.writeCharacters(actualSize); xmlw.writeEndElement(); //sampleSize } + xmlw.writeEndElement(); // targetSampleSize } } } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java index 51d3a214d5d..713fb770cb0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java @@ -446,9 +446,9 @@ public void testCreatePublishDestroyDataset() { */ boolean nameRequiredForContactToAppear = true; if (nameRequiredForContactToAppear) { - assertEquals("Finch, Fiona", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.stdyInfo.contact")); + assertEquals("Finch, Fiona", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.citation.distStmt.contact")); } else { - assertEquals("finch@mailinator.com", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.stdyInfo.contact.@email")); + assertEquals("finch@mailinator.com", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.citation.distStmt.contact.@email")); } assertEquals(datasetPersistentId, XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.docDscr.citation.titlStmt.IDNo")); @@ -659,10 +659,10 @@ public void testExcludeEmail() { exportDatasetAsDdi.then().assertThat() .statusCode(OK.getStatusCode()); - assertEquals("Dataverse, Admin", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.stdyInfo.contact")); + assertEquals("Dataverse, Admin", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.citation.distStmt.contact")); // no "sammi@sample.com" to be found https://github.com/IQSS/dataverse/issues/3443 - assertEquals("[]", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.stdyInfo.contact.@email")); - assertEquals("Sample Datasets, inc.", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.stdyInfo.contact.@affiliation")); + assertEquals("[]", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.citation.distStmt.contact.@email")); + assertEquals("Sample Datasets, inc.", XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.stdyDscr.citation.distStmt.contact.@affiliation")); assertEquals(datasetPersistentId, XmlPath.from(exportDatasetAsDdi.body().asString()).getString("codeBook.docDscr.citation.titlStmt.IDNo")); List datasetContactsFromNativeGet = with(getDatasetJsonAfterPublishing.body().asString()).param("datasetContact", "datasetContact") diff --git a/src/test/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtilTest.java index b3155e6d7ae..a76ce8475f2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/export/ddi/DdiExportUtilTest.java @@ -35,6 +35,18 @@ public void testJson2DdiNoFiles() throws Exception { assertEquals(datasetAsDdi, result); } + @Test + public void testExportDDI() throws Exception { + File datasetVersionJson = new File("src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-create-new-all-ddi-fields.json"); + String datasetVersionAsJson = new String(Files.readAllBytes(Paths.get(datasetVersionJson.getAbsolutePath()))); + File ddiFile = new File("src/test/java/edu/harvard/iq/dataverse/export/ddi/exportfull.xml"); + String datasetAsDdi = XmlPrinter.prettyPrintXml(new String(Files.readAllBytes(Paths.get(ddiFile.getAbsolutePath())))); + logger.info(datasetAsDdi); + String result = DdiExportUtil.datasetDtoAsJson2ddi(datasetVersionAsJson); + logger.info(result); + assertEquals(datasetAsDdi, result); + } + @Test public void testJson2ddiHasFiles() throws Exception { /** diff --git a/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-create-new-all-ddi-fields.json b/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-create-new-all-ddi-fields.json new file mode 100644 index 00000000000..8930938d1af --- /dev/null +++ b/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-create-new-all-ddi-fields.json @@ -0,0 +1,1067 @@ +{ + "id": 11, + "identifier": "WKUKGV", + "persistentUrl": "https://doi.org/10.5072/FK2/WKUKGV", + "protocol": "doi", + "authority": "10.5072/FK2", + "publisher": "Root", + "publicationDate": "2020-02-19", + "datasetVersion": { + "id": 2, + "versionNumber": 1, + "versionMinorNumber": 0, + "versionState": "RELEASED", + "productionDate": "Production Date", + "lastUpdateTime": "2015-09-24T17:07:57Z", + "releaseTime": "2020-02-19", + "createTime": "2015-09-24T16:47:51Z", + "license": "CC0", + "termsOfUse": "CC0 Waiver", + "termsOfAccess": "Terms of Access", + "dataAccessPlace": "Data Access Place", + "originalArchive": "Original Archive", + "availabilityStatus": "Availability Status", + "sizeOfCollection": "Size of Collection", + "studyCompletion": "Study Completion", + "confidentialityDeclaration": "Confidentiality Declaration", + "specialPermissions": "Special Permissions", + "restrictions": "Restrictions", + "contactForAccess": "Contact for Access", + "citationRequirements": "Citation Requirements", + "depositorRequirements": "Depositor Requirements", + "conditions": "Conditions ", + "disclaimer": "Disclaimer", + "metadataBlocks": { + "citation": { + "displayName": "Citation Metadata", + "fields": [ + { + "typeName": "title", + "multiple": false, + "typeClass": "primitive", + "value": "Replication Data for: Title" + }, + { + "typeName": "subtitle", + "multiple": false, + "typeClass": "primitive", + "value": "Subtitle" + }, + { + "typeName": "alternativeTitle", + "multiple": false, + "typeClass": "primitive", + "value": "Alternative Title" + }, + { + "typeName": "otherId", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "otherIdAgency": { + "typeName": "otherIdAgency", + "multiple": false, + "typeClass": "primitive", + "value": "OtherIDAgency1" + }, + "otherIdValue": { + "typeName": "otherIdValue", + "multiple": false, + "typeClass": "primitive", + "value": "OtherIDIdentifier1" + } + }, + { + "otherIdAgency": { + "typeName": "otherIdAgency", + "multiple": false, + "typeClass": "primitive", + "value": "OtherIDAgency2" + }, + "otherIdValue": { + "typeName": "otherIdValue", + "multiple": false, + "typeClass": "primitive", + "value": "OtherIDIdentifier2" + } + } + ] + }, + { + "typeName": "author", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "authorName": { + "typeName": "authorName", + "multiple": false, + "typeClass": "primitive", + "value": "LastAuthor1, FirstAuthor1" + }, + "authorAffiliation": { + "typeName": "authorAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "AuthorAffiliation1" + } + }, + { + "authorName": { + "typeName": "authorName", + "multiple": false, + "typeClass": "primitive", + "value": "LastAuthor2, FirstAuthor2" + }, + "authorAffiliation": { + "typeName": "authorAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "AuthorAffiliation2" + } + } + ] + }, + { + "typeName": "datasetContact", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "datasetContactName": { + "typeName": "datasetContactName", + "multiple": false, + "typeClass": "primitive", + "value": "LastContact1, FirstContact1" + }, + "datasetContactAffiliation": { + "typeName": "datasetContactAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "ContactAffiliation1" + }, + "datasetContactEmail": { + "typeName": "datasetContactEmail", + "multiple": false, + "typeClass": "primitive", + "value": "ContactEmail1@mailinator.com" + } + }, + { + "datasetContactName": { + "typeName": "datasetContactName", + "multiple": false, + "typeClass": "primitive", + "value": "LastContact2, FirstContact2" + }, + "datasetContactAffiliation": { + "typeName": "datasetContactAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "ContactAffiliation2" + }, + "datasetContactEmail": { + "typeName": "datasetContactEmail", + "multiple": false, + "typeClass": "primitive", + "value": "ContactEmail2@mailinator.com" + } + } + ] + }, + { + "typeName": "dsDescription", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "dsDescriptionValue": { + "typeName": "dsDescriptionValue", + "multiple": false, + "typeClass": "primitive", + "value": "DescriptionText 1" + }, + "dsDescriptionDate": { + "typeName": "dsDescriptionDate", + "multiple": false, + "typeClass": "primitive", + "value": "1000-01-01" + } + }, + { + "dsDescriptionValue": { + "typeName": "dsDescriptionValue", + "multiple": false, + "typeClass": "primitive", + "value": "DescriptionText2" + }, + "dsDescriptionDate": { + "typeName": "dsDescriptionDate", + "multiple": false, + "typeClass": "primitive", + "value": "1000-02-02" + } + } + ] + }, + { + "typeName": "subject", + "multiple": true, + "typeClass": "controlledVocabulary", + "value": [ + "Agricultural Sciences", + "Business and Management", + "Engineering", + "Law" + ] + }, + { + "typeName": "keyword", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "keywordValue": { + "typeName": "keywordValue", + "multiple": false, + "typeClass": "primitive", + "value": "KeywordTerm1" + }, + "keywordVocabulary": { + "typeName": "keywordVocabulary", + "multiple": false, + "typeClass": "primitive", + "value": "KeywordVocabulary1" + }, + "keywordVocabularyURI": { + "typeName": "keywordVocabularyURI", + "multiple": false, + "typeClass": "primitive", + "value": "http://KeywordVocabularyURL1.org" + } + }, + { + "keywordValue": { + "typeName": "keywordValue", + "multiple": false, + "typeClass": "primitive", + "value": "KeywordTerm2" + }, + "keywordVocabulary": { + "typeName": "keywordVocabulary", + "multiple": false, + "typeClass": "primitive", + "value": "KeywordVocabulary2" + }, + "keywordVocabularyURI": { + "typeName": "keywordVocabularyURI", + "multiple": false, + "typeClass": "primitive", + "value": "http://KeywordVocabularyURL2.org" + } + } + ] + }, + { + "typeName": "publication", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "publicationCitation": { + "typeName": "publicationCitation", + "multiple": false, + "typeClass": "primitive", + "value": "RelatedPublicationCitation1" + }, + "publicationIDType": { + "typeName": "publicationIDType", + "multiple": false, + "typeClass": "controlledVocabulary", + "value": "ark" + }, + "publicationIDNumber": { + "typeName": "publicationIDNumber", + "multiple": false, + "typeClass": "primitive", + "value": "RelatedPublicationIDNumber1" + }, + "publicationURL": { + "typeName": "publicationURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://RelatedPublicationURL1.org" + } + }, + { + "publicationCitation": { + "typeName": "publicationCitation", + "multiple": false, + "typeClass": "primitive", + "value": "RelatedPublicationCitation2" + }, + "publicationIDType": { + "typeName": "publicationIDType", + "multiple": false, + "typeClass": "controlledVocabulary", + "value": "arXiv" + }, + "publicationIDNumber": { + "typeName": "publicationIDNumber", + "multiple": false, + "typeClass": "primitive", + "value": "RelatedPublicationIDNumber2" + }, + "publicationURL": { + "typeName": "publicationURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://RelatedPublicationURL2.org" + } + } + ] + }, + { + "typeName": "notesText", + "multiple": false, + "typeClass": "primitive", + "value": "Notes1" + }, + { + "typeName": "producer", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "producerName": { + "typeName": "producerName", + "multiple": false, + "typeClass": "primitive", + "value": "LastProducer1, FirstProducer1" + }, + "producerAffiliation": { + "typeName": "producerAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "ProducerAffiliation1" + }, + "producerAbbreviation": { + "typeName": "producerAbbreviation", + "multiple": false, + "typeClass": "primitive", + "value": "ProducerAbbreviation1" + }, + "producerURL": { + "typeName": "producerURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://ProducerURL1.org" + }, + "producerLogoURL": { + "typeName": "producerLogoURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://ProducerLogoURL1.org" + } + }, + { + "producerName": { + "typeName": "producerName", + "multiple": false, + "typeClass": "primitive", + "value": "LastProducer2, FirstProducer2" + }, + "producerAffiliation": { + "typeName": "producerAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "ProducerAffiliation2" + }, + "producerAbbreviation": { + "typeName": "producerAbbreviation", + "multiple": false, + "typeClass": "primitive", + "value": "ProducerAbbreviation2" + }, + "producerURL": { + "typeName": "producerURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://ProducerURL2.org" + }, + "producerLogoURL": { + "typeName": "producerLogoURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://ProducerLogoURL2.org" + } + } + ] + }, + { + "typeName": "productionDate", + "multiple": false, + "typeClass": "primitive", + "value": "1003-01-01" + }, + { + "typeName": "productionPlace", + "multiple": false, + "typeClass": "primitive", + "value": "ProductionPlace" + }, + { + "typeName": "contributor", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "contributorType": { + "typeName": "contributorType", + "multiple": false, + "typeClass": "controlledVocabulary", + "value": "Data Collector" + }, + "contributorName": { + "typeName": "contributorName", + "multiple": false, + "typeClass": "primitive", + "value": "LastContributor1, FirstContributor1" + } + }, + { + "contributorType": { + "typeName": "contributorType", + "multiple": false, + "typeClass": "controlledVocabulary", + "value": "Data Curator" + }, + "contributorName": { + "typeName": "contributorName", + "multiple": false, + "typeClass": "primitive", + "value": "LastContributor2, FirstContributor2" + } + } + ] + }, + { + "typeName": "grantNumber", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "grantNumberAgency": { + "typeName": "grantNumberAgency", + "multiple": false, + "typeClass": "primitive", + "value": "GrantInformationGrantAgency1" + }, + "grantNumberValue": { + "typeName": "grantNumberValue", + "multiple": false, + "typeClass": "primitive", + "value": "GrantInformationGrantNumber1" + } + }, + { + "grantNumberAgency": { + "typeName": "grantNumberAgency", + "multiple": false, + "typeClass": "primitive", + "value": "GrantInformationGrantAgency2" + }, + "grantNumberValue": { + "typeName": "grantNumberValue", + "multiple": false, + "typeClass": "primitive", + "value": "GrantInformationGrantNumber2" + } + } + ] + }, + { + "typeName": "distributor", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "distributorName": { + "typeName": "distributorName", + "multiple": false, + "typeClass": "primitive", + "value": "LastDistributor1, FirstDistributor1" + }, + "distributorAffiliation": { + "typeName": "distributorAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "DistributorAffiliation1" + }, + "distributorAbbreviation": { + "typeName": "distributorAbbreviation", + "multiple": false, + "typeClass": "primitive", + "value": "DistributorAbbreviation1" + }, + "distributorURL": { + "typeName": "distributorURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://DistributorURL1.org" + }, + "distributorLogoURL": { + "typeName": "distributorLogoURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://DistributorLogoURL1.org" + } + }, + { + "distributorName": { + "typeName": "distributorName", + "multiple": false, + "typeClass": "primitive", + "value": "LastDistributor2, FirstDistributor2" + }, + "distributorAffiliation": { + "typeName": "distributorAffiliation", + "multiple": false, + "typeClass": "primitive", + "value": "DistributorAffiliation2" + }, + "distributorAbbreviation": { + "typeName": "distributorAbbreviation", + "multiple": false, + "typeClass": "primitive", + "value": "DistributorAbbreviation2" + }, + "distributorURL": { + "typeName": "distributorURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://DistributorURL2.org" + }, + "distributorLogoURL": { + "typeName": "distributorLogoURL", + "multiple": false, + "typeClass": "primitive", + "value": "http://DistributorLogoURL2.org" + } + } + ] + }, + { + "typeName": "distributionDate", + "multiple": false, + "typeClass": "primitive", + "value": "1004-01-01" + }, + { + "typeName": "depositor", + "multiple": false, + "typeClass": "primitive", + "value": "LastDepositor, FirstDepositor" + }, + { + "typeName": "dateOfDeposit", + "multiple": false, + "typeClass": "primitive", + "value": "1002-01-01" + }, + { + "typeName": "timePeriodCovered", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "timePeriodCoveredStart": { + "typeName": "timePeriodCoveredStart", + "multiple": false, + "typeClass": "primitive", + "value": "1005-01-01" + }, + "timePeriodCoveredEnd": { + "typeName": "timePeriodCoveredEnd", + "multiple": false, + "typeClass": "primitive", + "value": "1005-01-02" + } + }, + { + "timePeriodCoveredStart": { + "typeName": "timePeriodCoveredStart", + "multiple": false, + "typeClass": "primitive", + "value": "1005-02-01" + }, + "timePeriodCoveredEnd": { + "typeName": "timePeriodCoveredEnd", + "multiple": false, + "typeClass": "primitive", + "value": "1005-02-02" + } + } + ] + }, + { + "typeName": "dateOfCollection", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "dateOfCollectionStart": { + "typeName": "dateOfCollectionStart", + "multiple": false, + "typeClass": "primitive", + "value": "1006-01-01" + }, + "dateOfCollectionEnd": { + "typeName": "dateOfCollectionEnd", + "multiple": false, + "typeClass": "primitive", + "value": "1006-01-01" + } + }, + { + "dateOfCollectionStart": { + "typeName": "dateOfCollectionStart", + "multiple": false, + "typeClass": "primitive", + "value": "1006-02-01" + }, + "dateOfCollectionEnd": { + "typeName": "dateOfCollectionEnd", + "multiple": false, + "typeClass": "primitive", + "value": "1006-02-02" + } + } + ] + }, + { + "typeName": "kindOfData", + "multiple": true, + "typeClass": "primitive", + "value": [ + "KindOfData1", + "KindOfData2" + ] + }, + { + "typeName": "series", + "multiple": false, + "typeClass": "compound", + "value": { + "seriesName": { + "typeName": "seriesName", + "multiple": false, + "typeClass": "primitive", + "value": "SeriesName" + }, + "seriesInformation": { + "typeName": "seriesInformation", + "multiple": false, + "typeClass": "primitive", + "value": "SeriesInformation" + } + } + }, + { + "typeName": "software", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "softwareName": { + "typeName": "softwareName", + "multiple": false, + "typeClass": "primitive", + "value": "SoftwareName1" + }, + "softwareVersion": { + "typeName": "softwareVersion", + "multiple": false, + "typeClass": "primitive", + "value": "SoftwareVersion1" + } + }, + { + "softwareName": { + "typeName": "softwareName", + "multiple": false, + "typeClass": "primitive", + "value": "SoftwareName2" + }, + "softwareVersion": { + "typeName": "softwareVersion", + "multiple": false, + "typeClass": "primitive", + "value": "SoftwareVersion2" + } + } + ] + }, + { + "typeName": "relatedMaterial", + "multiple": true, + "typeClass": "primitive", + "value": [ + "RelatedMaterial1", + "RelatedMaterial2" + ] + }, + { + "typeName": "relatedDatasets", + "multiple": true, + "typeClass": "primitive", + "value": [ + "RelatedDatasets1", + "RelatedDatasets2" + ] + }, + { + "typeName": "otherReferences", + "multiple": true, + "typeClass": "primitive", + "value": [ + "OtherReferences1", + "OtherReferences2" + ] + }, + { + "typeName": "dataSources", + "multiple": true, + "typeClass": "primitive", + "value": [ + "DataSources1", + "DataSources2" + ] + }, + { + "typeName": "originOfSources", + "multiple": false, + "typeClass": "primitive", + "value": "OriginOfSources" + }, + { + "typeName": "characteristicOfSources", + "multiple": false, + "typeClass": "primitive", + "value": "CharacteristicOfSourcesNoted" + }, + { + "typeName": "accessToSources", + "multiple": false, + "typeClass": "primitive", + "value": "DocumentationAndAccessToSources" + } + ] + }, + "geospatial": { + "displayName": "Geospatial Metadata", + "fields": [ + { + "typeName": "geographicCoverage", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "country": { + "typeName": "country", + "multiple": false, + "typeClass": "controlledVocabulary", + "value": "Afghanistan" + }, + "state": { + "typeName": "state", + "multiple": false, + "typeClass": "primitive", + "value": "GeographicCoverageStateProvince1" + }, + "city": { + "typeName": "city", + "multiple": false, + "typeClass": "primitive", + "value": "GeographicCoverageCity1" + }, + "otherGeographicCoverage": { + "typeName": "otherGeographicCoverage", + "multiple": false, + "typeClass": "primitive", + "value": "GeographicCoverageOther1" + } + }, + { + "country": { + "typeName": "country", + "multiple": false, + "typeClass": "controlledVocabulary", + "value": "Albania" + }, + "state": { + "typeName": "state", + "multiple": false, + "typeClass": "primitive", + "value": "GeographicCoverageStateProvince2" + }, + "city": { + "typeName": "city", + "multiple": false, + "typeClass": "primitive", + "value": "GeographicCoverageCity2" + }, + "otherGeographicCoverage": { + "typeName": "otherGeographicCoverage", + "multiple": false, + "typeClass": "primitive", + "value": "GeographicCoverageOther2" + } + } + ] + }, + { + "typeName": "geographicUnit", + "multiple": true, + "typeClass": "primitive", + "value": [ + "GeographicUnit1", + "GeographicUnit2" + ] + }, + { + "typeName": "geographicBoundingBox", + "multiple": true, + "typeClass": "compound", + "value": [ + { + "westLongitude": { + "typeName": "westLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "10" + }, + "eastLongitude": { + "typeName": "eastLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "20" + }, + "northLongitude": { + "typeName": "northLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "30" + }, + "southLongitude": { + "typeName": "southLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "40" + } + }, + { + "westLongitude": { + "typeName": "westLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "50" + }, + "eastLongitude": { + "typeName": "eastLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "60" + }, + "northLongitude": { + "typeName": "northLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "70" + }, + "southLongitude": { + "typeName": "southLongitude", + "multiple": false, + "typeClass": "primitive", + "value": "80" + } + } + ] + } + ] + }, + "socialscience": { + "displayName": "Social Science and Humanities Metadata", + "fields": [ + { + "typeName": "unitOfAnalysis", + "multiple": true, + "typeClass": "primitive", + "value": [ + "UnitOfAnalysis1", + "UnitOfAnalysis2" + ] + }, + { + "typeName": "universe", + "multiple": true, + "typeClass": "primitive", + "value": [ + "Universe1", + "Universe2" + ] + }, + { + "typeName": "timeMethod", + "multiple": false, + "typeClass": "primitive", + "value": "TimeMethod" + }, + { + "typeName": "dataCollector", + "multiple": false, + "typeClass": "primitive", + "value": "LastDataCollector1, FirstDataCollector1" + }, + { + "typeName": "collectorTraining", + "multiple": false, + "typeClass": "primitive", + "value": "CollectorTraining" + }, + { + "typeName": "frequencyOfDataCollection", + "multiple": false, + "typeClass": "primitive", + "value": "Frequency" + }, + { + "typeName": "samplingProcedure", + "multiple": false, + "typeClass": "primitive", + "value": "SamplingProcedure" + }, + { + "typeName": "targetSampleSize", + "multiple": false, + "typeClass": "compound", + "value": { + "targetSampleActualSize": { + "typeName": "targetSampleActualSize", + "multiple": false, + "typeClass": "primitive", + "value": "100" + }, + "targetSampleSizeFormula": { + "typeName": "targetSampleSizeFormula", + "multiple": false, + "typeClass": "primitive", + "value": "TargetSampleSizeFormula" + } + } + }, + { + "typeName": "deviationsFromSampleDesign", + "multiple": false, + "typeClass": "primitive", + "value": "MajorDeviationsForSampleDesign" + }, + { + "typeName": "collectionMode", + "multiple": false, + "typeClass": "primitive", + "value": "CollectionMode" + }, + { + "typeName": "researchInstrument", + "multiple": false, + "typeClass": "primitive", + "value": "TypeOfResearchInstrument" + }, + { + "typeName": "dataCollectionSituation", + "multiple": false, + "typeClass": "primitive", + "value": "CharacteristicsOfDataCollectionSituation" + }, + { + "typeName": "actionsToMinimizeLoss", + "multiple": false, + "typeClass": "primitive", + "value": "ActionsToMinimizeLosses" + }, + { + "typeName": "controlOperations", + "multiple": false, + "typeClass": "primitive", + "value": "ControlOperations" + }, + { + "typeName": "weighting", + "multiple": false, + "typeClass": "primitive", + "value": "Weighting" + }, + { + "typeName": "cleaningOperations", + "multiple": false, + "typeClass": "primitive", + "value": "CleaningOperations" + }, + { + "typeName": "datasetLevelErrorNotes", + "multiple": false, + "typeClass": "primitive", + "value": "StudyLevelErrorNotes" + }, + { + "typeName": "responseRate", + "multiple": false, + "typeClass": "primitive", + "value": "ResponseRate" + }, + { + "typeName": "samplingErrorEstimates", + "multiple": false, + "typeClass": "primitive", + "value": "EstimatesOfSamplingError" + }, + { + "typeName": "otherDataAppraisal", + "multiple": false, + "typeClass": "primitive", + "value": "OtherFormsOfDataAppraisal" + }, + { + "typeName": "socialScienceNotes", + "multiple": false, + "typeClass": "compound", + "value": { + "socialScienceNotesType": { + "typeName": "socialScienceNotesType", + "multiple": false, + "typeClass": "primitive", + "value": "NotesType" + }, + "socialScienceNotesSubject": { + "typeName": "socialScienceNotesSubject", + "multiple": false, + "typeClass": "primitive", + "value": "NotesSubject" + }, + "socialScienceNotesText": { + "typeName": "socialScienceNotesText", + "multiple": false, + "typeClass": "primitive", + "value": "NotesText" + } + } + } + ] + } + }, + "files": [], + "citation": "LastAuthor1, FirstAuthor1; LastAuthor2, FirstAuthor2, 2020, \"Replication Data for: Title\", https://doi.org/10.5072/FK2/WKUKGV, Root, V1" + } +} diff --git a/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-finch1.xml b/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-finch1.xml index cc7ecca7f9d..79e9e363994 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-finch1.xml +++ b/src/test/java/edu/harvard/iq/dataverse/export/ddi/dataset-finch1.xml @@ -25,14 +25,18 @@ Johnny Hawk - + + Odin Raven + Jimmy Finch + Added, Depositor + Medicine, Health and Life Sciences - Keyword Value 1 - Keyword Value Two - TC Value 1 + Keyword Value 1 + Keyword Value Two + TC Value 1 Darwin's finches (also known as the Galápagos finches) are a group of about fifteen species of passerine birds. @@ -41,24 +45,28 @@ 20070831 20130630 Kind of Data - Cambridge USA + Cambridge MA Other Geographic Coverage - 41.6 - 60.3 - 59.8 - 43.8 + + 41.6 + 60.3 + 59.8 + 43.8 + - - Odin Raven - - Jimmy Finch - Added, Depositor - + + + + + + + + diff --git a/src/test/java/edu/harvard/iq/dataverse/export/ddi/exportfull.xml b/src/test/java/edu/harvard/iq/dataverse/export/ddi/exportfull.xml new file mode 100644 index 00000000000..d9be1217fc9 --- /dev/null +++ b/src/test/java/edu/harvard/iq/dataverse/export/ddi/exportfull.xml @@ -0,0 +1,194 @@ + + + + + + Replication Data for: Title + doi:10.5072/FK2/WKUKGV + + + Root + 2020-02-19 + + + 1 + + LastAuthor1, FirstAuthor1; LastAuthor2, FirstAuthor2, 2020, "Replication Data for: Title", https://doi.org/10.5072/FK2/WKUKGV, Root, V1 + + + + + + Replication Data for: Title + Subtitle + Alternative Title + doi:10.5072/FK2/WKUKGV + OtherIDIdentifier1 + OtherIDIdentifier2 + + + LastAuthor1, FirstAuthor1 + LastAuthor2, FirstAuthor2 + LastContributor1, FirstContributor1 + LastContributor2, FirstContributor2 + + + LastProducer1, FirstProducer1 + LastProducer2, FirstProducer2 + 1003-01-01 + ProductionPlace + SoftwareName1 + SoftwareName2 + GrantInformationGrantNumber1 + GrantInformationGrantNumber2 + + + Root + LastDistributor1, FirstDistributor1 + LastDistributor2, FirstDistributor2 + LastContact1, FirstContact1 + LastContact2, FirstContact2 + 1004-01-01 + LastDepositor, FirstDepositor + 1002-01-01 + + + SeriesName + SeriesInformation + + + + + Agricultural Sciences + Business and Management + Engineering + Law + KeywordTerm1 + KeywordTerm2 + + DescriptionText 1 + DescriptionText2 + + 1005-01-01 + 1005-01-02 + 1005-02-01 + 1005-02-02 + 1006-01-01 + 1006-01-01 + 1006-02-01 + 1006-02-02 + KindOfData1 + KindOfData2 + Afghanistan + GeographicCoverageCity1 + GeographicCoverageStateProvince1 + GeographicCoverageOther1 + Albania + GeographicCoverageCity2 + GeographicCoverageStateProvince2 + GeographicCoverageOther2 + + 10 + 20 + 30 + 40 + + + 80 + 70 + 60 + 50 + + GeographicUnit1 + GeographicUnit2 + UnitOfAnalysis1 + UnitOfAnalysis2 + Universe1 + Universe2 + + Notes1 + + + + TimeMethod + LastDataCollector1, FirstDataCollector1 + CollectorTraining + Frequency + SamplingProcedure + + TargetSampleSizeFormula + 100 + + MajorDeviationsForSampleDesign + + DataSources1 + DataSources2 + OriginOfSources + CharacteristicOfSourcesNoted + DocumentationAndAccessToSources + + CollectionMode + TypeOfResearchInstrument + CharacteristicsOfDataCollectionSituation + ActionsToMinimizeLosses + ControlOperations + Weighting + CleaningOperations + + + ResponseRate + EstimatesOfSamplingError + OtherFormsOfDataAppraisal + + NotesText + + + CC0 Waiver + Terms of Access + + Data Access Place + Original Archive + Availability Status + Size of Collection + Study Completion + + + Confidentiality Declaration + Special Permissions + Restrictions + Contact for Access + Citation Requirements + Depositor Requirements + Conditions + Disclaimer + + + + RelatedMaterial1 + RelatedMaterial2 + RelatedDatasets1 + RelatedDatasets2 + + + + RelatedPublicationIDNumber1 + + RelatedPublicationCitation1 + + + + + + + RelatedPublicationIDNumber2 + + RelatedPublicationCitation2 + + + + OtherReferences1 + OtherReferences2 + + StudyLevelErrorNotes + +