Package org.springframework.data.domain

Examples of org.springframework.data.domain.Pageable


    @RequestMapping(value = "/{year:\\d+}/{month:\\d+}", method = { GET, HEAD })
    public String listPublishedPostsForYearAndMonth(@PathVariable int year, @PathVariable int month,
                                                    @RequestParam(defaultValue = "1", value = "page") int page,
                                                    Model model) {

        Pageable pageRequest = PageableFactory.forLists(page);
        Page<Post> result = service.getPublishedPostsByDate(year, month, pageRequest);
        YearMonth yearMonth = new YearMonth(year, month);
        model.addAttribute("title", "Archive for " + yearMonth.toString("MMMM yyyy"));
        return renderListOfPosts(result, model, "All Posts");
    }
View Full Code Here


    @RequestMapping(value = "/{year:\\d+}", method = { GET, HEAD })
    public String listPublishedPostsForYear(@PathVariable int year,
                                            @RequestParam(defaultValue = "1", value = "page") int page, Model model) {

        Pageable pageRequest = PageableFactory.forLists(page);
        Page<Post> result = service.getPublishedPostsByDate(year, pageRequest);
        model.addAttribute("title", String.format("Archive for %d", year));
        return renderListOfPosts(result, model, "All Posts");
    }
View Full Code Here

        JsonParser jsonParser = new JsonParser();
        searchResultParser = new SearchResultParser();
        JestResult jestResult = new JestResult();
        jestResult.setJsonObject(jsonParser.parse(RESULT_STRING).getAsJsonObject());

        Pageable pageable = new PageRequest(1, 10);
        content = searchResultParser.parseResults(jestResult, pageable, "search term").getPage().getContent();
    }
View Full Code Here

        this.dateFactory = dateFactory;
    }

    @RequestMapping(value = "", method = { GET, HEAD })
    public String dashboard(Model model) {
        Pageable pageRequest = PageableFactory.forDashboard();
        model.addAttribute("posts", PostView.pageOf(service.getPublishedPosts(pageRequest), dateFactory));
        model.addAttribute("drafts", PostView.pageOf(service.getDraftPosts(pageRequest), dateFactory));
        model.addAttribute("scheduled", PostView.pageOf(service.getScheduledPosts(pageRequest), dateFactory));
        return "admin/blog/index";
    }
View Full Code Here

            String queryString = this.query;
            if (parameters.hasSortParameter()) {
                queryString = addSorting(queryString, (Sort) args[parameters.getSortIndex()]);
            }
            if (parameters.hasPageableParameter()) {
                final Pageable pageable = getPageable(args);
                if (pageable!=null) {
                    queryString = addSorting(queryString, pageable.getSort());
                    queryString = addPaging(queryString, pageable);
                }
            }
            return queryString;
        }
View Full Code Here

    }
    if (obj == null || !(obj instanceof Pageable)) {
      return false;
    }

    Pageable other = (Pageable) obj;
    if (page != other.getPageNumber()) {
      return false;
    }
    if (size != other.getPageSize()) {
      return false;
    }
    if (sort == null) {
      if (other.getSort() != null) {
        return false;
      }
    } else if (!sort.equals(other.getSort())) {
      return false;
    }
    return true;
  }
View Full Code Here

    }

    @Override
    public Object execute(Query query) {

      Pageable pageToUse = getPageable();

      if (isLimiting()) {

        int limit = getLimit();
        if (pageToUse == null) {
          pageToUse = new SolrPageRequest(0, limit);
        }

        if (limit > 0) {
          if (pageToUse.getOffset() > limit) {
            return new PageImpl(java.util.Collections.emptyList(), pageToUse, limit);
          }
          if (pageToUse.getOffset() + pageToUse.getPageSize() > limit) {
            pageToUse = getLimitingPageable(pageToUse, limit - pageToUse.getOffset());
          }
        }
      }

      query.setPageRequest(pageToUse);
View Full Code Here

    List<T> beans = convertQueryResponseToBeans(response, clazz);
    SolrDocumentList results = response.getResults();
    long numFound = results == null ? 0 : results.getNumFound();
    Float maxScore = results == null ? null : results.getMaxScore();

    Pageable pageRequest = query.getPageRequest();

    SolrResultPage<T> page = new SolrResultPage<T>(beans, pageRequest, numFound, maxScore);

    page.setFieldStatsResults(ResultHelper.convertFieldStatsInfoToFieldStatsResultMap(response.getFieldStatsInfo()));
    page.setGroupResults(ResultHelper.convertGroupQueryResponseToGroupResultMap(query, objectsName, response, this,
View Full Code Here

    return getAllMessages(1, size);
  }

  public List<Message> getAllMessages(int page, int size)
  {
    Pageable pageable = new PageRequest(page, size, new Sort(Sort.Direction.DESC, "createdOn"));
    return messageRepository.findAll(pageable).getContent();
  }
View Full Code Here

      add(new Object());
    }}));

    reader.jumpToItem(485);

    Pageable pageRequest = pageRequestContainer.getValue();
    assertEquals(400, pageRequest.getOffset());
    assertEquals(4, pageRequest.getPageNumber());
    assertEquals(100, pageRequest.getPageSize());
    assertEquals("id: ASC", pageRequest.getSort().toString());
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.Pageable

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.