Skip to content

Commit

Permalink
integrate AdsFetcher into AstrophysicsDataSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
zesaro committed Sep 19, 2016
1 parent 9303696 commit 9f29a2d
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import net.sf.jabref.Globals;
import net.sf.jabref.logic.importer.IdBasedFetcher;
import net.sf.jabref.logic.importer.fetcher.AdsFetcher;
import net.sf.jabref.logic.importer.fetcher.ArXiv;
import net.sf.jabref.logic.importer.fetcher.AstrophysicsDataSystem;
import net.sf.jabref.logic.importer.fetcher.DiVA;
Expand Down Expand Up @@ -49,7 +48,7 @@ public List<EntryFetcher> getEntryFetchers() {

public static ArrayList<IdBasedFetcher> getIdFetchers() {
ArrayList<IdBasedFetcher> list = new ArrayList<>();
list.add(new AdsFetcher(Globals.prefs.getImportFormatPreferences()));
list.add(new AstrophysicsDataSystem(Globals.prefs.getImportFormatPreferences()));
list.add(new IsbnFetcher(Globals.prefs.getImportFormatPreferences()));
list.add(new DiVA(Globals.prefs.getImportFormatPreferences()));
list.add(new DoiFetcher(Globals.prefs.getImportFormatPreferences()));
Expand Down
85 changes: 0 additions & 85 deletions src/main/java/net/sf/jabref/logic/importer/fetcher/AdsFetcher.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import net.sf.jabref.logic.formatter.bibtexfields.ClearFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.importer.EntryBasedParserFetcher;
import net.sf.jabref.logic.importer.FetcherException;
import net.sf.jabref.logic.importer.IdBasedParserFetcher;
import net.sf.jabref.logic.importer.ImportFormatPreferences;
import net.sf.jabref.logic.importer.Parser;
import net.sf.jabref.logic.importer.SearchBasedParserFetcher;
Expand All @@ -29,10 +31,11 @@
* There is also a new API (https://github.com/adsabs/adsabs-dev-api) but it returns JSON
* (or at least needs multiple calls to get BibTeX, status: September 2016)
*/
public class AstrophysicsDataSystem implements SearchBasedParserFetcher, EntryBasedParserFetcher {
public class AstrophysicsDataSystem implements IdBasedParserFetcher, SearchBasedParserFetcher, EntryBasedParserFetcher {

private static String API_QUERY_URL = "http://adsabs.harvard.edu/cgi-bin/nph-basic_connect";
private static String API_ENTRY_URL = "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect";
private static String API_DOI_URL = "http://adsabs.harvard.edu/doi/";
private final ImportFormatPreferences preferences;

public AstrophysicsDataSystem(ImportFormatPreferences preferences) {
Expand Down Expand Up @@ -89,6 +92,19 @@ public URL getURLForEntry(BibEntry entry) throws URISyntaxException, MalformedUR
return uriBuilder.build().toURL();
}

@Override
public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException {
String key = identifier.replaceAll("^(doi:|DOI:)", "");
URIBuilder uriBuilder = new URIBuilder(API_DOI_URL + key);
uriBuilder.addParameter("data_type", "BIBTEXPLUS");
return uriBuilder.build().toURL();
}

@Override
public HelpFile getHelpPage() {
return HelpFile.FETCHER_ADS;
}

@Override
public Parser getParser() {
return new BibtexParser(preferences);
Expand Down
137 changes: 0 additions & 137 deletions src/test/java/net/sf/jabref/logic/importer/fetcher/AdsFetcherTest.java

This file was deleted.

Loading

0 comments on commit 9f29a2d

Please sign in to comment.