Search in sources :

Example 6 with StringPlusLanguage

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

the class ModsExportFormat method addDetail.

private void addDetail(String detailName, String value, PartDefinition partDefinition) {
    DetailDefinition detail = new DetailDefinition();
    StringPlusLanguage detailType = new StringPlusLanguage();
    detailType.setValue(value);
    detail.setType(detailName);
    JAXBElement<StringPlusLanguage> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "number"), StringPlusLanguage.class, detailType);
    detail.getNumberOrCaptionOrTitle().add(element);
    partDefinition.getDetailOrExtentOrDate().add(detail);
}
Also used : DetailDefinition(org.jabref.logic.importer.fileformat.mods.DetailDefinition) StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement)

Example 7 with StringPlusLanguage

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

the class ModsImporter method parseGeographicInformation.

private void parseGeographicInformation(Map<String, String> fields, HierarchicalGeographicDefinition hierarchichalGeographic) {
    List<JAXBElement<? extends StringPlusLanguage>> areaOrContinentOrCountry = hierarchichalGeographic.getExtraTerrestrialAreaOrContinentOrCountry();
    for (JAXBElement<? extends StringPlusLanguage> element : areaOrContinentOrCountry) {
        String localName = element.getName().getLocalPart();
        if ("city".equals(localName)) {
            StringPlusLanguage city = element.getValue();
            putIfValueNotNull(fields, "city", city.getValue());
        } else if ("country".equals(localName)) {
            StringPlusLanguage country = element.getValue();
            putIfValueNotNull(fields, "country", country.getValue());
        }
    }
}
Also used : StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) JAXBElement(javax.xml.bind.JAXBElement)

Example 8 with StringPlusLanguage

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

the class ModsImporter method parseTitle.

private void parseTitle(Map<String, String> fields, List<Object> titleOrSubTitleOrPartNumber) {
    for (Object object : titleOrSubTitleOrPartNumber) {
        if (object instanceof JAXBElement) {
            @SuppressWarnings("unchecked") JAXBElement<StringPlusLanguage> element = (JAXBElement<StringPlusLanguage>) object;
            if ("title".equals(element.getName().getLocalPart())) {
                StringPlusLanguage title = element.getValue();
                fields.put(FieldName.TITLE, title.getValue());
            }
        }
    }
}
Also used : StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) JAXBElement(javax.xml.bind.JAXBElement)

Example 9 with StringPlusLanguage

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

the class ModsImporter method handleAuthorsInNamePart.

private void handleAuthorsInNamePart(NameDefinition name, List<String> authors, Map<String, String> fields) {
    List<JAXBElement<?>> namePartOrDisplayFormOrAffiliation = name.getNamePartOrDisplayFormOrAffiliation();
    List<String> foreName = new ArrayList<>();
    String familyName = "";
    String author = "";
    for (JAXBElement<?> element : namePartOrDisplayFormOrAffiliation) {
        Object value = element.getValue();
        String elementName = element.getName().getLocalPart();
        if (value instanceof NamePartDefinition) {
            NamePartDefinition namePart = (NamePartDefinition) value;
            String type = namePart.getAtType();
            if ((type == null) && (namePart.getValue() != null)) {
                authors.add(namePart.getValue());
            } else if ("family".equals(type) && (namePart.getValue() != null)) {
                //we have to check if forename and family name are not empty in case it's the first author
                if (!foreName.isEmpty() && !familyName.isEmpty()) {
                    //now set and add the old author
                    author = familyName + ", " + Joiner.on(" ").join(foreName);
                    authors.add(author);
                    //remove old forenames
                    foreName.clear();
                } else if (foreName.isEmpty() && !familyName.isEmpty()) {
                    authors.add(familyName);
                }
                familyName = namePart.getValue();
            } else if ("given".equals(type) && (namePart.getValue() != null)) {
                foreName.add(namePart.getValue());
            }
        } else if ((value instanceof StringPlusLanguage) && "affiliation".equals(elementName)) {
            StringPlusLanguage affiliation = (StringPlusLanguage) value;
            putIfValueNotNull(fields, "affiliation", affiliation.getValue());
        }
    }
    //last author is not added, so do it here
    if (!foreName.isEmpty() && !familyName.isEmpty()) {
        author = familyName + ", " + Joiner.on(" ").join(foreName);
        authors.add(author.trim());
        foreName.clear();
    } else if (foreName.isEmpty() && !familyName.isEmpty()) {
        authors.add(familyName.trim());
    }
}
Also used : StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) ArrayList(java.util.ArrayList) NamePartDefinition(org.jabref.logic.importer.fileformat.mods.NamePartDefinition) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

StringPlusLanguage (org.jabref.logic.importer.fileformat.mods.StringPlusLanguage)9 JAXBElement (javax.xml.bind.JAXBElement)8 QName (javax.xml.namespace.QName)4 TitleInfoDefinition (org.jabref.logic.importer.fileformat.mods.TitleInfoDefinition)3 ArrayList (java.util.ArrayList)2 DetailDefinition (org.jabref.logic.importer.fileformat.mods.DetailDefinition)2 ExtentDefinition (org.jabref.logic.importer.fileformat.mods.ExtentDefinition)2 NamePartDefinition (org.jabref.logic.importer.fileformat.mods.NamePartDefinition)2 List (java.util.List)1 NameDefinition (org.jabref.logic.importer.fileformat.mods.NameDefinition)1 PartDefinition (org.jabref.logic.importer.fileformat.mods.PartDefinition)1