diff --git a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java index a7bc4f49a4b..ff4486c9c55 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java @@ -103,14 +103,18 @@ public static MSBibEntry convert(BibEntry entry) { result.publicationTitle = entry.getField(FieldName.TITLE).orElse(null); } - entry.getLatexFreeField(FieldName.AUTHOR).ifPresent(authors -> result.authors = getAuthors(authors)); - entry.getLatexFreeField(FieldName.EDITOR).ifPresent(editors -> result.editors = getAuthors(editors)); + entry.getField(FieldName.AUTHOR).ifPresent(authors -> result.authors = getAuthors(authors)); + entry.getField(FieldName.EDITOR).ifPresent(editors -> result.editors = getAuthors(editors)); return result; } private static List getAuthors(String authors) { List result = new ArrayList<>(); + if (authors.startsWith("{") && authors.endsWith("}")) { + result.add(new PersonName(authors, true)); + return result; + } if (authors.toUpperCase(Locale.ENGLISH).contains(" AND ")) { String[] names = authors.split(" (?i)and "); diff --git a/src/main/java/org/jabref/logic/msbib/MSBibEntry.java b/src/main/java/org/jabref/logic/msbib/MSBibEntry.java index 8443f40e60a..228ddc0bfb3 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibEntry.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibEntry.java @@ -4,6 +4,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -321,16 +322,31 @@ private void addAuthor(Document document, Element allAuthors, String entryName, return; } Element authorTop = document.createElementNS(MSBibDatabase.NAMESPACE, MSBibDatabase.PREFIX + entryName); - Element nameList = document.createElementNS(MSBibDatabase.NAMESPACE, MSBibDatabase.PREFIX + "NameList"); - for (PersonName name : authorsLst) { - Element person = document.createElementNS(MSBibDatabase.NAMESPACE, MSBibDatabase.PREFIX + "Person"); - addField(document, person, "Last", name.getSurname()); - addField(document, person, "Middle", name.getMiddlename()); - addField(document, person, "First", name.getFirstname()); - nameList.appendChild(person); + + Optional personName = authorsLst.stream().filter(PersonName::isCorporateAuthor) + .findFirst(); + if (personName.isPresent()) { + PersonName person = personName.get(); + + Element corporate = document.createElementNS(MSBibDatabase.NAMESPACE, + MSBibDatabase.PREFIX + "Corporate"); + corporate.setTextContent(person.getFullname()); + authorTop.appendChild(corporate); + } else { + + Element nameList = document.createElementNS(MSBibDatabase.NAMESPACE, MSBibDatabase.PREFIX + "NameList"); + for (PersonName name : authorsLst) { + Element person = document.createElementNS(MSBibDatabase.NAMESPACE, MSBibDatabase.PREFIX + "Person"); + addField(document, person, "Last", name.getSurname()); + addField(document, person, "Middle", name.getMiddlename()); + addField(document, person, "First", name.getFirstname()); + nameList.appendChild(person); + + } + authorTop.appendChild(nameList); } - authorTop.appendChild(nameList); allAuthors.appendChild(authorTop); + } private void addAddress(Document document, Element parent, String addressToSplit) { diff --git a/src/main/java/org/jabref/logic/msbib/PersonName.java b/src/main/java/org/jabref/logic/msbib/PersonName.java index 08f28149cc4..14f55188689 100644 --- a/src/main/java/org/jabref/logic/msbib/PersonName.java +++ b/src/main/java/org/jabref/logic/msbib/PersonName.java @@ -20,7 +20,7 @@ public class PersonName { private String givenName; private String surname; private String middleName; - + private boolean isCorporate; public PersonName() { // Empty constructor @@ -30,6 +30,12 @@ public PersonName(String name) { parseName(name); } + public PersonName(String name, boolean isCorporate) { + this(name); + this.isCorporate = isCorporate; + + } + public PersonName(String firstName, String middleName, String lastName) { givenName = firstName; this.middleName = middleName; @@ -59,8 +65,7 @@ private void parseName(String author) { } else if (amountOfNames == 2) { givenName = names.get(0); surname = names.get(1); - } - else { + } else { givenName = names.get(0); middleName = ""; for (int i = 1; i < (amountOfNames - 1); i++) { @@ -106,6 +111,10 @@ public void setMiddlename(String middleName) { this.middleName = middleName; } + public boolean isCorporateAuthor() { + return isCorporate; + } + public String getFullname() { StringBuilder fullName = new StringBuilder(); if ((givenName != null) && !givenName.isEmpty()) {