Skip to content

Support to render SlicedModel from Slice via a dedicated RepresentationModelAssembler #1307

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
spring-projects-issues opened this issue Apr 12, 2016 · 5 comments
Assignees
Labels
in: web Integration with Spring MVC status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Oliver Drotbohm opened DATACMNS-845 and commented

From the original ticket in Spring HATEOAS:

Sometimes we cannot have information such as the total elements and total pages of a request, that's where we're using a Slice instead of a Page. But the PagedResourcesAssembler does not allow to convert a Slice to a Resource. It would be great to add a toResource(Slice<T> entity) method, or even add SlicedResourcesAssembler class.


Reference URL: spring-projects/spring-hateoas#443

2 votes, 4 watchers

@asjp1970
Copy link

asjp1970 commented Feb 7, 2021

Hi Oliver,
I've seen that the parent issue of this one is closed and this one has remained open for a while, last update being end of last year after nearly 4 years.
I wonder if this has any chance to get into HATEOAS because I am returning pages of a large set of entities and it's becoming a heavy operation over time; a possible improvement would be to return slice... But as we are using HATEOAS we are a bit tied to pages because clients are consuming the hypermedia.
Have checked some of the last release notes and have not seen anything about Slice support: is this still being considered a candidate for your backlog?
Thanks.
/Alberto

@bigjoe-memooria
Copy link

Same issue here: we are exposing a MongoDB collection with 1M+ elements via Spring HATEOAS and Page has become utterly inefficient due to the -useless in this case- total page number called through a count().
A Slice support would perhaps mitigate this huge performance bottleneck.

@odrotbohm
Copy link
Member

As a workaround it should be possible to issue repository methods returning a Slice and adding navigation links pointing to the previous and potentially next slice manually. Wouldn't mind to see such code wrapped into a SliceRepresentationModelAssembler effectively producing a CollectionModel<T> with the aforementioned links added in a pull request.

@odrotbohm odrotbohm added in: web Integration with Spring MVC status: ideal-for-contribution An issue that a contributor can help us with labels Feb 11, 2021
@bigjoe-memooria
Copy link

You're right, will look into it 👍

mschout added a commit to mschout/spring-hateoas that referenced this issue Oct 4, 2022
This is groundwork needed to support SlicedResourcesAssembler<T> in
spring-data-commons.

See spring-projects/spring-data-commons#1307
mschout added a commit to mschout/spring-data-commons that referenced this issue Oct 4, 2022
Added SlicedResourcesAssembler to esaily convert Slice instances into SlicedResource instances and automatically build the required previous/next link based on PageableHandlerMethodArgumentResolver present in the MVC configuration. The assembler can either be injected into a Spring MVC controller or a controller method. The latter will then assume the controller methods URI to be used as pagination link base.

Added necessary SlicedResourcesAssemblerArgumentResolver and MethodParameterAwareSlicedResourcesAssembler classes and wire up HateoasAwareSpringDataWebConfiguration configuration beans to that SlicedResourcesAssembler's can be auto-injected into controllers.

Closes spring-projects#1307
mschout added a commit to mschout/spring-data-commons that referenced this issue Oct 4, 2022
Added SlicedResourcesAssembler to esaily convert Slice instances into SlicedResource instances and automatically build the required previous/next link based on PageableHandlerMethodArgumentResolver present in the MVC configuration. The assembler can either be injected into a Spring MVC controller or a controller method. The latter will then assume the controller methods URI to be used as pagination link base.

Added necessary SlicedResourcesAssemblerArgumentResolver and MethodParameterAwareSlicedResourcesAssembler classes and wire up HateoasAwareSpringDataWebConfiguration configuration beans to that SlicedResourcesAssembler's can be auto-injected into controllers.

Closes spring-projects#1307
@mschout
Copy link
Contributor

mschout commented Oct 4, 2022

This bothered me enough I took a stab at solving it. Added SlicedModel to spring-hateoas and added SlicedResourcesAssembler plus injection to spring-data-commons. The HATEOAS MR needs to get merged first as the resources assembler needs that to be present in hateoas. Hopefully I did everything correctly 🤞

mschout added a commit to mschout/spring-hateoas that referenced this issue Oct 4, 2022
This is groundwork needed to support SlicedResourcesAssembler<T> in spring-data-commons.

See spring-projects/spring-data-commons#1307
mschout added a commit to mschout/spring-hateoas that referenced this issue Oct 4, 2022
This is groundwork needed to support SlicedResourcesAssembler<T> in spring-data-commons.

See spring-projects/spring-data-commons#1307
odrotbohm pushed a commit to spring-projects/spring-hateoas that referenced this issue Feb 28, 2023
In parallel to PagedModel we now provide a SlicedModel. This is groundwork needed to support SlicedResourcesAssembler<T> in spring-data-commons.

Related ticket: spring-projects/spring-data-commons#1307
odrotbohm added a commit that referenced this issue Mar 1, 2023
Imports, Javadoc, ticket references in test cases.

Removed the need for MethodParameterAware… flavors of the ResourceAssemblers by keeping the MethodParameter reference in the original assemblers in the first place. Extracted common Pageable MethodParameter lookup code into PageableMethodParameterUtils.

Related ticket: #1307.
odrotbohm added a commit that referenced this issue Mar 1, 2023
Update to latest addition in support for Slice. Also update to renamed methods and types in Spring HATEOAS.

Related ticket: #1307
@odrotbohm odrotbohm added this to the 3.1 M3 (2023.0.0) milestone Mar 1, 2023
@odrotbohm odrotbohm changed the title Support Slice in the PagedResourcesAssembler [DATACMNS-845] Support to render SlicedModel from Slice via a dedicated RepresentationModelAssembler Mar 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: web Integration with Spring MVC status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants