Back contributions from integrations (MGNLDAM-549)

[MGNLDAM-545] AssetQuery: add offset Created: 16/Feb/15  Updated: 25/Jun/15  Resolved: 05/Jun/15

Status: Closed
Project: Magnolia DAM Module
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1

Type: Sub-task Priority: Neutral
Reporter: Robert Šiška Assignee: Robert Šiška
Resolution: Fixed Votes: 0
Labels: api
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLDAM-546 AssetQuery: add sorting capabilities Closed
dependency
is depended upon by MGNLDAMEXT-32 List view Closed
Template:
Date of First Response:

 Description   

The AssetQuery interface supports specifying the max results but doesn't support the offset, which makes it unusable for paging.

Add AssetQuery#getOffset() and AssetQuery.Builder#withOffset(long offset) methods.

Rationale: it is planned to create jcr-agnostic AssetContainer that serves as bridge between AssetProviders and UI.
Right now, DAM app uses AbstractJcrContainer which uses JCR queries directly.



 Comments   
Comment by Robert Šiška [ 05/Mar/15 ]

Reopened to add pagination capability.

Comment by Magnolia International [ 20/Mar/15 ]

Implementation is fine but lacks specification. Currently the behavior is undefined, so we pretty much let backends do whatever they want, and the client code can't know if different providers will behave differently.

This is the comment I originally left on the concept page:

While I understand the need for pagination, here's the problem I have with adding it right into the query API: different backends might need different parameters:

  • offset (or skip) - similar to what MySQL proposes: you skip N entries, or
  • pageNumber (start at offset*pageSize)
  • startAtItemId
    While the first 2 are relatively compatible (you can easily derive one from the other), this 3rd option has very different semantics: it's requiring that you pass it the ID (UUID or other) of the first item you want in the page, or the last of the previous page, etc etc. All in all, different backends have different paging mechanisms, and some don't have one at all.

So what that means, really, is that you need to define very precisely the expected behaviors of the new params, in your interfaces. (e.g javadoc for getOffset; maxResults is self-descriptive, but offset can mean different things)

It's good that you introduced AssetProviderCapability(ies) for this; I'd suggest they be named queryWithXXX like the previously existing ones, and placed neared the other query-related capabilities.
They should also be checked (otherwise I can create and execute a query with pagination on a provider that doesn't support it?)

Comment by Robert Šiška [ 05/Jun/15 ]

> They should also be checked..
The AssetProvider#list JavaDoc says that it's up to the provider to validate the query. Client can always check the capabilities beforehand to prevent undefined behavior.

Generated at Mon Feb 12 05:00:54 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.