Commit 57b981e7 authored by Matija Obreza's avatar Matija Obreza

Pagination utility respects incoming maxPageSize

- /api/v0/datasets/../accessions lists up to 1000 entries
parent 596317d0
...@@ -151,7 +151,7 @@ public class Pagination { ...@@ -151,7 +151,7 @@ public class Pagination {
* @return the pageable * @return the pageable
*/ */
public Pageable toPageRequest(int maxPageSize) { public Pageable toPageRequest(int maxPageSize) {
return new PageRequest(p == null ? 0 : p, Integer.min(l == null ? 100 : l, maxPageSize), getDirection(Sort.Direction.ASC), getSortProperties(DEFAULT_SORT_PROPERTIES)); return new PageRequest(p == null ? 0 : p, Integer.min(l == null ? maxPageSize : l, maxPageSize), getDirection(Sort.Direction.ASC), getSortProperties(DEFAULT_SORT_PROPERTIES));
} }
/** /**
...@@ -163,7 +163,7 @@ public class Pagination { ...@@ -163,7 +163,7 @@ public class Pagination {
* @return the pageable * @return the pageable
*/ */
public Pageable toPageRequest(int maxPageSize, Direction defaultDir, String... defaultSort) { public Pageable toPageRequest(int maxPageSize, Direction defaultDir, String... defaultSort) {
return new PageRequest(p == null ? 0 : p, Integer.min(l == null ? 100 : l, maxPageSize), getDirection(defaultDir), getSortProperties(defaultSort)); return new PageRequest(p == null ? 0 : p, Integer.min(l == null ? maxPageSize : l, maxPageSize), getDirection(defaultDir), getSortProperties(defaultSort));
} }
/** /**
...@@ -174,7 +174,7 @@ public class Pagination { ...@@ -174,7 +174,7 @@ public class Pagination {
* @return the pageable * @return the pageable
*/ */
public static Pageable toPageRequest(int maxPageSize, Sort sort) { public static Pageable toPageRequest(int maxPageSize, Sort sort) {
return new PageRequest(0, Integer.min(100, maxPageSize), sort); return new PageRequest(0, maxPageSize, sort);
} }
} }
...@@ -141,7 +141,7 @@ public class DatasetController extends ApiBaseController { ...@@ -141,7 +141,7 @@ public class DatasetController extends ApiBaseController {
*/ */
@GetMapping("/{metadataId}/accessions") @GetMapping("/{metadataId}/accessions")
public Page<AccessionRef> listAccessions(@PathVariable("metadataId") long metadataId, Pagination pagination) { public Page<AccessionRef> listAccessions(@PathVariable("metadataId") long metadataId, Pagination pagination) {
return genesysService.listMetadataAccessionRefs(metadataId, pagination.toPageRequest(50, Direction.ASC, "a.id")); return genesysService.listMetadataAccessionRefs(metadataId, pagination.toPageRequest(1000, Direction.ASC, "a.id"));
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment