Package org.springframework.data.domain

Examples of org.springframework.data.domain.Page


    }

    @Test
    public void findPersonsForPage() {
        List<Person> expected = new ArrayList<Person>();
        Page foundPage = new PageImpl<Person>(expected);

        when(personRepositoryMock.findAll(any(Predicate.class), any(Pageable.class))).thenReturn(foundPage);

        List<Person> actual = repository.findPersonsForPage(SEARCH_TERM, PAGE_INDEX);
View Full Code Here


    @Override
    public List<Person> findPersonsForPage(String searchTerm, int page) {
        LOGGER.debug("Finding persons for page " + page + " with search term: " + searchTerm);

        //Passes the predicate and the page specification to the repository
        Page requestedPage =  personRepository.findAll(lastNameIsLike(searchTerm), constructPageSpecification(page));

        return requestedPage.getContent();
    }
View Full Code Here

    @Override
    public List<Person> search(String searchTerm, int pageIndex) {
        LOGGER.debug("Searching persons with search term: " + searchTerm);

        //Passes the specification created by PersonSpecifications class and the page specification to the repository.
        Page requestedPage = personRepository.findAll(lastNameIsLike(searchTerm), constructPageSpecification(pageIndex));

        return requestedPage.getContent();
    }
View Full Code Here

                        Query countQuery = em.createNativeQuery(countSQL);
                        Query findQuery = em.createNativeQuery(findSQL);
                        findQuery.setFirstResult(pageable.getOffset());
                        findQuery.setMaxResults(pageable.getPageSize());

                        Page page = new PageImpl(
                                findQuery.getResultList(),
                                pageable,
                                ((BigInteger) countQuery.getSingleResult()).longValue());

                        model.addAttribute("resultPage", page);
View Full Code Here

        this.permissionList.assertHasViewPermission();

        searchable.addSearchParam("groupId_eq", group.getId());

        Page page = null;
        if (group.getType() == GroupType.user) {
            page = groupRelationService.findAll(searchable);
        }

        if (group.getType() == GroupType.organization) {
View Full Code Here

                    Query countQuery = em.createQuery(countQL);
                    Query findQuery = em.createQuery(findQL);
                    findQuery.setFirstResult(pageable.getOffset());
                    findQuery.setMaxResults(pageable.getPageSize());

                    Page page = new PageImpl(
                            findQuery.getResultList(),
                            pageable,
                            (Long) countQuery.getSingleResult());

                    model.addAttribute("resultPage", page);
View Full Code Here

    }
   
    @Test
    public void search() {
        List<Person> expected = new ArrayList<Person>();
        Page expectedPage = new PageImpl(expected);
        when(personRepositoryMock.findAll(any(Specification.class), any(Pageable.class))).thenReturn(expectedPage);
       
        List<Person> actual = personService.search(SEARCH_TERM, PAGE_INDEX);

        ArgumentCaptor<Pageable> pageArgument = ArgumentCaptor.forClass(Pageable.class);
View Full Code Here

  }

  @Test
  @SuppressWarnings("rawtypes")
  public void shouldSupportSpringData() throws Exception {
    Page page = mock(Page.class);
    given(page.getContent()).willReturn(Collections.singletonList("a"));
    given(page.getTotalElements()).willReturn(100L);
    this.uiPagedData.setValueExpression("value", mockExpression(page));
    this.uiPagedData.encodeEnd(this.context);
    PagedDataRows rows = (PagedDataRows) this.requestMap.get("pagedData");
    rows.setRowIndex(0);
    assertThat(rows.getRowData(), is(equalTo((Object) "a")));
View Full Code Here

        final Specification filterSpecification = specificationFromRequest(request, persistentEntity);

        if (isPredicateScope(scope)) {
            final PredicateScopeMetadata predicateScope = (PredicateScopeMetadata) scope;

            final Page page = findBySpecificationAndPredicate(repositoryInvoker, filterSpecification, predicateScope.predicate(), pageable);

            Object resources = resultToResources(page, assembler);

            return new ResponseEntity(resources, HttpStatus.OK);
        }

        if (isSpecificationScope(scope)) {
            final Specification scopeSpecification = ((ScopeMetadataUtils.SpecificationScopeMetadata) scope).specification();

            Page page = findItemsBySpecification(repositoryInvoker, and(scopeSpecification, filterSpecification), pageable);

            Object resources = resultToResources(page, assembler);

            return new ResponseEntity(resources, HttpStatus.OK);
        }

        Page page = findItemsBySpecification(repositoryInvoker, filterSpecification, pageable);

        Object resources = resultToResources(page, assembler);

        return new ResponseEntity(resources, HttpStatus.OK);
    }
View Full Code Here

TOP

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

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.