diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java index f917adc6..e4cd5b2d 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java @@ -3,6 +3,7 @@ package eu.dnetlib.openaire.dsm; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -27,13 +28,16 @@ public class DsmAjaxController extends AbstractDnetController { } @GetMapping("/searchByField/{field}/{page}/{size}") - public List searchByField(@PathVariable final String field, @RequestParam final String value) { - return dsmService.searchByField(DsmBrowsableFields.valueOf(field), value); + public Page searchByField(@PathVariable final String field, + @PathVariable final int page, + @PathVariable final int size, + @RequestParam final String value) { + return dsmService.searchByField(DsmBrowsableFields.valueOf(field), value, page, size); } - @GetMapping("/search") - public List search(@RequestParam final String value) { - return dsmService.search(value); + @GetMapping("/search/{page}/{size}") + public Page search(@RequestParam final String value, @PathVariable final int page, @PathVariable final int size) { + return dsmService.search(value, page, size); } } diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java index 468ed568..89a1adcd 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java @@ -479,31 +479,31 @@ public class DsmService { } } - public List searchByField(final DsmBrowsableFields f, final String value) { + public Page searchByField(final DsmBrowsableFields f, final String value, final int page, final int size) { switch (f) { case type: - return simpleDsWithApisRepository.findByType(value); + return simpleDsWithApisRepository.findByType(value, PageRequest.of(page, size)); case collectedfrom: - return simpleDsWithApisRepository.findByCollectedFrom(value); + return simpleDsWithApisRepository.findByCollectedFrom(value, PageRequest.of(page, size)); case compliance: - return simpleDsWithApisRepository.findByCompliance(value); + return simpleDsWithApisRepository.findByCompliance(value, PageRequest.of(page, size)); case country: - return simpleDsWithApisRepository.findByCountry(value); + return simpleDsWithApisRepository.findByCountry(value, PageRequest.of(page, size)); case protocol: - return simpleDsWithApisRepository.findByProtocol(value); + return simpleDsWithApisRepository.findByProtocol(value, PageRequest.of(page, size)); case active: - return simpleDsWithApisRepository.findByActive(Boolean.valueOf(value)); + return simpleDsWithApisRepository.findByActive(Boolean.valueOf(value), PageRequest.of(page, size)); case consenttermsofuse: - return simpleDsWithApisRepository.findByConsenttermsofuse(Boolean.valueOf(value)); + return simpleDsWithApisRepository.findByConsenttermsofuse(Boolean.valueOf(value), PageRequest.of(page, size)); case fulltextdownload: - return simpleDsWithApisRepository.findByFulltextdownload(Boolean.valueOf(value)); + return simpleDsWithApisRepository.findByFulltextdownload(Boolean.valueOf(value), PageRequest.of(page, size)); default: throw new RuntimeException("not implemeted"); @@ -511,8 +511,8 @@ public class DsmService { } - public List search(final String value) { - return simpleDsWithApisRepository.search(value); + public Page search(final String value, final int page, final int size) { + return simpleDsWithApisRepository.search(value, PageRequest.of(page, size)); } } diff --git a/apps/dnet-is-application/src/main/resources/templates/resultsDatasources.html b/apps/dnet-is-application/src/main/resources/templates/resultsDatasources.html index 020115cc..6fbae8a3 100644 --- a/apps/dnet-is-application/src/main/resources/templates/resultsDatasources.html +++ b/apps/dnet-is-application/src/main/resources/templates/resultsDatasources.html @@ -13,17 +13,19 @@ - +
+ +

+ Number of results: {{nResults}}
+ Page: {{currPage}} / {{nPages}} +

- +

-

- Number of APIs: {{(results | filter:apiFilter).length}} -

@@ -87,22 +89,35 @@ diff --git a/libs/dnet-is-common/src/main/java/eu/dnetlib/data/openaire/dsm/repository/SimpleDsWithApisRepository.java b/libs/dnet-is-common/src/main/java/eu/dnetlib/data/openaire/dsm/repository/SimpleDsWithApisRepository.java index 19b4c4cc..c13087d9 100644 --- a/libs/dnet-is-common/src/main/java/eu/dnetlib/data/openaire/dsm/repository/SimpleDsWithApisRepository.java +++ b/libs/dnet-is-common/src/main/java/eu/dnetlib/data/openaire/dsm/repository/SimpleDsWithApisRepository.java @@ -3,6 +3,8 @@ package eu.dnetlib.data.openaire.dsm.repository; import java.util.List; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -17,27 +19,27 @@ import eu.dnetlib.data.openaire.dsm.model.view.SimpleDsWithApis; public interface SimpleDsWithApisRepository extends ReadOnlyRepository, JpaSpecificationExecutor { @Query(value = "select * from dsm_datasources_view where id = :value or name ilike %:value% or other_name ilike %:value%", nativeQuery = true) - List search(@Param("value") String value); + Page search(@Param("value") String value, Pageable pageable); - List findByType(String type); + Page findByType(String type, Pageable pageable); - List findByCollectedFrom(String collectdFrom); + Page findByCollectedFrom(String collectdFrom, Pageable pageable); - List findByConsenttermsofuse(Boolean consenttermsofuse); + Page findByConsenttermsofuse(Boolean consenttermsofuse, Pageable pageable); - List findByFulltextdownload(Boolean fulltextdownload); + Page findByFulltextdownload(Boolean fulltextdownload, Pageable pageable); @Query(value = "select * from dsm_datasources_view where ? = ANY(hidden_compliances)", nativeQuery = true) - List findByCompliance(String compliance); + Page findByCompliance(String compliance, Pageable pageable); @Query(value = "select * from dsm_datasources_view where ? = ANY(hidden_countries)", nativeQuery = true) - List findByCountry(String country); + Page findByCountry(String country, Pageable pageable); @Query(value = "select * from dsm_datasources_view where ? = ANY(hidden_protocols)", nativeQuery = true) - List findByProtocol(String brotocol); + Page findByProtocol(String brotocol, Pageable pageable); @Query(value = "select * from dsm_datasources_view where ? = ANY(hidden_actives)", nativeQuery = true) - List findByActive(Boolean active); + Page findByActive(Boolean active, Pageable pageable); @Query(value = "select type as term, type as name, count(*) as total from dsm_datasources_view group by type order by total desc", nativeQuery = true) List browseTermsForType();