List of usage examples for org.springframework.data.domain Page isFirst
boolean isFirst();
From source file:org.openlmis.fulfillment.service.PageDto.java
/** * Creates new instance based on data from {@link Page} instance. *//*w w w . j a va2s. c o m*/ public PageDto(Page<T> page) { this(checkNotNull(page).isLast(), page.isFirst(), page.getTotalPages(), page.getTotalElements(), page.getSize(), page.getNumber(), page.getNumberOfElements(), page.getSort(), checkNotNull(page.getContent())); }
From source file:de.olivergierke.deepdive.ProductRepositoryIntegrationTest.java
/** * @since Step 6.2//from w w w. j av a 2s . c o m */ @Test public void findsAllAppleProductPaged() { Page<Product> products = repository.findByDescriptionContaining("Apple", new PageRequest(0, 1)); assertThat(products.isFirst(), is(true)); assertThat(products.hasNext(), is(true)); assertThat(products, Matchers.<Product>hasItem(hasProperty("name", is("iPad")))); assertThat(products, not(Matchers.<Product>hasItem(hasProperty("name", is("Dock"))))); }
From source file:demo.ProductRepositoryIntegrationTest.java
/** * @since Step 6.2//www. j ava 2 s . com */ @Test public void findsAllAppleProductPaged() { Page<Product> products = repository.findByDescriptionContaining("Apple", new PageRequest(0, 1)); assertThat(products.isFirst()).isTrue(); assertThat(products.hasNext()).isTrue(); assertThat(products).filteredOn("name", "iPad").isNotEmpty(); assertThat(products).filteredOn("name", "Dock").isEmpty(); }
From source file:de.olivergierke.deepdive.CustomerRepositoryIntegrationTest.java
/** * @since Step 4.1// www . ja v a 2 s . c o m */ @Test public void accessesCustomersPageByPage() { Page<Customer> result = repository.findAll(new PageRequest(1, 1)); assertThat(result, is(notNullValue())); assertThat(result.isFirst(), is(false)); assertThat(result.isLast(), is(false)); assertThat(result.getNumberOfElements(), is(1)); }
From source file:demo.CustomerRepositoryIntegrationTest.java
/** * @since Step 4.1//w ww . ja v a 2s. c om */ @Test public void accessesCustomersPageByPage() { Page<Customer> result = repository.findAll(new PageRequest(/* page:*/ 1, /* page size:*/ 1)); assertThat(result).isNotNull(); assertThat(result.isFirst()).isFalse(); assertThat(result.isLast()).isFalse(); assertThat(result.getNumberOfElements()).isEqualTo(1); }
From source file:io.leishvl.core.test.CitationRepositoryTests.java
@Test public void readsFirstPageCorrectly() { repository.deleteAll();/* w w w. j av a2 s.co m*/ // save a couple of citations ImmutableList.of(citation0, citation1).stream().forEach(citation -> repository.save(citation)); // fetch all citations pw.println("Citations found with findAll():"); pw.println("-------------------------------"); repository.findAll().stream().forEach(pw::println); pw.println(); // fetch a citations within a given namespace pw.println("Citation found with findByNamespace('citations'):"); pw.println("--------------------------------"); final Page<Citation> citations = repository.findByNamespaceValue("citations", new PageRequest(0, 20, Sort.Direction.ASC, "pubmed.medlineCitation.pmid.value")); assertThat("first page", citations.isFirst(), equalTo(true)); pw.println("Total elements=" + citations.getTotalElements() + ", Total pages=" + citations.getTotalPages()); citations.forEach(pw::println); // fetch an individual citation pw.println("Citation found with findByLeishvlId('lvl-ci-pm-CIT_0'):"); pw.println("--------------------------------"); pw.println(repository.findByLeishvlId("lvl-ci-pm-CIT_0")); }
From source file:com.yqboots.web.thymeleaf.processor.element.PaginationElementProcessor.java
/** * Gets the link node of the first page. * * @param page the pagination object * @param contextPath current context path of servlet * @return the node/* ww w. ja va 2 s . c o m*/ */ private Element getFirstElement(final Page<?> page, final String contextPath) { final Element result = new Element("li"); final Element a = new Element("a"); a.setAttribute("href", getPagedParams(contextPath, 0, page.getSize())); result.addChild(a); final Element icon = new Element("i"); icon.setAttribute("class", "glyphicon glyphicon-step-backward"); a.addChild(icon); if (page.isFirst()) { result.setAttribute("class", "disabled"); } return result; }
From source file:com.rizki.mufrizal.belajar.spring.data.mongodb.service.impl.CategoryServiceImpl.java
@Override public TreeMap<String, Object> getCategories(Pageable pageable) { Page<Category> categories = categoryRepository.findAll(pageable); List<Category> categorys = new ArrayList<>(); for (Category category : categories) { category.setDepartment(departmentRepository.findOne(category.getDepartmentId())); categorys.add(category);/*from w w w . j av a2 s .co m*/ } TreeMap<String, Object> map = new TreeMap<>(); map.put("content", categorys); map.put("last", categories.isLast()); map.put("totalPages", categories.getTotalPages()); map.put("totalElements", categories.getTotalElements()); map.put("size", categories.getSize()); map.put("number", categories.getNumber()); map.put("sort", categories.getSort()); map.put("first", categories.isFirst()); map.put("numberOfElements", categories.getNumberOfElements()); return map; }
From source file:com.afmobi.mongodb.repository.PersonRepositoryIntegrationTests.java
@Test public void findsPagedPersons() throws Exception { Page<Person> result = repository.findAll(new PageRequest(1, 2, Direction.ASC, "lastname", "firstname")); assertThat(result.isFirst(), is(false)); assertThat(result.isLast(), is(false)); assertThat(result, hasItems(dave, stefan)); }
From source file:com.afmobi.mongodb.repository.PersonRepositoryIntegrationTests.java
@Test public void executesPagedFinderCorrectly() throws Exception { Page<Person> page = repository.findByLastnameLike("*a*", new PageRequest(0, 2, Direction.ASC, "lastname", "firstname")); assertThat(page.isFirst(), is(true)); assertThat(page.isLast(), is(false)); assertThat(page.getNumberOfElements(), is(2)); assertThat(page, hasItems(carter, stefan)); }