use of org.jabref.logic.importer.fileformat.mods.DetailDefinition 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());
}
}
}
}
}
}
use of org.jabref.logic.importer.fileformat.mods.DetailDefinition 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);
}
Aggregations