Skip to content

Commit 09d1ed5

Browse files
authored
Reenable running fetcher tests (and update Springer from v1 to v2) (#13798)
* Add comment on Springer * Add TODO * Fix fetcher test running using gradle * Add link to documetnationAdd link to documentation * Refine link * Use meta API v2 instead of v1
1 parent 1616fd2 commit 09d1ed5

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

docs/code-howtos/fetchers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Fetchers are the implementation of the [search using online services](https://do
1212
| [SAO/NASA Astrophysics Data System](https://docs.jabref.org/collect/import-using-online-bibliographic-database#sao-nasa-astrophysics-data-system) | [ADS UI](https://ui.adsabs.harvard.edu/user/settings/token) | `AstrophysicsDataSystemAPIKey` | 5000 calls/day |
1313
| [ScienceDirect](https://www.sciencedirect.com) | | `ScienceDirectApiKey` | |
1414
| [SemanticScholar](https://www.semanticscholar.org/) | <https://www.semanticscholar.org/product/api#api-key-form> | `SemanticScholarApiKey` | |
15-
| [Springer Nature](https://docs.jabref.org/collect/import-using-online-bibliographic-database#springer) | [Springer Nature API Portal](https://dev.springernature.com) | `SpringerNatureAPIKey` | 5000 calls/day |
15+
| [Springer Nature](https://docs.jabref.org/collect/import-using-online-bibliographic-database#springer) | [Springer Nature API Portal](https://dev.springernature.com). Use the "Meta API" API key. | `SpringerNatureAPIKey` | 5000 calls/day |
1616
| [Zentralblatt Math](https://www.zbmath.org) | (none) | (none) | Depending on the current network |
1717
| [Biodiversity Heritage Library](https://www.biodiversitylibrary.org/) | [Biodiversitylibrary](https://about.biodiversitylibrary.org/tools-and-services/developer-and-data-tools/#APIs) | `BiodiversityHeritageApiKey` | - |
1818

jablib/build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,25 +431,30 @@ jmh {
431431
zip64 = true
432432
}
433433

434+
val testSourceSet = sourceSets["test"]
435+
434436
tasks.register<Test>("fetcherTest") {
437+
group = LifecycleBasePlugin.VERIFICATION_GROUP
438+
testClassesDirs = testSourceSet.output.classesDirs
439+
classpath = testSourceSet.runtimeClasspath
435440
useJUnitPlatform {
436441
includeTags("FetcherTest")
437442
}
438-
439443
maxParallelForks = 1
440444
}
441445

442446
tasks.register<Test>("databaseTest") {
447+
group = LifecycleBasePlugin.VERIFICATION_GROUP
448+
testClassesDirs = testSourceSet.output.classesDirs
449+
classpath = testSourceSet.runtimeClasspath
443450
useJUnitPlatform {
444451
includeTags("DatabaseTest")
445452
}
446-
447453
testLogging {
448454
// set options for log level LIFECYCLE
449455
events("FAILED")
450456
exceptionFormat = TestExceptionFormat.FULL
451457
}
452-
453458
maxParallelForks = 1
454459
}
455460

jablib/src/main/java/org/jabref/logic/importer/fetcher/SpringerNatureFullTextFetcher.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class SpringerNatureFullTextFetcher implements FulltextFetcher, Customiza
3131

3232
private static final Logger LOGGER = LoggerFactory.getLogger(SpringerNatureFullTextFetcher.class);
3333

34+
// TODO: Update to the new [fulltext API](https://dev.springernature.com/docs/api-endpoints/fulltext-api/?source=jabref)
35+
// as well as [Open Access API](https://dev.springernature.com/docs/api-endpoints/open-access/?source=jabref)
36+
// Both APIs also [require separate API keys](https://dev.springernature.com/subscription/).
3437
private static final String API_URL = "https://api.springer.com/meta/v1/json";
3538
private static final String CONTENT_HOST = "link.springer.com";
3639

jablib/src/main/java/org/jabref/logic/importer/fetcher/SpringerNatureWebFetcher.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,17 @@
3232
import org.slf4j.Logger;
3333
import org.slf4j.LoggerFactory;
3434

35-
/**
36-
* Fetches data from the Springer
37-
*
38-
* @see <a href="https://dev.springernature.com/">API documentation</a> for more details
39-
*/
35+
/// Fetches data from Springer Nature
36+
///
37+
/// See <https://dev.springernature.com/docs/api-endpoints/meta-api/?source=jabref> for more information
4038
public class SpringerNatureWebFetcher implements PagedSearchBasedParserFetcher, CustomizableKeyFetcher {
4139
public static final String FETCHER_NAME = "Springer";
4240

4341
private static final Logger LOGGER = LoggerFactory.getLogger(SpringerNatureWebFetcher.class);
4442

45-
private static final String API_URL = "https://api.springernature.com/meta/v1/json";
43+
private static final String API_URL = "https://api.springernature.com/meta/v2/json";
4644
// Springer query using the parameter 'q=doi:10.1007/s11276-008-0131-4s=1' will respond faster
47-
private static final String TEST_URL_WITHOUT_API_KEY = "https://api.springernature.com/meta/v1/json?q=doi:10.1007/s11276-008-0131-4s=1&p=1&api_key=";
45+
private static final String TEST_URL_WITHOUT_API_KEY = "https://api.springernature.com/meta/v2/json?q=doi:10.1007/s11276-008-0131-4s=1&p=1&api_key=";
4846

4947
private final ImporterPreferences importerPreferences;
5048

@@ -53,7 +51,7 @@ public SpringerNatureWebFetcher(ImporterPreferences importerPreferences) {
5351
}
5452

5553
/**
56-
* Convert a JSONObject obtained from <a href="http://api.springer.com/metadata/json">http://api.springer.com/metadata/json</a> to a BibEntry
54+
* Convert a JSONObject obtained from <a href="https://dev.springernature.com/docs/api-endpoints/metadata-api/?source=jabref">the Metadata API</a> to a BibEntry
5755
*
5856
* @param springerJsonEntry the JSONObject from search results
5957
* @return the converted BibEntry

jablib/src/main/java/org/jabref/logic/importer/fetcher/transformers/SpringerQueryTransformer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package org.jabref.logic.importer.fetcher.transformers;
22

3-
/**
4-
* This class converts a query string written in lucene syntax into a complex query.
5-
*
6-
* For simplicity this is currently limited to fielded data and the boolean AND operator.
7-
*/
3+
/// This class converts a query string written in lucene syntax into a complex query.
4+
///
5+
/// For simplicity this is currently limited to fielded data and the boolean AND operator.
6+
///
7+
/// See <https://dev.springernature.com/docs/supported-query-params/?source=data-solutions> for a complete list of supported fields.
8+
/// `handleUnFieldedTerm` is not overridden, because the API handles unfielded terms.
89
public class SpringerQueryTransformer extends AbstractQueryTransformer {
910

1011
@Override

0 commit comments

Comments
 (0)