Search in sources :

Example 21 with FieldDTO

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

the class DdiExportUtil method writeTargetSampleElement.

private static void writeTargetSampleElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO) throws XMLStreamException {
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("socialscience".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.targetSampleSize.equals(fieldDTO.getTypeName())) {
                    String sizeFormula = "";
                    String actualSize = "";
                    Set<FieldDTO> foo = fieldDTO.getSingleCompound();
                    for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                        FieldDTO next = iterator.next();
                        if (DatasetFieldConstant.targetSampleSizeFormula.equals(next.getTypeName())) {
                            sizeFormula = next.getSinglePrimitive();
                        }
                        if (DatasetFieldConstant.targetSampleActualSize.equals(next.getTypeName())) {
                            actualSize = next.getSinglePrimitive();
                        }
                    }
                    if (!sizeFormula.isEmpty()) {
                        xmlw.writeStartElement("sampleSizeFormula");
                        xmlw.writeCharacters(sizeFormula);
                        // sampleSizeFormula
                        xmlw.writeEndElement();
                    }
                    if (!actualSize.isEmpty()) {
                        xmlw.writeStartElement("sampleSize");
                        xmlw.writeCharacters(actualSize);
                        // sampleSize
                        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 22 with FieldDTO

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

the class DdiExportUtil method writeAuthorsElement.

private static void writeAuthorsElement(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.author.equals(fieldDTO.getTypeName())) {
                    xmlw.writeStartElement("rspStmt");
                    String authorName = "";
                    String authorAffiliation = "";
                    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 (DatasetFieldConstant.authorAffiliation.equals(next.getTypeName())) {
                                authorAffiliation = next.getSinglePrimitive();
                            }
                        }
                        if (!authorName.isEmpty()) {
                            xmlw.writeStartElement("AuthEnty");
                            if (!authorAffiliation.isEmpty()) {
                                writeAttribute(xmlw, "affiliation", authorAffiliation);
                            }
                            xmlw.writeCharacters(authorName);
                            // AuthEnty
                            xmlw.writeEndElement();
                        }
                    }
                    // rspStmt
                    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 23 with FieldDTO

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

the class DdiExportUtil method writeOtherIdElement.

private static void writeOtherIdElement(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.otherId.equals(fieldDTO.getTypeName())) {
                    String otherId = "";
                    String otherIdAgency = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.otherIdValue.equals(next.getTypeName())) {
                                otherId = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.otherIdAgency.equals(next.getTypeName())) {
                                otherIdAgency = next.getSinglePrimitive();
                            }
                        }
                        if (!otherId.isEmpty()) {
                            xmlw.writeStartElement("IDNo");
                            if (!otherIdAgency.isEmpty()) {
                                writeAttribute(xmlw, "agency", otherIdAgency);
                            }
                            xmlw.writeCharacters(otherId);
                            // IDNo
                            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 24 with FieldDTO

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

the class DdiExportUtil method writeDistributorsElement.

private static void writeDistributorsElement(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.distributor.equals(fieldDTO.getTypeName())) {
                    xmlw.writeStartElement("distrbtr");
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        String distributorName = "";
                        String distributorAffiliation = "";
                        String distributorAbbreviation = "";
                        String distributorURL = "";
                        String distributorLogoURL = "";
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.distributorName.equals(next.getTypeName())) {
                                distributorName = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.distributorAffiliation.equals(next.getTypeName())) {
                                distributorAffiliation = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.distributorAbbreviation.equals(next.getTypeName())) {
                                distributorAbbreviation = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.distributorURL.equals(next.getTypeName())) {
                                distributorURL = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.distributorLogo.equals(next.getTypeName())) {
                                distributorLogoURL = next.getSinglePrimitive();
                            }
                        }
                        if (!distributorName.isEmpty()) {
                            xmlw.writeStartElement("distrbtr");
                            if (!distributorAffiliation.isEmpty()) {
                                writeAttribute(xmlw, "affiliation", distributorAffiliation);
                            }
                            if (!distributorAbbreviation.isEmpty()) {
                                writeAttribute(xmlw, "abbr", distributorAbbreviation);
                            }
                            if (!distributorURL.isEmpty()) {
                                writeAttribute(xmlw, "URI", distributorURL);
                            }
                            if (!distributorLogoURL.isEmpty()) {
                                writeAttribute(xmlw, "role", distributorLogoURL);
                            }
                            xmlw.writeCharacters(distributorName);
                            // AuthEnty
                            xmlw.writeEndElement();
                        }
                    }
                    // rspStmt
                    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 25 with FieldDTO

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

the class DdiExportUtil method writeNotesElement.

private static void writeNotesElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO) throws XMLStreamException {
    for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
        String key = entry.getKey();
        MetadataBlockDTO value = entry.getValue();
        if ("socialscience".equals(key)) {
            for (FieldDTO fieldDTO : value.getFields()) {
                if (DatasetFieldConstant.socialScienceNotes.equals(fieldDTO.getTypeName())) {
                    String notesText = "";
                    String notesType = "";
                    String notesSubject = "";
                    Set<FieldDTO> foo = fieldDTO.getSingleCompound();
                    for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                        FieldDTO next = iterator.next();
                        if (DatasetFieldConstant.socialScienceNotesText.equals(next.getTypeName())) {
                            notesText = next.getSinglePrimitive();
                        }
                        if (DatasetFieldConstant.socialScienceNotesType.equals(next.getTypeName())) {
                            notesType = next.getSinglePrimitive();
                        }
                        if (DatasetFieldConstant.socialScienceNotesSubject.equals(next.getTypeName())) {
                            notesSubject = next.getSinglePrimitive();
                        }
                    }
                    if (!notesText.isEmpty()) {
                        xmlw.writeStartElement("notes");
                        if (!notesType.isEmpty()) {
                            writeAttribute(xmlw, "type", notesType);
                        }
                        if (!notesSubject.isEmpty()) {
                            writeAttribute(xmlw, "subject", notesSubject);
                        }
                        xmlw.writeCharacters(notesText);
                        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