Search in sources :

Example 1 with StringPlusLanguage

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

the class ModsExportFormat method addAffiliation.

private void addAffiliation(ModsDefinition mods, String value) {
    NameDefinition nameDefinition = new NameDefinition();
    StringPlusLanguage affiliation = new StringPlusLanguage();
    affiliation.setValue(value);
    JAXBElement<StringPlusLanguage> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "affiliation"), StringPlusLanguage.class, affiliation);
    nameDefinition.getAffiliationOrRoleOrDescription().add(element);
    mods.getModsGroup().add(nameDefinition);
}
Also used : StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) NameDefinition(org.jabref.logic.importer.fileformat.mods.NameDefinition)

Example 2 with StringPlusLanguage

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

the class ModsExportFormat method addTitle.

private void addTitle(ModsDefinition mods, String value) {
    TitleInfoDefinition titleInfo = new TitleInfoDefinition();
    StringPlusLanguage title = new StringPlusLanguage();
    title.setValue(value);
    JAXBElement<StringPlusLanguage> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "title"), StringPlusLanguage.class, title);
    titleInfo.getTitleOrSubTitleOrPartNumber().add(element);
    mods.getModsGroup().add(titleInfo);
}
Also used : TitleInfoDefinition(org.jabref.logic.importer.fileformat.mods.TitleInfoDefinition) StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement)

Example 3 with StringPlusLanguage

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

the class ModsExportFormat method addJournal.

private void addJournal(String value, RelatedItemDefinition relatedItem) {
    TitleInfoDefinition titleInfo = new TitleInfoDefinition();
    StringPlusLanguage title = new StringPlusLanguage();
    title.setValue(value);
    JAXBElement<StringPlusLanguage> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "title"), StringPlusLanguage.class, title);
    titleInfo.getTitleOrSubTitleOrPartNumber().add(element);
    relatedItem.getModsGroup().add(titleInfo);
}
Also used : TitleInfoDefinition(org.jabref.logic.importer.fileformat.mods.TitleInfoDefinition) StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement)

Example 4 with StringPlusLanguage

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

the class ModsImporter method parseRelatedModsGroup.

/**
     * Puts the Information from the RelatedModsGroup. It has the same elements like the ModsGroup.
     * But Informations like volume, issue and the pages appear here instead of in the ModsGroup.
     * Also if there appears a title field, then this indicates that is the name of journal which the article belongs to.
     */
private void parseRelatedModsGroup(Map<String, String> fields, List<Object> relatedModsGroup) {
    for (Object groupElement : relatedModsGroup) {
        if (groupElement instanceof PartDefinition) {
            PartDefinition part = (PartDefinition) groupElement;
            List<Object> detailOrExtentOrDate = part.getDetailOrExtentOrDate();
            for (Object object : detailOrExtentOrDate) {
                if (object instanceof DetailDefinition) {
                    DetailDefinition detail = (DetailDefinition) object;
                    List<JAXBElement<StringPlusLanguage>> numberOrCaptionOrTitle = detail.getNumberOrCaptionOrTitle();
                    //In the for loop should only be the value of the element that belongs to the detail not be null
                    for (JAXBElement<StringPlusLanguage> jaxbElement : numberOrCaptionOrTitle) {
                        StringPlusLanguage value = jaxbElement.getValue();
                        //put details like volume, issue,...
                        putIfValueNotNull(fields, detail.getType(), value.getValue());
                    }
                } else if (object instanceof ExtentDefinition) {
                    ExtentDefinition extentDefinition = (ExtentDefinition) object;
                    putPageInformation(extentDefinition, fields);
                }
            }
        } else if (groupElement instanceof TitleInfoDefinition) {
            TitleInfoDefinition titleInfo = (TitleInfoDefinition) groupElement;
            List<Object> titleOrSubTitleOrPartNumber = titleInfo.getTitleOrSubTitleOrPartNumber();
            for (Object object : titleOrSubTitleOrPartNumber) {
                if (object instanceof JAXBElement) {
                    @SuppressWarnings("unchecked") JAXBElement<StringPlusLanguage> element = (JAXBElement<StringPlusLanguage>) object;
                    if ("title".equals(element.getName().getLocalPart())) {
                        StringPlusLanguage journal = element.getValue();
                        fields.put(FieldName.JOURNAL, journal.getValue());
                    }
                }
            }
        }
    }
}
Also used : ExtentDefinition(org.jabref.logic.importer.fileformat.mods.ExtentDefinition) TitleInfoDefinition(org.jabref.logic.importer.fileformat.mods.TitleInfoDefinition) DetailDefinition(org.jabref.logic.importer.fileformat.mods.DetailDefinition) StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage) PartDefinition(org.jabref.logic.importer.fileformat.mods.PartDefinition) NamePartDefinition(org.jabref.logic.importer.fileformat.mods.NamePartDefinition) List(java.util.List) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement)

Example 5 with StringPlusLanguage

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

the class ModsExportFormat method addStartAndEndPage.

private void addStartAndEndPage(String value, PartDefinition partDefinition, String minus) {
    int minusIndex = value.indexOf(minus);
    String startPage = value.substring(0, minusIndex);
    String endPage = "";
    if (MINUS.equals(minus)) {
        endPage = value.substring(minusIndex + 1);
    } else if (DOUBLE_MINUS.equals(minus)) {
        endPage = value.substring(minusIndex + 2);
    }
    StringPlusLanguage start = new StringPlusLanguage();
    start.setValue(startPage);
    StringPlusLanguage end = new StringPlusLanguage();
    end.setValue(endPage);
    ExtentDefinition extent = new ExtentDefinition();
    extent.setStart(start);
    extent.setEnd(end);
    partDefinition.getDetailOrExtentOrDate().add(extent);
}
Also used : ExtentDefinition(org.jabref.logic.importer.fileformat.mods.ExtentDefinition) StringPlusLanguage(org.jabref.logic.importer.fileformat.mods.StringPlusLanguage)

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