Search in sources :

Example 1 with StringPlusLanguagePlusAuthority

use of org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority in project jabref by JabRef.

the class ModsExportFormat method addKeyWords.

private void addKeyWords(ModsDefinition mods, String value) {
    String[] keywords = value.split(", ");
    for (String keyword : keywords) {
        SubjectDefinition subject = new SubjectDefinition();
        StringPlusLanguagePlusAuthority topic = new StringPlusLanguagePlusAuthority();
        topic.setValue(keyword);
        JAXBElement<?> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "topic"), StringPlusLanguagePlusAuthority.class, topic);
        subject.getTopicOrGeographicOrTemporal().add(element);
        mods.getModsGroup().add(subject);
    }
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) StringPlusLanguagePlusAuthority(org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority) SubjectDefinition(org.jabref.logic.importer.fileformat.mods.SubjectDefinition)

Example 2 with StringPlusLanguagePlusAuthority

use of org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority in project jabref by JabRef.

the class ModsImporter method parseRecordInfo.

private void parseRecordInfo(Map<String, String> fields, RecordInfoDefinition recordInfo) {
    List<JAXBElement<?>> recordContent = recordInfo.getRecordContentSourceOrRecordCreationDateOrRecordChangeDate();
    for (JAXBElement<?> jaxbElement : recordContent) {
        Object value = jaxbElement.getValue();
        if (value instanceof StringPlusLanguagePlusAuthority) {
            StringPlusLanguagePlusAuthority source = (StringPlusLanguagePlusAuthority) value;
            putIfValueNotNull(fields, "source", source.getValue());
        } else if (value instanceof LanguageDefinition) {
            LanguageDefinition language = (LanguageDefinition) value;
            List<LanguageTermDefinition> languageTerms = language.getLanguageTerm();
            List<String> languages = languageTerms.stream().map(LanguageTermDefinition::getValue).collect(Collectors.toList());
            putIfListIsNotEmpty(fields, languages, FieldName.LANGUAGE, ", ");
        }
    }
}
Also used : LanguageDefinition(org.jabref.logic.importer.fileformat.mods.LanguageDefinition) List(java.util.List) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) StringPlusLanguagePlusAuthority(org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority) LanguageTermDefinition(org.jabref.logic.importer.fileformat.mods.LanguageTermDefinition)

Example 3 with StringPlusLanguagePlusAuthority

use of org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority in project jabref by JabRef.

the class ModsImporter method parseTopic.

private void parseTopic(Map<String, String> fields, List<JAXBElement<?>> topicOrGeographicOrTemporal, List<String> keywords) {
    for (JAXBElement<?> jaxbElement : topicOrGeographicOrTemporal) {
        Object value = jaxbElement.getValue();
        String elementName = jaxbElement.getName().getLocalPart();
        if (value instanceof HierarchicalGeographicDefinition) {
            HierarchicalGeographicDefinition hierarchichalGeographic = (HierarchicalGeographicDefinition) value;
            parseGeographicInformation(fields, hierarchichalGeographic);
        } else if ((value instanceof StringPlusLanguagePlusAuthority) && "topic".equals(elementName)) {
            StringPlusLanguagePlusAuthority topic = (StringPlusLanguagePlusAuthority) value;
            keywords.add(topic.getValue().trim());
        }
    }
}
Also used : HierarchicalGeographicDefinition(org.jabref.logic.importer.fileformat.mods.HierarchicalGeographicDefinition) StringPlusLanguagePlusAuthority(org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority)

Aggregations

StringPlusLanguagePlusAuthority (org.jabref.logic.importer.fileformat.mods.StringPlusLanguagePlusAuthority)3 JAXBElement (javax.xml.bind.JAXBElement)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1 HierarchicalGeographicDefinition (org.jabref.logic.importer.fileformat.mods.HierarchicalGeographicDefinition)1 LanguageDefinition (org.jabref.logic.importer.fileformat.mods.LanguageDefinition)1 LanguageTermDefinition (org.jabref.logic.importer.fileformat.mods.LanguageTermDefinition)1 SubjectDefinition (org.jabref.logic.importer.fileformat.mods.SubjectDefinition)1