Search in sources :

Example 6 with MetadataBlockDTO

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

the class DdiExportUtil method writeRelPublElement.

private static void writeRelPublElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO) 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("relPubl");
                            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 7 with MetadataBlockDTO

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

the class DdiExportUtil method writeSoftwareElement.

private static void writeSoftwareElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO) 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.software.equals(fieldDTO.getTypeName())) {
                    String softwareName = "";
                    String softwareVersion = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.softwareName.equals(next.getTypeName())) {
                                softwareName = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.softwareVersion.equals(next.getTypeName())) {
                                softwareVersion = next.getSinglePrimitive();
                            }
                        }
                        if (!softwareName.isEmpty()) {
                            xmlw.writeStartElement("software");
                            if (!softwareVersion.isEmpty()) {
                                writeAttribute(xmlw, "version", softwareVersion);
                            }
                            xmlw.writeCharacters(softwareName);
                            // software
                            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 8 with MetadataBlockDTO

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

the class DublinCoreExportUtil method writeAuthorsElement.

private static void writeAuthorsElement(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.author.equals(fieldDTO.getTypeName())) {
                    String authorName = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.authorName.equals(next.getTypeName())) {
                                authorName = next.getSinglePrimitive();
                            }
                        }
                        if (!authorName.isEmpty()) {
                            xmlw.writeStartElement(dcFlavor + ":" + "creator");
                            xmlw.writeCharacters(authorName);
                            // AuthEnty
                            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 9 with MetadataBlockDTO

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

the class DublinCoreExportUtil method writeAbstractElement.

private static void writeAbstractElement(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.description.equals(fieldDTO.getTypeName())) {
                    String descriptionText = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.descriptionText.equals(next.getTypeName())) {
                                descriptionText = next.getSinglePrimitive();
                            }
                        }
                        if (!descriptionText.isEmpty()) {
                            xmlw.writeStartElement(dcFlavor + ":" + "description");
                            xmlw.writeCharacters(descriptionText);
                            // 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 10 with MetadataBlockDTO

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

the class DublinCoreExportUtil method writeTimeElements.

private static void writeTimeElements(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.timePeriodCovered.equals(fieldDTO.getTypeName())) {
                    String dateValStart = "";
                    String dateValEnd = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        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()) {
                            writeFullElement(xmlw, dcFlavor + ":" + "temporal", dateValStart);
                        }
                        if (!dateValEnd.isEmpty()) {
                            writeFullElement(xmlw, dcFlavor + ":" + "temporal", dateValEnd);
                        }
                    }
                }
                if (DatasetFieldConstant.dateOfCollection.equals(fieldDTO.getTypeName())) {
                    String dateValStart = "";
                    String dateValEnd = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        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()) {
                            writeFullElement(xmlw, dcFlavor + ":" + "temporal", dateValStart);
                        }
                        if (!dateValEnd.isEmpty()) {
                            writeFullElement(xmlw, dcFlavor + ":" + "temporal", dateValEnd);
                        }
                    }
                }
            }
        }
    }
}
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