use of edu.harvard.iq.dataverse.api.dto.FieldDTO in project dataverse by IQSS.
the class ImportDDIServiceBean method addNote.
private void addNote(String noteText, DatasetVersionDTO dvDTO) {
MetadataBlockDTO citation = getCitation(dvDTO);
FieldDTO field = citation.getField("notesText");
if (field == null) {
field = FieldDTO.createPrimitiveFieldDTO("notesText", "");
citation.getFields().add(field);
}
String noteValue = field.getSinglePrimitive();
noteValue += noteText;
field.setSinglePrimitive(noteValue);
}
use of edu.harvard.iq.dataverse.api.dto.FieldDTO in project dataverse by IQSS.
the class ImportDDIServiceBean method processSumDscr.
private void processSumDscr(XMLStreamReader xmlr, DatasetVersionDTO dvDTO) throws XMLStreamException {
List<String> geoUnit = new ArrayList<>();
List<String> unitOfAnalysis = new ArrayList<>();
List<String> universe = new ArrayList<>();
List<String> kindOfData = new ArrayList<>();
List<HashSet<FieldDTO>> geoBoundBox = new ArrayList<>();
List<HashSet<FieldDTO>> geoCoverages = new ArrayList<>();
FieldDTO timePeriodStart = null;
FieldDTO timePeriodEnd = null;
FieldDTO dateOfCollectionStart = null;
FieldDTO dateOfCollectionEnd = null;
for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) {
if (event == XMLStreamConstants.START_ELEMENT) {
if (xmlr.getLocalName().equals("timePrd")) {
String eventAttr = xmlr.getAttributeValue(null, "event");
if (eventAttr == null || EVENT_SINGLE.equalsIgnoreCase(eventAttr) || EVENT_START.equalsIgnoreCase(eventAttr)) {
timePeriodStart = FieldDTO.createPrimitiveFieldDTO("timePeriodCoveredStart", parseDate(xmlr, "timePrd"));
} else if (EVENT_END.equals(eventAttr)) {
timePeriodEnd = FieldDTO.createPrimitiveFieldDTO("timePeriodCoveredEnd", parseDate(xmlr, "timePrd"));
}
} else if (xmlr.getLocalName().equals("collDate")) {
String eventAttr = xmlr.getAttributeValue(null, "event");
if (eventAttr == null || EVENT_SINGLE.equalsIgnoreCase(eventAttr) || EVENT_START.equalsIgnoreCase(eventAttr)) {
dateOfCollectionStart = FieldDTO.createPrimitiveFieldDTO("dateOfCollectionStart", parseDate(xmlr, "collDate"));
} else if (EVENT_END.equals(eventAttr)) {
dateOfCollectionEnd = FieldDTO.createPrimitiveFieldDTO("dateOfCollectionEnd", parseDate(xmlr, "collDate"));
}
} else if (xmlr.getLocalName().equals("nation")) {
HashSet<FieldDTO> set = new HashSet<>();
set.add(FieldDTO.createVocabFieldDTO("country", parseText(xmlr)));
geoCoverages.add(set);
} else if (xmlr.getLocalName().equals("geogCover")) {
HashSet<FieldDTO> set = new HashSet<>();
set.add(FieldDTO.createPrimitiveFieldDTO("otherGeographicCoverage", parseText(xmlr)));
geoCoverages.add(set);
} else if (xmlr.getLocalName().equals("geogUnit")) {
geoUnit.add(parseText(xmlr));
} else if (xmlr.getLocalName().equals("geoBndBox")) {
geoBoundBox.add(processGeoBndBox(xmlr));
} else if (xmlr.getLocalName().equals("anlyUnit")) {
unitOfAnalysis.add(parseText(xmlr, "anlyUnit"));
} else if (xmlr.getLocalName().equals("universe")) {
universe.add(parseText(xmlr, "universe"));
} else if (xmlr.getLocalName().equals("dataKind")) {
kindOfData.add(parseText(xmlr));
}
} else if (event == XMLStreamConstants.END_ELEMENT) {
if (xmlr.getLocalName().equals("sumDscr")) {
if (timePeriodStart != null || timePeriodEnd != null) {
getCitation(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("timePeriodCovered", timePeriodStart, timePeriodEnd));
}
if (dateOfCollectionStart != null || dateOfCollectionEnd != null) {
getCitation(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("dateOfCollection", dateOfCollectionStart, dateOfCollectionEnd));
}
if (geoUnit.size() > 0) {
getGeospatial(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO("geographicUnit", geoUnit));
}
if (unitOfAnalysis.size() > 0) {
getSocialScience(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO("unitOfAnalysis", unitOfAnalysis));
}
if (universe.size() > 0) {
getSocialScience(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO("universe", universe));
}
if (kindOfData.size() > 0) {
getCitation(dvDTO).addField(FieldDTO.createMultiplePrimitiveFieldDTO("kindOfData", kindOfData));
}
if (geoCoverages.size() > 0) {
getGeospatial(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("geographicCoverage", geoCoverages));
}
if (geoBoundBox.size() > 0) {
getGeospatial(dvDTO).addField(FieldDTO.createMultipleCompoundFieldDTO("geographicBoundingBox", geoBoundBox));
}
return;
}
}
}
}
Aggregations