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

ADS Fetcher using the new fetcher infrastructure #1923

Merged
merged 13 commits into from
Sep 21, 2016
165 changes: 0 additions & 165 deletions src/main/java/net/sf/jabref/gui/importer/fetcher/ADSFetcher.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class EntryFetchers {
private final List<EntryFetcher> entryFetchers = new LinkedList<>();

public EntryFetchers(JournalAbbreviationLoader abbreviationLoader) {
entryFetchers.add(new ADSFetcher());
entryFetchers.add(new CiteSeerXFetcher());
entryFetchers.add(new DBLPFetcher());
entryFetchers.add(new IEEEXploreFetcher(abbreviationLoader));
Expand All @@ -49,6 +48,7 @@ public List<EntryFetcher> getEntryFetchers() {

public static ArrayList<IdBasedFetcher> getIdFetchers() {
ArrayList<IdBasedFetcher> list = new ArrayList<>();
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
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,13 @@
* 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 String patternRemoveDOI = "^(doi:|DOI:)";
private final ImportFormatPreferences preferences;

public AstrophysicsDataSystem(ImportFormatPreferences preferences) {
Expand Down Expand Up @@ -89,6 +94,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(patternRemoveDOI, "");
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
9 changes: 1 addition & 8 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,6 @@ Unmark_entries=Fjern_mærkning

Unmark_entry=Fjern_mærkning


untitled=uden_navn

Up=Op
Expand Down Expand Up @@ -1419,6 +1418,7 @@ Fetching_Medline_by_term...=Henter_fra_Medline_via_udtryk...
Please_enter_a_valid_number=Indtast_venligst_et_gyldigt_tal
Please_enter_a_comma_separated_list_of_Medline_IDs_(numbers)_or_search_terms.=Indtast_venligst_en_kommasepareret_liste_af_Medline_IDer_(numre)_eller_søgeudtryk.
Show_search_results_in_a_window=Vis_søgeresultater_i_et_vindue
Search_in_all_open_databases=
Move_file_to_file_directory?=Flyt_fil_til_filbibliotek?
Rename_to_'%0'=Omdøb_til_'%0'
You_have_changed_the_menu_and_label_font_size.=Du_har_ændret_menu-_og_tekst-skriftstørrelsen.
Expand Down Expand Up @@ -1771,8 +1771,6 @@ Add_{}_to_specified_title_words_on_search_to_keep_the_correct_case=
Import_conversions=
Please_enter_a_search_string=
Please_open_or_start_a_new_database_before_searching=
An_error_occurred_while_fetching_from_ADS_(%0)\:=
An_error_occurred_while_parsing_abstract=
Log=

Canceled_merging_entries=
Expand Down Expand Up @@ -1921,7 +1919,6 @@ Copy_BibTeX_key_and_title=
File_rename_failed_for_%0_entries.=
To_set_up,_go_to=For_at_sætte_op,_gå_til
Merged_BibTeX_source_code=
'%0'_is_not_a_valid_ADS_bibcode.=
Invalid_DOI\:_'%0'.=Ugyldig_DOI\:_'%0'.
should_start_with_a_name=
should_end_with_a_name=
Expand Down Expand Up @@ -2155,8 +2152,6 @@ OpenOffice/LibreOffice_integration=

incorrect_control_digit=
incorrect_format=


Copy_version_to_clipboard=
Copied_version_to_clipboard=

Expand Down Expand Up @@ -2301,6 +2296,4 @@ Fetcher_'%0'_did_not_find_an_entry_for_id_'%1'.=
Select_first_entry=
Select_last_entry=

Search_in_all_open_databases=

Invalid_ISBN\:_'%0'.=
11 changes: 1 addition & 10 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1324,9 +1324,6 @@ Unmark_entries=Markierung_aufheben

Unmark_entry=Markierung_aufheben




untitled=ohne_Titel

Up=Hoch
Expand Down Expand Up @@ -1421,6 +1418,7 @@ Fetching_Medline_by_term...=Rufe_Medline_mittels_Suchbegriff_ab...
Please_enter_a_valid_number=Bitte_geben_Sie_eine_gültige_Zahl_ein
Please_enter_a_comma_separated_list_of_Medline_IDs_(numbers)_or_search_terms.=Bitte_geben_Sie_eine_durch_Kommas_unterteilte_Liste_von_Medline-IDs_(Zahlen)_oder_Suchausdrücken_ein.
Show_search_results_in_a_window=Suchergebnisse_in_einem_Fenster_anzeigen
Search_in_all_open_databases=
Move_file_to_file_directory?=Datei_in_Dateiverzeichnis_verschieben?
Rename_to_'%0'=Umbenennen_in_'%0'
You_have_changed_the_menu_and_label_font_size.=Sie_haben_die_Schriftgröße_für_Menüs_und_Label_geändert.
Expand Down Expand Up @@ -1773,8 +1771,6 @@ Add_{}_to_specified_title_words_on_search_to_keep_the_correct_case=Nach_der_Such
Import_conversions=Konvertierungen_importieren
Please_enter_a_search_string=Bitte_geben_Sie_eine_Suchphrase_ein
Please_open_or_start_a_new_database_before_searching=Bitte_öffnen_Sie_eine_Datei_oder_legen_Sie_eine_neue_an,_bevor_Sie_suchen
An_error_occurred_while_fetching_from_ADS_(%0)\:=Beim_Abrufen_von_ADS_ist_ein_Fehler_aufgetreten_(%0)\:
An_error_occurred_while_parsing_abstract=Beim_Parsen_der_Zusammenfassung_ist_ein_Fehler_aufgetreten
Log=Protokoll

Canceled_merging_entries=Zusammenführen_der_Einträge_abgebrochen
Expand Down Expand Up @@ -1865,7 +1861,6 @@ Could_not_open_browser.=Konnte_Browser_nicht_öffnen.
Please_open_%0_manually.=Bitte_öffnen_Sie_%0_manuell.
The_link_has_been_copied_to_the_clipboard.=Der_Link_wurde_in_die_Zwischenablage_kopiert.


Open_%0_file=%0_Datei_öffnen

Cannot_delete_file=Datei_kann_nicht_gelöscht_werden.
Expand Down Expand Up @@ -1924,7 +1919,6 @@ Copy_BibTeX_key_and_title=BibTeX-Key_und_Titel_kopieren
File_rename_failed_for_%0_entries.=Dateiumbennung_schlug_ür_%0_Einträge_fehl.
To_set_up,_go_to=Einstellungen_unter
Merged_BibTeX_source_code=BibTeX-Quelltext_zusammengeführt
'%0'_is_not_a_valid_ADS_bibcode.='%0'_ist_kein_gültiger_ADS-Bibcode
Invalid_DOI\:_'%0'.=Ungültiger_DOI\:_'%0'.
should_start_with_a_name=sollte_mit_einem_Name_beginnen
should_end_with_a_name=sollte_mit_einem_Name_enden
Expand Down Expand Up @@ -2158,7 +2152,6 @@ OpenOffice/LibreOffice_integration=OpenOffice/LibreOffice-Integration

incorrect_control_digit=Falsche_Prüfziffer
incorrect_format=Falsches_Format

Copy_version_to_clipboard=Kopiere_Version_in_die_Zwischenablage
Copied_version_to_clipboard=Version_in_die_Zwischenablage_kopiert

Expand Down Expand Up @@ -2303,6 +2296,4 @@ Fetcher_'%0'_did_not_find_an_entry_for_id_'%1'.=Der_Fetcher_%0_hat_keinen_Eintra
Select_first_entry=Ersten_Eintrag_auswählen
Select_last_entry=Letzten_Eintrag_auswählen

Search_in_all_open_databases=

Invalid_ISBN\:_'%0'.=
3 changes: 0 additions & 3 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1771,8 +1771,6 @@ Add_{}_to_specified_title_words_on_search_to_keep_the_correct_case=Add_{}_to_spe
Import_conversions=Import_conversions
Please_enter_a_search_string=Please_enter_a_search_string
Please_open_or_start_a_new_database_before_searching=Please_open_or_start_a_new_database_before_searching
An_error_occurred_while_fetching_from_ADS_(%0)\:=An_error_occurred_while_fetching_from_ADS_(%0)\:
An_error_occurred_while_parsing_abstract=An_error_occurred_while_parsing_abstract
Log=Log

Canceled_merging_entries=Canceled_merging_entries
Expand Down Expand Up @@ -1921,7 +1919,6 @@ Copy_BibTeX_key_and_title=Copy_BibTeX_key_and_title
File_rename_failed_for_%0_entries.=File_rename_failed_for_%0_entries.
To_set_up,_go_to=To_set_up,_go_to
Merged_BibTeX_source_code=Merged_BibTeX_source_code
'%0'_is_not_a_valid_ADS_bibcode.='%0'_is_not_a_valid_ADS_bibcode.
Invalid_DOI\:_'%0'.=Invalid_DOI\:_'%0'.
should_start_with_a_name=should_start_with_a_name
should_end_with_a_name=should_end_with_a_name
Expand Down
Loading