Class PaginationServiceImpl

    • Constructor Detail

      • PaginationServiceImpl

        @Autowired
        public PaginationServiceImpl​(LinkService linkService)
    • Method Detail

      • getPage

        @NotNull
        public <W,​T extends AbstractRestModel> @NotNull RestPageModel<T> getPage​(@NotNull
                                                                                       @NotNull Iterable<W> input,
                                                                                       @NotNull
                                                                                       @NotNull PageRequest pageRequest,
                                                                                       @NotNull
                                                                                       @NotNull Expansion expansion,
                                                                                       @NotNull
                                                                                       @NotNull javax.ws.rs.core.UriInfo uriInfo,
                                                                                       @NotNull
                                                                                       @NotNull RestConversionFunction<? super W,​T> transformer)
        Description copied from interface: PaginationService

        Transforms a list of domain objects to AbstractRestModels and constructs a RestPageModel from the result. Assumes input is the full list of possible objects. Will only transform the required number of objects as defined by the PageRequest. The RestPageModel will include page links.

        DO NOT USE FOR EXPANDED PAGES

        This method assumes the uriInfo represents the page being requested and uses it to construct the page's self link. Use PaginationService.getPage(Iterable, PageRequest, Expansion, UriInfo, RestConversionFunction, String) to specify the page location if the current request does not represent the page being transformed (e.g. resource expansion may need to construct a page of sub-resources).

        Specified by:
        getPage in interface PaginationService
        Type Parameters:
        W - domain object
        T - rest object
        Parameters:
        input - full list of domain objects
        pageRequest - which page of information required
        expansion - The expansion to use when transforming the objects
        uriInfo - URI info from the request used to construct the page's self link
        transformer - to convert domain object into rest object
        Returns:
        Single page of rest objects
      • getPage

        @NotNull
        public <W,​T extends AbstractRestModel> @NotNull RestPageModel<T> getPage​(@NotNull
                                                                                       @NotNull Stream<W> input,
                                                                                       @NotNull
                                                                                       @NotNull PageRequest pageRequest,
                                                                                       @NotNull
                                                                                       @NotNull Expansion expansion,
                                                                                       @NotNull
                                                                                       @NotNull javax.ws.rs.core.UriInfo uriInfo,
                                                                                       @NotNull
                                                                                       @NotNull RestConversionFunction<? super W,​T> transformer)
        Description copied from interface: PaginationService

        Transforms a list of domain objects to AbstractRestModels and constructs a RestPageModel from the result. Assumes input is the full list of possible objects. Will only transform the required number of objects as defined by the PageRequest. The RestPageModel will include page links.

        DO NOT USE FOR EXPANDED PAGES

        This method assumes the uriInfo represents the page being requested and uses it to construct the page's self link. Use PaginationService.getPage(Iterable, PageRequest, Expansion, UriInfo, RestConversionFunction, String) to specify the page location if the current request does not represent the page being transformed (e.g. resource expansion may need to construct a page of sub-resources).

        Specified by:
        getPage in interface PaginationService
        Type Parameters:
        W - domain object
        T - rest object
        Parameters:
        input - full list of domain objects
        pageRequest - which page of information required
        expansion - The expansion to use when transforming the objects
        uriInfo - URI info from the request used to construct the page's self link
        transformer - to convert domain object into rest object
        Returns:
        Single page of rest objects
      • getPage

        @NotNull
        public <W,​T extends AbstractRestModel> @NotNull RestPageModel<T> getPage​(@NotNull
                                                                                       @NotNull Iterable<W> input,
                                                                                       @NotNull
                                                                                       @NotNull PageRequest pageRequest,
                                                                                       @NotNull
                                                                                       @NotNull Expansion expansion,
                                                                                       @NotNull
                                                                                       @NotNull javax.ws.rs.core.UriInfo uriInfo,
                                                                                       @NotNull
                                                                                       @NotNull RestConversionFunction<? super W,​T> transformer,
                                                                                       @NotNull
                                                                                       @NotNull String pageLocation)
        Description copied from interface: PaginationService
        Transforms a list of domain objects to AbstractRestModels and constructs a RestPageModel from the result. Assumes input is the full list of possible objects. Will only transform the required number of objects as defined by the PageRequest. The RestPageModel will include page links.
        Specified by:
        getPage in interface PaginationService
        Type Parameters:
        W - domain object
        T - rest object
        Parameters:
        input - full list of domain objects
        pageRequest - which page of information required
        expansion - The expansion to use when transforming the objects
        uriInfo - URI info from the request
        transformer - to convert domain object into rest object
        pageLocation - The relative URI path used to construct the page's self link
        Returns:
        Single page of rest objects
      • getPage

        @NotNull
        public <W,​T extends AbstractRestModel> @NotNull RestPageModel<T> getPage​(@NotNull
                                                                                       @NotNull Stream<W> input,
                                                                                       @NotNull
                                                                                       @NotNull PageRequest pageRequest,
                                                                                       @NotNull
                                                                                       @NotNull Expansion expansion,
                                                                                       @NotNull
                                                                                       @NotNull javax.ws.rs.core.UriInfo uriInfo,
                                                                                       @NotNull
                                                                                       @NotNull RestConversionFunction<? super W,​T> transformer,
                                                                                       @NotNull
                                                                                       @NotNull String pageLocation)
        Description copied from interface: PaginationService
        Transforms a list of domain objects to AbstractRestModels and constructs a RestPageModel from the result. Assumes input is the full list of possible objects. Will only transform the required number of objects as defined by the PageRequest. The RestPageModel will include page links.
        Specified by:
        getPage in interface PaginationService
        Type Parameters:
        W - domain object
        T - rest object
        Parameters:
        input - full list of domain objects
        pageRequest - which page of information required
        expansion - The expansion to use when transforming the objects
        uriInfo - URI info from the request
        transformer - to convert domain object into rest object
        pageLocation - The relative URI path used to construct the page's self link
        Returns:
        Single page of rest objects
      • getExpandablePage

        @NotNull
        public <T extends AbstractRestModel> @NotNull RestPageModel<T> getExpandablePage​(@NotNull
                                                                                         @NotNull PageRequest pageRequest,
                                                                                         @NotNull
                                                                                         @NotNull javax.ws.rs.core.UriInfo uriInfo,
                                                                                         @NotNull
                                                                                         @NotNull String pageLocation)
        Description copied from interface: PaginationService
        Constructs a RestPageModel which is an empty page with a self link.
        Specified by:
        getExpandablePage in interface PaginationService
        Type Parameters:
        T - rest object
        Parameters:
        pageRequest - which page of information required
        uriInfo - URI info from the request
        pageLocation - The relative URI path used to construct the page's self link
        Returns:
        Empty page with self link
      • transformPage

        @NotNull
        public <W,​T extends AbstractRestModel> @NotNull RestPageModel<T> transformPage​(@NotNull
                                                                                             @NotNull PageRequest pageRequest,
                                                                                             @NotNull
                                                                                             @NotNull Expansion expansion,
                                                                                             @NotNull
                                                                                             @NotNull javax.ws.rs.core.UriInfo uriInfo,
                                                                                             @NotNull
                                                                                             @NotNull RestConversionFunction<? super W,​T> transformer,
                                                                                             @NotNull
                                                                                             @NotNull Function<Integer,​Collection<W>> daoFunction)
        Description copied from interface: PaginationService

        Gets paginated set of objects from database and transforms to AbstractRestModels and constructs a RestPageModel. The RestPageModel will include page links.

        This method assumes the uriInfo represents the page being requested and uses it to construct the page's self link.

        Specified by:
        transformPage in interface PaginationService
        Type Parameters:
        W - domain object
        T - rest object
        Parameters:
        pageRequest - which page of information required
        expansion - The expansion to use when transforming the objects
        uriInfo - URI info from the request used to construct the page's self link
        transformer - to convert domain object into rest object
        daoFunction - function which allows get subset of objects from database. Takes limit arg to define max length of the subset.
        Returns:
        Single page of rest objects