Search in sources :

Example 11 with MetadataBlockDTO

use of edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO in project dataverse by IQSS.

the class DublinCoreExportUtil method writeContributorElement.

private static void writeContributorElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO, String dcFlavor) throws XMLStreamException {
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("citation".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.contributor.equals(fieldDTO.getTypeName())) {
                    String contributorName = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.contributorName.equals(next.getTypeName())) {
                                contributorName = next.getSinglePrimitive();
                            }
                        }
                        if (!contributorName.isEmpty()) {
                            xmlw.writeStartElement(dcFlavor + ":" + "contributor");
                            xmlw.writeCharacters(contributorName);
                            // abstract
                            xmlw.writeEndElement();
                        }
                    }
                }
            }
        }
    }
}
Also used : MetadataBlockDTO(edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO) Map(java.util.Map) FieldDTO(edu.harvard.iq.dataverse.api.dto.FieldDTO)

Example 12 with MetadataBlockDTO

use of edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO in project dataverse by IQSS.

the class DublinCoreExportUtil method writeSpatialElements.

private static void writeSpatialElements(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO, String dcFlavor) throws XMLStreamException {
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("geospatial".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.geographicCoverage.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.country.equals(next.getTypeName())) {
                                writeFullElement(xmlw, dcFlavor + ":" + "spatial", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.city.equals(next.getTypeName())) {
                                writeFullElement(xmlw, dcFlavor + ":" + "spatial", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.state.equals(next.getTypeName())) {
                                writeFullElement(xmlw, dcFlavor + ":" + "spatial", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.otherGeographicCoverage.equals(next.getTypeName())) {
                                writeFullElement(xmlw, dcFlavor + ":" + "spatial", next.getSinglePrimitive());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : MetadataBlockDTO(edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO) Map(java.util.Map) FieldDTO(edu.harvard.iq.dataverse.api.dto.FieldDTO)

Example 13 with MetadataBlockDTO

use of edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO in project dataverse by IQSS.

the class DublinCoreExportUtil method writeSubjectElement.

private static void writeSubjectElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO, String dcFlavor) throws XMLStreamException {
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("citation".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.subject.equals(fieldDTO.getTypeName())) {
                    for (String subject : fieldDTO.getMultipleVocab()) {
                        xmlw.writeStartElement(dcFlavor + ":" + "subject");
                        xmlw.writeCharacters(subject);
                        // Keyword
                        xmlw.writeEndElement();
                    }
                }
                if (DatasetFieldConstant.keyword.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        String keywordValue = "";
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.keywordValue.equals(next.getTypeName())) {
                                keywordValue = next.getSinglePrimitive();
                            }
                        }
                        if (!keywordValue.isEmpty()) {
                            xmlw.writeStartElement(dcFlavor + ":" + "subject");
                            xmlw.writeCharacters(keywordValue);
                            // Keyword
                            xmlw.writeEndElement();
                        }
                    }
                }
            }
        }
    }
}
Also used : MetadataBlockDTO(edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO) Map(java.util.Map) FieldDTO(edu.harvard.iq.dataverse.api.dto.FieldDTO)

Example 14 with MetadataBlockDTO

use of edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO in project dataverse by IQSS.

the class DublinCoreExportUtil method writeRelPublElement.

private static void writeRelPublElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO, String dcFlavor) throws XMLStreamException {
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("citation".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.publication.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        String pubString = "";
                        String citation = "";
                        String IDType = "";
                        String IDNo = "";
                        String url = "";
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.publicationCitation.equals(next.getTypeName())) {
                                citation = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.publicationIDType.equals(next.getTypeName())) {
                                IDType = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.publicationIDNumber.equals(next.getTypeName())) {
                                IDNo = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.publicationURL.equals(next.getTypeName())) {
                                url = next.getSinglePrimitive();
                            }
                        }
                        pubString = appendCommaSeparatedValue(citation, IDType);
                        pubString = appendCommaSeparatedValue(pubString, IDNo);
                        pubString = appendCommaSeparatedValue(pubString, url);
                        if (!pubString.isEmpty()) {
                            xmlw.writeStartElement(dcFlavor + ":" + "isReferencedBy");
                            xmlw.writeCharacters(pubString);
                            // relPubl
                            xmlw.writeEndElement();
                        }
                    }
                }
            }
        }
    }
}
Also used : MetadataBlockDTO(edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO) Map(java.util.Map) FieldDTO(edu.harvard.iq.dataverse.api.dto.FieldDTO)

