Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MathSciNet as ID-based fetcher #2621

Merged
merged 7 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Font sizes can now be increased <kbd>Ctrl</kbd> + <kbd>Plus</kbd>, decreased <kbd>Ctrl</kbd> + <kbd>Minus</kbd>, and reset to default <kbd>CTRL</kbd> + <kbd>0</kbd>.
- 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public EntryFetchers(JournalAbbreviationLoader abbreviationLoader) {
entryFetchers.add(new SearchBasedEntryFetcher(new GoogleScholar(Globals.prefs.getImportFormatPreferences())));
}

public List<EntryFetcher> getEntryFetchers() {
return Collections.unmodifiableList(this.entryFetchers);
}

public static List<IdBasedFetcher> getIdFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<IdBasedFetcher> list = new ArrayList<>();
list.add(new ArXiv(importFormatPreferences));
Expand All @@ -62,6 +58,7 @@ public static List<IdBasedFetcher> 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;
}
Expand All @@ -74,4 +71,8 @@ public static List<EntryBasedFetcher> getEntryBasedFetchers(ImportFormatPreferen
list.sort(Comparator.comparing(WebFetcher::getName));
return list;
}

public List<EntryFetcher> getEntryFetchers() {
return Collections.unmodifiableList(this.entryFetchers);
}
}
12 changes: 11 additions & 1 deletion src/main/java/org/jabref/logic/importer/fetcher/MathSciNet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<BibEntry> fetchedEntries = fetcher.performSearch("Two-Dimensional Ericksen Leslie System");
List<BibEntry> 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<BibEntry> fetchedEntry = fetcher.performSearchById("3537908");
assertEquals(Optional.of(ratiuEntry), fetchedEntry);
}
}