forked from blcham/record-manager
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #2 from akaene/record-manager-ui#71-filtering-pagi…
…ng-sorting Record manager UI#71 filtering paging sorting
- Loading branch information
Showing
22 changed files
with
965 additions
and
174 deletions.
There are no files selected for viewing
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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/cz/cvut/kbss/study/persistence/dao/util/RecordSort.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,36 @@ | ||
package cz.cvut.kbss.study.persistence.dao.util; | ||
|
||
import org.springframework.data.domain.Sort; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Provides constants for sorting records. | ||
*/ | ||
public class RecordSort { | ||
|
||
/** | ||
* Property used to sort records by date of last modification (if available) or creation. | ||
*/ | ||
public static final String SORT_DATE_PROPERTY = "date"; | ||
|
||
/** | ||
* Supported sorting properties. | ||
*/ | ||
public static final Set<String> SORTING_PROPERTIES = Set.of(SORT_DATE_PROPERTY); | ||
|
||
private RecordSort() { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Returns the default sort for retrieving records. | ||
* <p> | ||
* By default, records are sorted by date of last modification/creation in descending order. | ||
* | ||
* @return Default sort | ||
*/ | ||
public static Sort defaultSort() { | ||
return Sort.by(Sort.Order.desc("date")); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/java/cz/cvut/kbss/study/rest/event/PaginatedResultRetrievedEvent.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,37 @@ | ||
package cz.cvut.kbss.study.rest.event; | ||
|
||
import jakarta.servlet.http.HttpServletResponse; | ||
import org.springframework.context.ApplicationEvent; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
/** | ||
* Fired when a paginated result is retrieved by a REST controller, so that HATEOAS headers can be added to the | ||
* response. | ||
*/ | ||
public class PaginatedResultRetrievedEvent extends ApplicationEvent { | ||
|
||
private final UriComponentsBuilder uriBuilder; | ||
private final HttpServletResponse response; | ||
private final Page<?> page; | ||
|
||
public PaginatedResultRetrievedEvent(Object source, UriComponentsBuilder uriBuilder, HttpServletResponse response, | ||
Page<?> page) { | ||
super(source); | ||
this.uriBuilder = uriBuilder; | ||
this.response = response; | ||
this.page = page; | ||
} | ||
|
||
public UriComponentsBuilder getUriBuilder() { | ||
return uriBuilder; | ||
} | ||
|
||
public HttpServletResponse getResponse() { | ||
return response; | ||
} | ||
|
||
public Page<?> getPage() { | ||
return page; | ||
} | ||
} |
Oops, something went wrong.