diff --git a/CHANGELOG.md b/CHANGELOG.md index 479f827dfeb..2d784e804c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Font sizes can now be increased Ctrl + Plus, decreased Ctrl + Minus, and reset to default CTRL + 0. - We integrated support for the [paper recommender system Mr.DLib](http://help.jabref.org/en/EntryEditor#related-articles-tab) in a new tab in the entry editor. - We renamed "database" to "library" to have a real distinction to SQL and NoSQL databases. [#2095](https://github.com/JabRef/jabref/issues/2095) +- We added MathSciNet as a ID-based fetcher in the `BibTeX -> New entry` dialog (implements a [feature request in the forum](http://discourse.jabref.org/t/allow-to-search-by-mr-number-mathscinet)) - Removed the apache.commons.collections library - We removed the ordinals-to-superscript formatter from the recommendations for biblatex save actions [#2596](https://github.com/JabRef/jabref/issues/2596) - The `Move linked files to default file directory`-Cleanup operation respects the `File directory pattern` setting diff --git a/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java b/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java index 5928f4f79f7..189e8209ad2 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/EntryFetchers.java @@ -49,10 +49,6 @@ public EntryFetchers(JournalAbbreviationLoader abbreviationLoader) { entryFetchers.add(new SearchBasedEntryFetcher(new GoogleScholar(Globals.prefs.getImportFormatPreferences()))); } - public List getEntryFetchers() { - return Collections.unmodifiableList(this.entryFetchers); - } - public static List getIdFetchers(ImportFormatPreferences importFormatPreferences) { ArrayList list = new ArrayList<>(); list.add(new ArXiv(importFormatPreferences)); @@ -62,6 +58,7 @@ public static List getIdFetchers(ImportFormatPreferences importF list.add(new DoiFetcher(importFormatPreferences)); list.add(new MedlineFetcher()); list.add(new TitleFetcher(importFormatPreferences)); + list.add(new MathSciNet(importFormatPreferences)); list.sort(Comparator.comparing(WebFetcher::getName)); return list; } @@ -74,4 +71,8 @@ public static List getEntryBasedFetchers(ImportFormatPreferen list.sort(Comparator.comparing(WebFetcher::getName)); return list; } + + public List getEntryFetchers() { + return Collections.unmodifiableList(this.entryFetchers); + } } 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 52ec5332f21..4262d289954 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java @@ -16,6 +16,7 @@ import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.importer.EntryBasedParserFetcher; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.IdBasedParserFetcher; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; @@ -30,7 +31,7 @@ /** * Fetches data from the MathSciNet (http://www.ams.org/mathscinet) */ -public class MathSciNet implements SearchBasedParserFetcher, EntryBasedParserFetcher { +public class MathSciNet implements SearchBasedParserFetcher, EntryBasedParserFetcher, IdBasedParserFetcher { private final ImportFormatPreferences preferences; @@ -71,6 +72,15 @@ public URL getURLForQuery(String query) throws URISyntaxException, MalformedURLE return uriBuilder.build().toURL(); } + @Override + public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException { + URIBuilder uriBuilder = new URIBuilder("http://www.ams.org/mathscinet/search/publications.html"); + uriBuilder.addParameter("pg1", "MR"); // search MR number + uriBuilder.addParameter("s1", identifier); // identifier + uriBuilder.addParameter("fmt", "bibtex"); // BibTeX format + return uriBuilder.build().toURL(); + } + @Override public Parser getParser() { diff --git a/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java b/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java index b4d2c50ca6f..b3b6533ed5f 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java @@ -1,6 +1,7 @@ package org.jabref.logic.importer.fetcher; import java.util.List; +import java.util.Optional; import org.jabref.logic.bibtex.FieldContentParserPreferences; import org.jabref.logic.importer.ImportFormatPreferences; @@ -65,8 +66,17 @@ public void searchByQueryFindsEntry() throws Exception { // CI has no subscription to zbMath and thus gets 401 response Assume.assumeFalse(DevEnvironment.isCIServer()); - List fetchedEntries = fetcher.performSearch("Two-Dimensional Ericksen Leslie System"); + List fetchedEntries = fetcher.performSearch("Existence and uniqueness theorems Two-Dimensional Ericksen Leslie System"); assertFalse(fetchedEntries.isEmpty()); assertEquals(ratiuEntry, fetchedEntries.get(0)); } + + @Test + public void searchByIdFindsEntry() throws Exception { + // CI has no subscription to zbMath and thus gets 401 response + Assume.assumeFalse(DevEnvironment.isCIServer()); + + Optional fetchedEntry = fetcher.performSearchById("3537908"); + assertEquals(Optional.of(ratiuEntry), fetchedEntry); + } }