Skip to content

Commit

Permalink
Rework DBLPFetcher to new structure (#2314)
Browse files Browse the repository at this point in the history
* Rework DBLPFetcher to new structure - also fixes #2311

* implement as SearchBasedParserFetcher
  • Loading branch information
matthiasgeiger committed Nov 26, 2016
1 parent 64306e4 commit ff550e4
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 251 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue which prevented that a database was saved successfully if JabRef failed to generate new BibTeX-keys [#2285](https://github.com/JabRef/jabref/issues/2285).
- We fixed an issue when JabRef restores its session and a shared database was used: The error message "No suitable driver found" will not appear.
- Update check now correctly notifies about new release if development version is used. [#2298](https://github.com/JabRef/jabref/issues/2298)
- Fixed [#2311](https://github.com/JabRef/jabref/issues/2311): The DBLP fetcher has been rewritten and is working again.

### Removed

Expand Down
157 changes: 0 additions & 157 deletions src/main/java/net/sf/jabref/gui/importer/fetcher/DBLPFetcher.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.sf.jabref.logic.importer.IdBasedFetcher;
import net.sf.jabref.logic.importer.fetcher.ArXiv;
import net.sf.jabref.logic.importer.fetcher.AstrophysicsDataSystem;
import net.sf.jabref.logic.importer.fetcher.DBLPFetcher;
import net.sf.jabref.logic.importer.fetcher.DiVA;
import net.sf.jabref.logic.importer.fetcher.DoiFetcher;
import net.sf.jabref.logic.importer.fetcher.GoogleScholar;
Expand All @@ -25,7 +26,7 @@ public class EntryFetchers {

public EntryFetchers(JournalAbbreviationLoader abbreviationLoader) {
entryFetchers.add(new CiteSeerXFetcher());
entryFetchers.add(new DBLPFetcher());
entryFetchers.add(new SearchBasedEntryFetcher(new DBLPFetcher(Globals.prefs.getImportFormatPreferences())));
entryFetchers.add(new IEEEXploreFetcher(abbreviationLoader));
entryFetchers.add(new INSPIREFetcher());
// entryFetchers.add(new OAI2Fetcher()); - new arXiv fetcher in place, see below
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package net.sf.jabref.logic.importer.fetcher;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Objects;

import net.sf.jabref.logic.cleanup.DoiCleanup;
import net.sf.jabref.logic.formatter.bibtexfields.ClearFormatter;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.importer.FetcherException;
import net.sf.jabref.logic.importer.ImportFormatPreferences;
import net.sf.jabref.logic.importer.Parser;
import net.sf.jabref.logic.importer.SearchBasedParserFetcher;
import net.sf.jabref.logic.importer.fileformat.BibtexParser;
import net.sf.jabref.model.cleanup.FieldFormatterCleanup;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;

import org.apache.http.client.utils.URIBuilder;

/**
* Fetches BibTeX data from DBLP (dblp.org)
*
* @see <a href="http://dblp.dagstuhl.de/faq/13501473">Basic API documentation</a>
*/
public class DBLPFetcher implements SearchBasedParserFetcher {

private static final String BASIC_SEARCH_URL = "http://www.dblp.org/search/api/";

private final ImportFormatPreferences importFormatPreferences;

public DBLPFetcher(ImportFormatPreferences importFormatPreferences) {
Objects.requireNonNull(importFormatPreferences);

this.importFormatPreferences = importFormatPreferences;
}

@Override
public URL getURLForQuery(String query) throws URISyntaxException, MalformedURLException, FetcherException {
URIBuilder uriBuilder = new URIBuilder(BASIC_SEARCH_URL);
uriBuilder.addParameter("q", query);
uriBuilder.addParameter("h", String.valueOf(100)); // number of hits
uriBuilder.addParameter("c", String.valueOf(0)); // no need for auto-completion
uriBuilder.addParameter("f", String.valueOf(0)); // "from", index of first hit to download
uriBuilder.addParameter("format", "bib1");

return uriBuilder.build().toURL();
}

@Override
public Parser getParser() {
return new BibtexParser(importFormatPreferences);
}

@Override
public void doPostCleanup(BibEntry entry) {
DoiCleanup doiCleaner = new DoiCleanup();

FieldFormatterCleanup clearTimestampFormatter = new FieldFormatterCleanup(FieldName.TIMESTAMP,
new ClearFormatter());

doiCleaner.cleanup(entry);
clearTimestampFormatter.cleanup(entry);

}

@Override
public String getName() {
return "DBLP";
}

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

}
93 changes: 0 additions & 93 deletions src/main/java/net/sf/jabref/logic/importer/util/DBLPHelper.java

This file was deleted.

Loading

0 comments on commit ff550e4

Please sign in to comment.