You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Dan Haywood (JIRA)" <ji...@apache.org> on 2017/06/02 13:40:04 UTC

[jira] [Updated] (ISIS-1598) Extend RO API to handle pagination parameter

     [ https://issues.apache.org/jira/browse/ISIS-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Haywood updated ISIS-1598:
------------------------------
    Fix Version/s:     (was: 1.16.0)
                   1.18.0

> Extend RO API to handle pagination parameter
> --------------------------------------------
>
>                 Key: ISIS-1598
>                 URL: https://issues.apache.org/jira/browse/ISIS-1598
>             Project: Isis
>          Issue Type: New Feature
>          Components: Core: Viewer: RestfulObjects
>    Affects Versions: 1.14.0
>            Reporter: Dan Haywood
>             Fix For: 1.18.0
>
>
> as per https://lists.apache.org/thread.html/9e663076e7af01a7cbc625a0046b62c13d533fb89df1f395f5078457@%3Cusers.isis.apache.org%3E
> {code}
> We are mostly using Restful Objects. 
> We were able to do this type of pagination on Action, by modifying the "ObjectActionArgHelper.java" to populate the pagination details.
> On method: public List<ObjectAdapter> parseAndValidateArguments(final JsonRepresentation arguments) {...}
> // Handle page parameters
> if (paramSpec.getCorrespondingClass() == Pageable.class
> && argRepr != null
> /*&& argRepr.mapHas("value")
> && !argRepr.isNull("value")*/) {
> /*final JsonRepresentation token = argRepr.getRepresentation("value");
> final String tokenAsString = token.asString();*/
> final PageRequest pageRequest;
> if (argRepr.getString("sort") != null) {
> final String[] split = argRepr.getString("sort").split(": ");
> final Sort.Direction dir = Sort.Direction.fromStringOrNull(split[1]);
> pageRequest = new PageRequest(Integer.parseInt(argRepr.getString("pageNumber")),
> Integer.parseInt(argRepr.getString("pageSize")),
> new Sort(dir, split[0]));
> } else {
> pageRequest = new PageRequest(Integer.parseInt(argRepr.getString("pageNumber")),
> Integer.parseInt(argRepr.getString("pageSize")));
> }
> if (pageRequest != null) {
> // Encode pageable. This shall be deserialized later on.
> final ObjectAdapter adapter = getPersistenceSession().adapterFor(pageRequest);
> final EncodableFacet encodableFacet = paramSpec.getFacet(EncodableFacet.class);
> argRepr = JsonRepresentation.newMap();
> argRepr.mapPut("value", encodableFacet.toEncodedString(adapter));
> } else {
> // No file for given token; throw error
> final String reason = "There is something wrong with your page parameters.";
> argRepr.mapPut("invalidReason", reason);
> throw new IllegalArgumentException(reason);
> }
> }
> What we are thinking for the implementation:
> METHOD 1: Modify the existing metamodels.
> 1. On "ObjectCollectionReprRenderer.java" [1], we are thinking that we can insert Pageable arguments to this line
> 2. On " ObjectAssociation.java" [2], we might end up changing this line as well to accept Pageable parameter. 
> METHOD 2: Create new metamodels which extends the existing metamodels.
> As mention, we are able to do this on Actions. And our intent to do this as well on Collections.
> We might as well asks for your suggestion on how to do this Dan or if there are any better implementation for this one.
> [1] https://github.com/apache/isis/blob/master/core/viewer-restfulobjects-rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/ObjectCollectionReprRenderer.java#L84
> [2] https://github.com/apache/isis/blob/master/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAssociation.java#L67 
> Thanks and best regards,
> Arjun Gica Manipes
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)