Search in sources :

Example 6 with FieldDTO

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

the class DdiExportUtil method writeSeriesElement.

private static void writeSeriesElement(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.series.equals(fieldDTO.getTypeName())) {
                    xmlw.writeStartElement("serStmt");
                    String seriesName = "";
                    String seriesInformation = "";
                    Set<FieldDTO> foo = fieldDTO.getSingleCompound();
                    for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                        FieldDTO next = iterator.next();
                        if (DatasetFieldConstant.seriesName.equals(next.getTypeName())) {
                            seriesName = next.getSinglePrimitive();
                        }
                        if (DatasetFieldConstant.seriesInformation.equals(next.getTypeName())) {
                            seriesInformation = next.getSinglePrimitive();
                        }
                    }
                    if (!seriesName.isEmpty()) {
                        xmlw.writeStartElement("serName");
                        xmlw.writeCharacters(seriesName);
                        // grantno
                        xmlw.writeEndElement();
                    }
                    if (!seriesInformation.isEmpty()) {
                        xmlw.writeStartElement("serInfo");
                        xmlw.writeCharacters(seriesInformation);
                        // grantno
                        xmlw.writeEndElement();
                    }
                    // serStmt
                    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 FieldDTO

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

the class DdiExportUtil method writeContactsElement.

private static void writeContactsElement(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.datasetContact.equals(fieldDTO.getTypeName())) {
                    String datasetContactName = "";
                    String datasetContactAffiliation = "";
                    String datasetContactEmail = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.datasetContactName.equals(next.getTypeName())) {
                                datasetContactName = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.datasetContactAffiliation.equals(next.getTypeName())) {
                                datasetContactAffiliation = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.datasetContactEmail.equals(next.getTypeName())) {
                                datasetContactEmail = next.getSinglePrimitive();
                            }
                        }
                        // TODO: Since datasetContactEmail is a required field but datasetContactName is not consider not checking if datasetContactName is empty so we can write out datasetContactEmail.
                        if (!datasetContactName.isEmpty()) {
                            xmlw.writeStartElement("contact");
                            if (!datasetContactAffiliation.isEmpty()) {
                                writeAttribute(xmlw, "affiliation", datasetContactAffiliation);
                            }
                            if (!datasetContactEmail.isEmpty()) {
                                writeAttribute(xmlw, "email", datasetContactEmail);
                            }
                            xmlw.writeCharacters(datasetContactName);
                            // 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 8 with FieldDTO

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

the class DdiExportUtil method writeAbstractElement.

private static void writeAbstractElement(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.description.equals(fieldDTO.getTypeName())) {
                    String descriptionText = "";
                    String descriptionDate = "";
                    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 (DatasetFieldConstant.descriptionDate.equals(next.getTypeName())) {
                                descriptionDate = next.getSinglePrimitive();
                            }
                        }
                        if (!descriptionText.isEmpty()) {
                            xmlw.writeStartElement("abstract");
                            if (!descriptionDate.isEmpty()) {
                                writeAttribute(xmlw, "date", descriptionDate);
                            }
                            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 9 with FieldDTO

use of edu.harvard.iq.dataverse.api.dto.FieldDTO 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 10 with FieldDTO

use of edu.harvard.iq.dataverse.api.dto.FieldDTO 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)

Aggregations

FieldDTO (edu.harvard.iq.dataverse.api.dto.FieldDTO)32 MetadataBlockDTO (edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO)26 Map (java.util.Map)22 Gson (com.google.gson.Gson)2 DatasetFieldCompoundValue (edu.harvard.iq.dataverse.DatasetFieldCompoundValue)2 DatasetFieldType (edu.harvard.iq.dataverse.DatasetFieldType)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 JsonElement (com.google.gson.JsonElement)1 DatasetField (edu.harvard.iq.dataverse.DatasetField)1 ForeignMetadataFieldMapping (edu.harvard.iq.dataverse.ForeignMetadataFieldMapping)1 DatasetVersionDTO (edu.harvard.iq.dataverse.api.dto.DatasetVersionDTO)1 JsonParseException (edu.harvard.iq.dataverse.util.json.JsonParseException)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 StringReader (java.io.StringReader)1 Scanner (java.util.Scanner)1 EJBException (javax.ejb.EJBException)1 JsonObject (javax.json.JsonObject)1