Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.jabref.logic.importer.fetcher.CompositeSearchBasedFetcher;
import org.jabref.logic.importer.fetcher.DBLPFetcher;
import org.jabref.logic.importer.fetcher.IEEE;
import org.jabref.logic.importer.fetcher.SpringerFetcher;
import org.jabref.logic.importer.fetcher.SpringerNatureWebFetcher;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.study.Study;
import org.jabref.model.study.StudyDatabase;
Expand All @@ -48,7 +48,7 @@ public class ManageStudyDefinitionViewModel {
private static final Set<String> DEFAULT_SELECTION = Set.of(
ACMPortalFetcher.FETCHER_NAME,
IEEE.FETCHER_NAME,
SpringerFetcher.FETCHER_NAME,
SpringerNatureWebFetcher.FETCHER_NAME,
DBLPFetcher.FETCHER_NAME);

private final StringProperty title = new SimpleStringProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface FulltextFetcher {
* @return The fulltext PDF URL Optional, if found, or an empty Optional if not found.
* @throws NullPointerException if no BibTex entry is given
* @throws java.io.IOException if an IO operation has failed
* @throws FetcherException if a fetcher specific error occurred
* @throws FetcherException if a fetcher-specific error occurred
*/
Optional<URL> findFullText(BibEntry entry) throws IOException, FetcherException;

Expand Down
10 changes: 5 additions & 5 deletions jablib/src/main/java/org/jabref/logic/importer/WebFetchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.jabref.logic.importer.fetcher.ScholarArchiveFetcher;
import org.jabref.logic.importer.fetcher.ScienceDirect;
import org.jabref.logic.importer.fetcher.SemanticScholar;
import org.jabref.logic.importer.fetcher.SpringerFetcher;
import org.jabref.logic.importer.fetcher.SpringerLink;
import org.jabref.logic.importer.fetcher.SpringerNatureFullTextFetcher;
import org.jabref.logic.importer.fetcher.SpringerNatureWebFetcher;
import org.jabref.logic.importer.fetcher.TitleFetcher;
import org.jabref.logic.importer.fetcher.ZbMATH;
import org.jabref.logic.importer.fetcher.isbntobibtex.IsbnFetcher;
Expand Down Expand Up @@ -118,7 +118,7 @@ public static SortedSet<SearchBasedFetcher> getSearchBasedFetchers(ImportFormatP
set.add(new ACMPortalFetcher());
// set.add(new GoogleScholar(importFormatPreferences));
set.add(new DBLPFetcher(importFormatPreferences));
set.add(new SpringerFetcher(importerPreferences));
set.add(new SpringerNatureWebFetcher(importerPreferences));
set.add(new CrossRef());
set.add(new CiteSeer());
set.add(new DOAJFetcher(importFormatPreferences));
Expand Down Expand Up @@ -209,7 +209,7 @@ public static Set<FulltextFetcher> getFullTextFetchers(ImportFormatPreferences i

// Publishers
fetchers.add(new ScienceDirect(importerPreferences));
fetchers.add(new SpringerLink(importerPreferences));
fetchers.add(new SpringerNatureFullTextFetcher(importerPreferences));
fetchers.add(new ACS());
fetchers.add(new ArXivFetcher(importFormatPreferences));
fetchers.add(new IEEE(importFormatPreferences, importerPreferences));
Expand All @@ -232,7 +232,7 @@ public static Set<FulltextFetcher> getFullTextFetchers(ImportFormatPreferences i
public static Set<CustomizableKeyFetcher> getCustomizableKeyFetchers(ImportFormatPreferences importFormatPreferences, ImporterPreferences importerPreferences) {
Set<CustomizableKeyFetcher> fetchers = new HashSet<>();
fetchers.add(new IEEE(importFormatPreferences, importerPreferences));
fetchers.add(new SpringerFetcher(importerPreferences));
fetchers.add(new SpringerNatureWebFetcher(importerPreferences));
fetchers.add(new ScienceDirect(importerPreferences));
fetchers.add(new AstrophysicsDataSystem(importFormatPreferences, importerPreferences));
fetchers.add(new BiodiversityLibrary(importerPreferences));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import org.jabref.logic.importer.WebFetcher;

/// Fetchers implementing this interface support customizable keys
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment uses triple forward slashes (///) which is not a standard Java documentation style. JavaDoc comments should use /** */ format for better documentation support and IDE integration.

public interface CustomizableKeyFetcher extends WebFetcher {

/// Returns an URL for testing a key
///
/// The key is appended at the URL
Comment on lines +8 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-standard comment style using triple forward slashes. Additionally, the comment merely restates what's obvious from the method name and parameter, providing no additional information.

///
/// @return null if key validity checking is not supported
default String getTestUrl() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
* <p>
* Uses Springer API, see <a href="https://dev.springer.com">https://dev.springer.com</a>
*/
public class SpringerLink implements FulltextFetcher, CustomizableKeyFetcher {
public class SpringerNatureFullTextFetcher implements FulltextFetcher, CustomizableKeyFetcher {
public static final String FETCHER_NAME = "Springer";

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

private static final String API_URL = "https://api.springer.com/meta/v1/json";
private static final String CONTENT_HOST = "link.springer.com";

private final ImporterPreferences importerPreferences;

public SpringerLink(ImporterPreferences importerPreferences) {
public SpringerNatureFullTextFetcher(ImporterPreferences importerPreferences) {
this.importerPreferences = importerPreferences;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
*
* @see <a href="https://dev.springernature.com/">API documentation</a> for more details
*/
public class SpringerFetcher implements PagedSearchBasedParserFetcher, CustomizableKeyFetcher {
public class SpringerNatureWebFetcher implements PagedSearchBasedParserFetcher, CustomizableKeyFetcher {
public static final String FETCHER_NAME = "Springer";

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

private static final String API_URL = "https://api.springernature.com/meta/v1/json";
// Springer query using the parameter 'q=doi:10.1007/s11276-008-0131-4s=1' will respond faster
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=";

private final ImporterPreferences importerPreferences;

public SpringerFetcher(ImporterPreferences importerPreferences) {
public SpringerNatureWebFetcher(ImporterPreferences importerPreferences) {
this.importerPreferences = importerPreferences;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import org.jabref.logic.importer.fetcher.IEEE;
import org.jabref.logic.importer.fetcher.MrDlibPreferences;
import org.jabref.logic.importer.fetcher.ScienceDirect;
import org.jabref.logic.importer.fetcher.SpringerFetcher;
import org.jabref.logic.importer.fetcher.SpringerNatureWebFetcher;
import org.jabref.logic.importer.fetcher.citation.semanticscholar.SemanticScholarCitationFetcher;
import org.jabref.logic.importer.fileformat.CustomImporter;
import org.jabref.logic.importer.plaincitation.PlainCitationParserChoice;
Expand Down Expand Up @@ -520,7 +520,7 @@ public JabRefCliPreferences() {
defaults.put(SEARCH_WINDOW_DIVIDER_POS, 0.5);
defaults.put(SEARCH_CATALOGS, convertListToString(List.of(
ACMPortalFetcher.FETCHER_NAME,
SpringerFetcher.FETCHER_NAME,
SpringerNatureWebFetcher.FETCHER_NAME,
DBLPFetcher.FETCHER_NAME,
IEEE.FETCHER_NAME)));
defaults.put(DEFAULT_PLAIN_CITATION_PARSER, PlainCitationParserChoice.RULE_BASED.name());
Expand Down Expand Up @@ -2322,7 +2322,7 @@ private Map<String, String> getDefaultFetcherKeys() {
keys.put(AstrophysicsDataSystem.FETCHER_NAME, buildInfo.astrophysicsDataSystemAPIKey);
keys.put(BiodiversityLibrary.FETCHER_NAME, buildInfo.biodiversityHeritageApiKey);
keys.put(ScienceDirect.FETCHER_NAME, buildInfo.scienceDirectApiKey);
keys.put(SpringerFetcher.FETCHER_NAME, buildInfo.springerNatureAPIKey);
keys.put(SpringerNatureWebFetcher.FETCHER_NAME, buildInfo.springerNatureAPIKey);
// SpringerLink uses the same key and fetcher name as SpringerFetcher

return keys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static Stream<Arguments> performSearchParameters() {
when(importerPreferences.getApiKey(eq(SemanticScholarCitationFetcher.FETCHER_NAME))).thenReturn(Optional.of(buildInfo.semanticScholarApiKey));
when(importerPreferences.getApiKey(eq(BiodiversityLibrary.FETCHER_NAME))).thenReturn(Optional.of(buildInfo.biodiversityHeritageApiKey));
when(importerPreferences.getApiKey(eq(ScienceDirect.FETCHER_NAME))).thenReturn(Optional.of(buildInfo.scienceDirectApiKey));
when(importerPreferences.getApiKey(eq(SpringerFetcher.FETCHER_NAME))).thenReturn(Optional.of(buildInfo.springerNatureAPIKey));
when(importerPreferences.getApiKey(eq(SpringerNatureWebFetcher.FETCHER_NAME))).thenReturn(Optional.of(buildInfo.springerNatureAPIKey));
when(importerPreferences.getApiKey(eq(IEEE.FETCHER_NAME))).thenReturn(Optional.of(buildInfo.ieeeAPIKey));

List<Set<SearchBasedFetcher>> fetcherParameters = new ArrayList<>();
Expand All @@ -130,7 +130,7 @@ static Stream<Arguments> performSearchParameters() {
new ZbMATH(importFormatPreferences),
new GoogleScholar(importFormatPreferences),
new DBLPFetcher(importFormatPreferences),
new SpringerFetcher(importerPreferences),
new SpringerNatureWebFetcher(importerPreferences),
new CrossRef(),
new CiteSeer(),
new DOAJFetcher(importFormatPreferences),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
import static org.mockito.Mockito.when;

@FetcherTest
class SpringerLinkTest {
class SpringerNatureFullTextFetcherTest {

private final ImporterPreferences importerPreferences = mock(ImporterPreferences.class);
private SpringerLink finder;
private SpringerNatureFullTextFetcher finder;
private BibEntry entry;

@BeforeEach
void setUp() {
Optional<String> apiKey = Optional.of(new BuildInfo().springerNatureAPIKey);
when(importerPreferences.getApiKey(SpringerLink.FETCHER_NAME)).thenReturn(apiKey);
when(importerPreferences.getApiKey(SpringerNatureFullTextFetcher.FETCHER_NAME)).thenReturn(apiKey);
when(importerPreferences.getApiKeys()).thenReturn(FXCollections.emptyObservableSet());
finder = new SpringerLink(importerPreferences);
finder = new SpringerNatureFullTextFetcher(importerPreferences);
entry = new BibEntry();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import static org.mockito.Mockito.when;

@FetcherTest
class SpringerFetcherTest implements SearchBasedFetcherCapabilityTest, PagedSearchFetcherTest {
class SpringerNatureWebFetcherTest implements SearchBasedFetcherCapabilityTest, PagedSearchFetcherTest {

ImporterPreferences importerPreferences = mock(ImporterPreferences.class);
SpringerFetcher fetcher;
SpringerNatureWebFetcher fetcher;

@BeforeEach
void setUp() {
BuildInfo buildInfo = Injector.instantiateModelOrService(BuildInfo.class);
fetcher = new SpringerFetcher(importerPreferences);
fetcher = new SpringerNatureWebFetcher(importerPreferences);
when(importerPreferences.getApiKeys()).thenReturn(FXCollections.emptyObservableSet());
when(importerPreferences.getApiKey(fetcher.getName())).thenReturn(Optional.of(buildInfo.springerNatureAPIKey));
}
Expand Down Expand Up @@ -159,7 +159,7 @@ void springerJSONToBibtex() {
}""";

JSONObject jsonObject = new JSONObject(jsonString);
BibEntry bibEntry = SpringerFetcher.parseSpringerJSONtoBibtex(jsonObject);
BibEntry bibEntry = SpringerNatureWebFetcher.parseSpringerJSONtoBibtex(jsonObject);
assertEquals(Optional.of("1992"), bibEntry.getField(StandardField.YEAR));
assertEquals(Optional.of("5"), bibEntry.getField(StandardField.NUMBER));
assertEquals(Optional.of("#sep#"), bibEntry.getField(StandardField.MONTH));
Expand Down