-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6236 from JabRef/pagedFetcher
- Loading branch information
Showing
6 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/org/jabref/logic/importer/PagedSearchBasedFetcher.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,21 @@ | ||
package org.jabref.logic.importer; | ||
|
||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.paging.Page; | ||
|
||
public interface PagedSearchBasedFetcher extends SearchBasedFetcher { | ||
|
||
/** | ||
* @param query search query send to endpoint | ||
* @param pageNumber requested site number | ||
* @return Page with search results | ||
*/ | ||
Page<BibEntry> performSearchPaged(String query, int pageNumber) throws FetcherException; | ||
|
||
/** | ||
* @return default pageSize | ||
*/ | ||
default int getPageSize() { | ||
return 20; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/jabref/logic/importer/PagedSearchBasedParserFetcher.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,16 @@ | ||
package org.jabref.logic.importer; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
public interface PagedSearchBasedParserFetcher extends SearchBasedParserFetcher, PagedSearchBasedFetcher { | ||
|
||
/** | ||
* Constructs a URL based on the query, size and page number. | ||
* @param query the search query | ||
* @param size the size of the page | ||
* @param pageNumber the number of the page | ||
* */ | ||
URL getURLForQuery(String query, int size, int pageNumber) throws URISyntaxException, MalformedURLException, FetcherException; | ||
} |
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
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,37 @@ | ||
package org.jabref.model.paging; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
public class Page<T> { | ||
|
||
private int pageNumber; | ||
private String query; | ||
private Collection<T> content; | ||
|
||
public Page(String query, int pageNumber, Collection<T> content) { | ||
this.query = query; | ||
this.pageNumber = pageNumber; | ||
this.content = Collections.unmodifiableCollection(content); | ||
} | ||
|
||
public Page(String query, int pageNumber) { | ||
this(query, pageNumber, Collections.emptyList()); | ||
} | ||
|
||
public Collection<T> getContent() { | ||
return content; | ||
} | ||
|
||
public int getPageNumber() { | ||
return pageNumber; | ||
} | ||
|
||
public String getQuery() { | ||
return query; | ||
} | ||
|
||
public int getSize() { | ||
return content.size(); | ||
} | ||
} |
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
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