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);
}
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());
}
}
}
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());
}
}
}
}
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());
}
}
Aggregations