Example 15 with MetadataBlockDTO

use of edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO in project dataverse by IQSS.

the class DdiExportUtil method writeSummaryDescriptionElement.

private static void writeSummaryDescriptionElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO) throws XMLStreamException {
    xmlw.writeStartElement("sumDscr");
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("citation".equals(key)) {
            Integer per = 0;
            Integer coll = 0;
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.timePeriodCovered.equals(fieldDTO.getTypeName())) {
                    String dateValStart = "";
                    String dateValEnd = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        per++;
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.timePeriodCoveredStart.equals(next.getTypeName())) {
                                dateValStart = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.timePeriodCoveredEnd.equals(next.getTypeName())) {
                                dateValEnd = next.getSinglePrimitive();
                            }
                        }
                        if (!dateValStart.isEmpty()) {
                            writeDateElement(xmlw, "timePrd", "P" + per.toString(), "start", dateValStart);
                        }
                        if (!dateValEnd.isEmpty()) {
                            writeDateElement(xmlw, "timePrd", "P" + per.toString(), "end", dateValEnd);
                        }
                    }
                }
                if (DatasetFieldConstant.dateOfCollection.equals(fieldDTO.getTypeName())) {
                    String dateValStart = "";
                    String dateValEnd = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        coll++;
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.dateOfCollectionStart.equals(next.getTypeName())) {
                                dateValStart = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.dateOfCollectionEnd.equals(next.getTypeName())) {
                                dateValEnd = next.getSinglePrimitive();
                            }
                        }
                        if (!dateValStart.isEmpty()) {
                            writeDateElement(xmlw, "collDate", "P" + coll.toString(), "start", dateValStart);
                        }
                        if (!dateValEnd.isEmpty()) {
                            writeDateElement(xmlw, "collDate", "P" + coll.toString(), "end", dateValEnd);
                        }
                    }
                }
                if (DatasetFieldConstant.kindOfData.equals(fieldDTO.getTypeName())) {
                    writeMultipleElement(xmlw, "dataKind", fieldDTO);
                }
            }
        }
        if ("geospatial".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.geographicCoverage.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.country.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "nation", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.city.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "geogCover", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.state.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "geogCover", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.otherGeographicCoverage.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "geogCover", next.getSinglePrimitive());
                            }
                        }
                    }
                }
                if (DatasetFieldConstant.geographicBoundingBox.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.westLongitude.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "westBL", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.eastLongitude.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "eastBL", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.northLatitude.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "northBL", next.getSinglePrimitive());
                            }
                            if (DatasetFieldConstant.southLatitude.equals(next.getTypeName())) {
                                writeFullElement(xmlw, "southBL", next.getSinglePrimitive());
                            }
                        }
                    }
                }
            }
            writeFullElementList(xmlw, "geogUnit", dto2PrimitiveList(datasetVersionDTO, DatasetFieldConstant.geographicUnit));
        }
        if ("socialscience".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.universe.equals(fieldDTO.getTypeName())) {
                    writeMultipleElement(xmlw, "universe", fieldDTO);
                }
                if (DatasetFieldConstant.unitOfAnalysis.equals(fieldDTO.getTypeName())) {
                    writeMultipleElement(xmlw, "anlyUnit", fieldDTO);
                }
            }
        }
    }
    // sumDscr
    xmlw.writeEndElement();
}
Also used : MetadataBlockDTO(edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO) Map(java.util.Map) FieldDTO(edu.harvard.iq.dataverse.api.dto.FieldDTO)

Aggregations

MetadataBlockDTO (edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO)32 FieldDTO (edu.harvard.iq.dataverse.api.dto.FieldDTO)26 Map (java.util.Map)22 DatasetFieldType (edu.harvard.iq.dataverse.DatasetFieldType)2 DatasetFieldCompoundValue (edu.harvard.iq.dataverse.DatasetFieldCompoundValue)1 ForeignMetadataFieldMapping (edu.harvard.iq.dataverse.ForeignMetadataFieldMapping)1 JsonParseException (edu.harvard.iq.dataverse.util.json.JsonParseException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 EJBException (javax.ejb.EJBException)1 NoResultException (javax.persistence.NoResultException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1