Search in sources :

Example 21 with MetadataBlockDTO

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

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

Example 23 with MetadataBlockDTO

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

the class DdiExportUtil method writeSubjectElement.

private static void writeSubjectElement(XMLStreamWriter xmlw, DatasetVersionDTO datasetVersionDTO) throws XMLStreamException {
    // Key Words and Topic Classification
    xmlw.writeStartElement("subject");
    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("keyword");
                        xmlw.writeCharacters(subject);
                        // Keyword
                        xmlw.writeEndElement();
                    }
                }
                if (DatasetFieldConstant.keyword.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        String keywordValue = "";
                        String keywordVocab = "";
                        String keywordURI = "";
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.keywordValue.equals(next.getTypeName())) {
                                keywordValue = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.keywordVocab.equals(next.getTypeName())) {
                                keywordVocab = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.keywordVocabURI.equals(next.getTypeName())) {
                                keywordURI = next.getSinglePrimitive();
                            }
                        }
                        if (!keywordValue.isEmpty()) {
                            xmlw.writeStartElement("keyword");
                            if (!keywordVocab.isEmpty()) {
                                writeAttribute(xmlw, "vocab", keywordVocab);
                            }
                            if (!keywordURI.isEmpty()) {
                                writeAttribute(xmlw, "URI", keywordURI);
                            }
                            xmlw.writeCharacters(keywordValue);
                            // Keyword
                            xmlw.writeEndElement();
                        }
                    }
                }
                if (DatasetFieldConstant.topicClassification.equals(fieldDTO.getTypeName())) {
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        String topicClassificationValue = "";
                        String topicClassificationVocab = "";
                        String topicClassificationURI = "";
                        for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext(); ) {
                            FieldDTO next = iterator.next();
                            if (DatasetFieldConstant.topicClassValue.equals(next.getTypeName())) {
                                topicClassificationValue = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.topicClassVocab.equals(next.getTypeName())) {
                                topicClassificationVocab = next.getSinglePrimitive();
                            }
                            if (DatasetFieldConstant.topicClassVocabURI.equals(next.getTypeName())) {
                                topicClassificationURI = next.getSinglePrimitive();
                            }
                        }
                        if (!topicClassificationValue.isEmpty()) {
                            xmlw.writeStartElement("topcClas");
                            if (!topicClassificationVocab.isEmpty()) {
                                writeAttribute(xmlw, "vocab", topicClassificationVocab);
                            }
                            if (!topicClassificationURI.isEmpty()) {
                                writeAttribute(xmlw, "URI", topicClassificationURI);
                            }
                            xmlw.writeCharacters(topicClassificationValue);
                            // topcClas
                            xmlw.writeEndElement();
                        }
                    }
                }
            }
        }
    }
    // subject
    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 MetadataBlockDTO

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

the class ImportGenericServiceBean method getOtherIdFromDTO.

private String getOtherIdFromDTO(DatasetVersionDTO datasetVersionDTO) {
    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 = "";
                    for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
                        for (FieldDTO next : foo) {
                            if (DatasetFieldConstant.otherIdValue.equals(next.getTypeName())) {
                                otherId = next.getSinglePrimitive();
                            }
                        }
                        if (!otherId.isEmpty()) {
                            return otherId;
                        }
                    }
                }
            }
        }
    }
    return null;
}
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 MetadataBlockDTO

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

the class ImportGenericServiceBean method processDCTerms.

private void processDCTerms(XMLStreamReader xmlr, DatasetDTO datasetDTO, Map<String, String> filesMap) throws XMLStreamException {
    // make sure we have a codeBook
    // while ( xmlr.next() == XMLStreamConstants.COMMENT ); // skip pre root comments
    xmlr.nextTag();
    MetadataBlockDTO citationBlock = datasetDTO.getDatasetVersion().getMetadataBlocks().get("citation");
/*         if (codeBookLevelId != null && !codeBookLevelId.equals("")) {
            if (citationBlock.getField("otherId")==null) {
                // this means no ids were found during the parsing of the 
                // study description section. we'll use the one we found in 
                // the codeBook entry:
                FieldDTO otherIdValue = FieldDTO.createPrimitiveFieldDTO("otherIdValue", codeBookLevelId);
                FieldDTO otherId = FieldDTO.createCompoundFieldDTO("otherId", otherIdValue);
                citationBlock.getFields().add(otherId);
                
          } 
        }*/
}
Also used : MetadataBlockDTO(edu.harvard.iq.dataverse.api.dto.MetadataBlockDTO)

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