performSearch(BibEntry entry) throws FetcherException {
bibEntry.ifPresent(list::add);
return list;
}
-
}
diff --git a/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java b/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java
index 4262d289954..eeacd2a0f70 100644
--- a/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java
+++ b/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java
@@ -108,5 +108,8 @@ public void doPostCleanup(BibEntry entry) {
new MoveFieldCleanup("mrclass", FieldName.KEYWORDS).cleanup(entry);
new FieldFormatterCleanup("mrreviewer", new ClearFormatter()).cleanup(entry);
new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
+
+ // Remove comments: MathSciNet prepends a html tag
+ entry.setCommentsBeforeEntry("");
}
}
diff --git a/src/main/java/org/jabref/logic/journals/AbbreviationParser.java b/src/main/java/org/jabref/logic/journals/AbbreviationParser.java
index c5d8eab569f..589081ab6e0 100644
--- a/src/main/java/org/jabref/logic/journals/AbbreviationParser.java
+++ b/src/main/java/org/jabref/logic/journals/AbbreviationParser.java
@@ -11,9 +11,11 @@
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -25,7 +27,7 @@ public class AbbreviationParser {
private static final Log LOGGER = LogFactory.getLog(AbbreviationParser.class);
- private final List abbreviations = new LinkedList<>();
+ private final Set abbreviations = new HashSet<>(5000);
public void readJournalListFromResource(String resourceFileName) {
URL url = Objects.requireNonNull(JournalAbbreviationRepository.class.getResource(Objects.requireNonNull(resourceFileName)));
@@ -90,9 +92,7 @@ private void addLine(String line) {
}
Abbreviation abbreviation = new Abbreviation(fullName, abbrName);
- if (!abbreviations.contains(abbreviation)) {
- this.abbreviations.add(abbreviation);
- }
+ this.abbreviations.add(abbreviation);
}
}
diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java
index 56a26be1b39..08743e3ffe2 100644
--- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java
+++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java
@@ -1,14 +1,11 @@
package org.jabref.logic.journals;
+import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -19,12 +16,7 @@
public class JournalAbbreviationRepository {
private static final Log LOGGER = LogFactory.getLog(JournalAbbreviationRepository.class);
- private final Map fullNameLowerCase2Abbreviation = new HashMap<>();
- private final Map isoLowerCase2Abbreviation = new HashMap<>();
-
- private final Map medlineLowerCase2Abbreviation = new HashMap<>();
-
- private final SortedSet abbreviations = new TreeSet<>();
+ private final Set abbreviations = new HashSet<>(16000); // We have over 15.000 abbreviations in the built-in lists
public JournalAbbreviationRepository(Abbreviation... abbreviations) {
for (Abbreviation abbreviation : abbreviations) {
@@ -32,19 +24,27 @@ public JournalAbbreviationRepository(Abbreviation... abbreviations) {
}
}
+ private static boolean isMatched(String name, Abbreviation abbreviation) {
+ return name.equalsIgnoreCase(abbreviation.getName())
+ || name.equalsIgnoreCase(abbreviation.getIsoAbbreviation())
+ || name.equalsIgnoreCase(abbreviation.getMedlineAbbreviation());
+ }
+
+ private static boolean isMatchedAbbreviated(String name, Abbreviation abbreviation) {
+ return name.equalsIgnoreCase(abbreviation.getIsoAbbreviation())
+ || name.equalsIgnoreCase(abbreviation.getMedlineAbbreviation());
+ }
+
public int size() {
return abbreviations.size();
}
public boolean isKnownName(String journalName) {
- String nameKey = Objects.requireNonNull(journalName).trim().toLowerCase(Locale.ENGLISH);
- return (fullNameLowerCase2Abbreviation.containsKey(nameKey)) || (isoLowerCase2Abbreviation.containsKey(nameKey))
- || (medlineLowerCase2Abbreviation.containsKey(nameKey));
+ return abbreviations.stream().anyMatch(abbreviation -> isMatched(journalName.trim(), abbreviation));
}
public boolean isAbbreviatedName(String journalName) {
- String nameKey = Objects.requireNonNull(journalName).trim().toLowerCase(Locale.ENGLISH);
- return (isoLowerCase2Abbreviation.containsKey(nameKey)) || (medlineLowerCase2Abbreviation.containsKey(nameKey));
+ return abbreviations.stream().anyMatch(abbreviation -> isMatchedAbbreviated(journalName.trim(), abbreviation));
}
/**
@@ -54,23 +54,13 @@ public boolean isAbbreviatedName(String journalName) {
* @return The abbreviated name
*/
public Optional getAbbreviation(String journalName) {
- String nameKey = Objects.requireNonNull(journalName).toLowerCase(Locale.ENGLISH).trim();
-
- if (fullNameLowerCase2Abbreviation.containsKey(nameKey)) {
- return Optional.of(fullNameLowerCase2Abbreviation.get(nameKey));
- } else if (isoLowerCase2Abbreviation.containsKey(nameKey)) {
- return Optional.of(isoLowerCase2Abbreviation.get(nameKey));
- } else if (medlineLowerCase2Abbreviation.containsKey(nameKey)) {
- return Optional.of(medlineLowerCase2Abbreviation.get(nameKey));
- } else {
- return Optional.empty();
- }
+ return abbreviations.stream().filter(abbreviation -> isMatched(journalName.trim(), abbreviation)).findFirst();
}
public void addEntry(Abbreviation abbreviation) {
Objects.requireNonNull(abbreviation);
- if (isKnownName(abbreviation.getName())) {
+ if (abbreviations.contains(abbreviation)) {
Abbreviation previous = getAbbreviation(abbreviation.getName()).get();
abbreviations.remove(previous);
LOGGER.info("Duplicate journal abbreviation - old one will be overwritten by new one\nOLD: "
@@ -78,51 +68,25 @@ public void addEntry(Abbreviation abbreviation) {
}
abbreviations.add(abbreviation);
-
- fullNameLowerCase2Abbreviation.put(abbreviation.getName().toLowerCase(Locale.ENGLISH), abbreviation);
- isoLowerCase2Abbreviation.put(abbreviation.getIsoAbbreviation().toLowerCase(Locale.ENGLISH), abbreviation);
- medlineLowerCase2Abbreviation.put(abbreviation.getMedlineAbbreviation().toLowerCase(Locale.ENGLISH),
- abbreviation);
}
- public void addEntries(List