Package org.candlepin.paging

Examples of org.candlepin.paging.PageRequest


            pool.setStartDate(TestUtil.createDate(2011, 1, 2));
            pool.setEndDate(TestUtil.createDate(2011, 3, 2));
            poolCurator.create(pool);
        }

        PageRequest req = new PageRequest();
        req.setPage(1);
        req.setPerPage(10);

        Date activeOn = TestUtil.createDate(2011, 2, 2);
        Page<List<Pool>> page = poolCurator.listAvailableEntitlementPools(
            null, owner, product.getId(), activeOn, false, new PoolFilterBuilder(),
            req, false);
View Full Code Here


        Set<String> types = new HashSet<String>();
        types.add("type");
        consumerTypeCurator.create(new ConsumerType("type"));

        List<Consumer> results = ownerResource.listConsumers(
            owner.getKey(), "username", types, uuids, null, null, new PageRequest());

        assertEquals(0, results.size());
    }
View Full Code Here

        assertEquals(2, ents.size());
    }

    @Test
    public void testListByConsumerAndProduct() {
        PageRequest req = new PageRequest();
        req.setPage(1);
        req.setPerPage(10);
        req.setOrder(PageRequest.Order.ASCENDING);
        req.setSortBy("id");

        Product product = TestUtil.createProduct();
        productCurator.create(product);

        Pool pool = createPoolAndSub(owner, product, 1L,
View Full Code Here

        assertNull(page.getPageRequest());
    }

    @Test
    public void testListByConsumerAndProductFiltered() {
        PageRequest req = new PageRequest();
        req.setPage(1);
        req.setPerPage(10);

        Product product = TestUtil.createProduct();
        productCurator.create(product);

        Pool pool = createPoolAndSub(owner, product, 1L,
View Full Code Here

        builder.queryParam(PageRequest.PAGE_PARAM, String.valueOf(value));
        return builder.build().toString();
    }

    protected Integer getLastPage(Page page) {
        PageRequest pageRequest = page.getPageRequest();

        // The last page is ceiling(maxRecords/recordsPerPage)
        int lastPage = page.getMaxRecords() / pageRequest.getPerPage();

        if (page.getMaxRecords() % pageRequest.getPerPage() != 0) {
            lastPage++;
        }

        return lastPage;
    }
View Full Code Here

        Page<List<E>> resultsPage;
        if (postFilter) {
            // Create a copy of the page request with just the order and sort by values.
            // Since we are filtering after the results are returned, we don't want
            // to send the page or page size values in.
            PageRequest orderAndSortByPageRequest = null;
            if (pageRequest != null) {
                orderAndSortByPageRequest = new PageRequest();
                orderAndSortByPageRequest.setOrder(pageRequest.getOrder());
                orderAndSortByPageRequest.setSortBy(pageRequest.getSortBy());
            }

            resultsPage = listAll(orderAndSortByPageRequest);

            // Set the pageRequest to the correct object here.
View Full Code Here

        Page<List<E>> resultsPage;
        if (postFilter) {
            // Create a copy of the page request with just the order and sort by values.
            // Since we are filtering after the results are returned, we don't want
            // to send the page or page size values in.
            PageRequest orderAndSortByPageRequest = null;
            if (pageRequest != null) {
                orderAndSortByPageRequest = new PageRequest();
                orderAndSortByPageRequest.setOrder(pageRequest.getOrder());
                orderAndSortByPageRequest.setSortBy(pageRequest.getSortBy());
            }

            resultsPage = listByCriteria(query, orderAndSortByPageRequest);

            // Set the pageRequest to the correct object here.
View Full Code Here

    }

    @Override
    public ServerResponse preProcess(HttpRequest request, ResourceMethod method)
        throws Failure, WebApplicationException {
        PageRequest p = null;

        MultivaluedMap<String, String> params = request.getUri().getQueryParameters();

        String page = params.getFirst(PageRequest.PAGE_PARAM);
        String perPage = params.getFirst(PageRequest.PER_PAGE_PARAM);
        String order = params.getFirst(PageRequest.ORDER_PARAM);
        String sortBy = params.getFirst(PageRequest.SORT_BY_PARAM);

        if (page != null || perPage != null || order != null || sortBy != null) {
            p = new PageRequest();

            if (order == null) {
                p.setOrder(PageRequest.DEFAULT_ORDER);
            }
            else {
                p.setOrder(readOrder(order));
            }

            /* We'll leave it to the curator layer to figure out what to sort by if
             * sortBy is null. */
            p.setSortBy(sortBy);

            try {
                if (page == null && perPage != null) {
                    p.setPage(PageRequest.DEFAULT_PAGE);
                    p.setPerPage(readInteger(perPage));
                }
                else if (page != null && perPage == null) {
                    p.setPage(readInteger(page));
                    p.setPerPage(PageRequest.DEFAULT_PER_PAGE);
                }
                else {
                    p.setPage(readInteger(page));
                    p.setPerPage(readInteger(perPage));
                }
            }
            catch (NumberFormatException nfe) {
                throw new BadRequestException(i18n.tr("offset and limit parameters" +
                    " must be positive integers"), nfe);
View Full Code Here

TOP

Related Classes of org.candlepin.paging.PageRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.