From 23c9a70a472d5dcc9e0810d9a1b645ecd24554ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Mon, 29 May 2023 00:41:26 -0600 Subject: First instance for pagination. Setting filters and sorters and saving them on a list. Then the list can be paginated and returned. --- src/main/java/com/encora/ToDosRepository.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main/java/com/encora/ToDosRepository.java') diff --git a/src/main/java/com/encora/ToDosRepository.java b/src/main/java/com/encora/ToDosRepository.java index 8d09d7e..a4c9a10 100644 --- a/src/main/java/com/encora/ToDosRepository.java +++ b/src/main/java/com/encora/ToDosRepository.java @@ -184,6 +184,19 @@ public class ToDosRepository implements JpaRepository { return comparator; } + + // Filter and then sort all of our to dos. + public void refreshFilteredToDos(Sort sort, String name, String priority, String done) throws Exception { + this.filteredToDos = this.findAllWithFilter(name, priority, done); + + try { + Comparator comparator = this.getToDoComparator(sort); + Collections.sort(this.filteredToDos, comparator); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + /* * N O T Y E T D E F I N E D . */ -- cgit v1.2.3