Skip to content

Commit

Permalink
ADS Fetcher using the new fetcher infrastructure (JabRef#1923)
Browse files Browse the repository at this point in the history
* create new fetcher and test

* remove old fetcher

* remove obsolete keys

* add new fetcher in EntryFetchers

* include feedback use BIBTEXPLUS as type

* remove useless curly brackets

* rename test cases

* use IdBasedParserFetcher, update adsfetcher and test, add to entryfetchers

* integrate AdsFetcher into AstrophysicsDataSystem

* fix localization

* modify remove doi pattern and testPerformSearchByIdEmptyDOI

* remove abstract in existing entries and add new without any abstract by default
  • Loading branch information
zesaro committed Oct 27, 2016
1 parent 7f5ae96 commit 01f9783
Show file tree
Hide file tree
Showing 22 changed files with 171 additions and 326 deletions.
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 Down Expand Up @@ -52,6 +51,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.sort((fetcher1, fetcher2) -> fetcher1.getName().compareTo(fetcher2.getName()));
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 @@ -1323,7 +1323,6 @@ Unmark_entries=Fjern_mærkning

Unmark_entry=Fjern_mærkning


untitled=uden_navn

Up=Op
Expand Down Expand Up @@ -1418,6 +1417,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 @@ -1770,8 +1770,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 @@ -1920,7 +1918,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 @@ -2154,8 +2151,6 @@ OpenOffice/LibreOffice_integration=

incorrect_control_digit=
incorrect_format=


Copy_version_to_clipboard=
Copied_version_to_clipboard=

Expand Down Expand Up @@ -2370,8 +2365,6 @@ Fetcher_'%0'_did_not_find_an_entry_for_id_'%1'.=
Select_first_entry=
Select_last_entry=

Search_in_all_open_databases=

Invalid_ISBN\:_'%0'.=

should_be_an_integer_or_normalized=
Expand Down
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 @@ -1323,9 +1323,6 @@ Unmark_entries=Markierung_aufheben

Unmark_entry=Markierung_aufheben




untitled=ohne_Titel

Up=Hoch
Expand Down Expand Up @@ -1420,6 +1417,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 @@ -1772,8 +1770,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 @@ -1864,7 +1860,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 @@ -1923,7 +1918,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 @@ -2157,7 +2151,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 @@ -2366,8 +2359,6 @@ 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'.=

should_be_an_integer_or_normalized=
Expand Down
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 @@ -1769,8 +1769,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 @@ -1919,7 +1917,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

0 comments on commit 01f9783

Please sign in to comment.