-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework DBLPFetcher to new structure (#2314)
* Rework DBLPFetcher to new structure - also fixes #2311 * implement as SearchBasedParserFetcher
- Loading branch information
1 parent
64306e4
commit ff550e4
Showing
6 changed files
with
146 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 0 additions & 157 deletions
157
src/main/java/net/sf/jabref/gui/importer/fetcher/DBLPFetcher.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/net/sf/jabref/logic/importer/fetcher/DBLPFetcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
93
src/main/java/net/sf/jabref/logic/importer/util/DBLPHelper.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.