List of usage examples for org.springframework.data.domain PageImpl PageImpl
public PageImpl(List<T> content, Pageable pageable, long total)
From source file:br.com.joaops.smt.service.EmpresaServiceImpl.java
@Override public Page<EmpresaDto> searchAllEmpresa(Pageable p) { List<EmpresaDto> list = new ArrayList<>(); Page<Empresa> empresas = empresaRepository.findAll(p); for (Empresa empresa : empresas) { EmpresaDto dto = new EmpresaDto(); mapper.map(empresa, dto);/*from ww w. j av a2 s .co m*/ list.add(dto); } Page<EmpresaDto> page = null; if (!list.isEmpty()) { page = new PageImpl<>(list, p, list.size()); } return page; }
From source file:org.terasoluna.gfw.functionaltest.app.el.ElDateTimeFormatController.java
@RequestMapping(value = "6_13/search", method = RequestMethod.GET) public String listOfJavaBeanQueryString(DateForm5 dateForm5, @PageableDefault Pageable pageable, Model model) { // Create Dummy Data List<String> dummyList = new ArrayList<String>(); for (int i = 1; i <= 10; i++) { dummyList.add("Dummy"); }//from w w w .j av a 2 s . com Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100); model.addAttribute("page", dummyPage); return "el/dateTimeFormatQueryOutput"; }
From source file:org.terasoluna.gfw.functionaltest.app.el.ElMapOfSimpleValueController.java
@RequestMapping(value = "6_12/search", method = RequestMethod.GET) public String listOfJavaBeanQueryString(SearchForm4 searchForm4, @PageableDefault Pageable pageable, Model model) {// www . j a v a 2 s . co m // Create Dummy Data List<String> dummyList = new ArrayList<String>(); for (int i = 1; i <= 10; i++) { dummyList.add("Dummy"); } Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100); model.addAttribute("page", dummyPage); return "el/mapOfSimpleValueQueryOutput"; }
From source file:it.f2informatica.pagination.repository.mongodb.SimpleMongoPaginationRepository.java
@Override public Page<T> findAll(MongoQueryPredicate<T> predicate, Pageable pageable) { List<T> content = getMongoOperations().find(predicate.queryPredicate().with(pageable), predicate.getEntityClass()); return new PageImpl<>(content, pageable, getMongoOperations().count(predicate.queryPredicate(), predicate.getEntityClass())); }
From source file:org.terasoluna.gfw.functionaltest.app.el.ElNestedJavaBeanController.java
@RequestMapping(value = "6_9/search", method = RequestMethod.GET) public String nestedJavaBeanQueryString(SearchUserForm1 searchUserForm1, @PageableDefault Pageable pageable, Model model) {//from w w w .ja v a 2 s.c o m // Create Dummy Data List<String> dummyList = new ArrayList<String>(); for (int i = 1; i <= 10; i++) { dummyList.add("Dummy"); } Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100); model.addAttribute("page", dummyPage); return "el/nestedJavaBeanQueryOutput"; }
From source file:org.springframework.data.examples.repository.ContactRepositoryImpl.java
@Override public Page<Contact> findAll(Pageable pageable) { long first = pageable.getOffset() + 1; long last = pageable.getOffset() + pageable.getPageSize(); SelectResults<Contact> results = template.find("select * from /Contact where id >= $1 and id <= $2", first, last);/*from w w w . j a v a 2 s . co m*/ List<Contact> contacts = results.asList(); Collections.sort(contacts, new Comparator<Contact>() { @Override public int compare(Contact c0, Contact c1) { return (int) (c0.getId() - c1.getId()); } }); return results == null ? null : new PageImpl<Contact>(contacts, pageable, results.size()); }
From source file:org.terasoluna.gfw.functionaltest.app.el.ElListOfJavaBeanController.java
@RequestMapping(value = "6_10/search", method = RequestMethod.GET) public String listOfJavaBeanQueryString(BatchUpdateUserForm2 batchUpdateUserForm2, @PageableDefault Pageable pageable, Model model) { // Create Dummy Data List<String> dummyList = new ArrayList<String>(); for (int i = 1; i <= 10; i++) { dummyList.add("Dummy"); }/*from w ww . j a v a 2 s .co m*/ Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100); model.addAttribute("page", dummyPage); return "el/listOfJavaBeanQueryOutput"; }
From source file:org.terasoluna.gfw.functionaltest.app.el.ElArrayController.java
@RequestMapping(value = "6_14/search", method = RequestMethod.GET) public String listOfJavaBeanQueryString(ArrayForm6 arrayForm6, @PageableDefault Pageable pageable, Model model) {//w w w. j a va 2s. c o m // Create Dummy Data List<String> dummyList = new ArrayList<String>(); for (int i = 1; i <= 10; i++) { dummyList.add("Dummy"); } Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100); model.addAttribute("page", dummyPage); return "el/arrayQueryOutput"; }
From source file:org.terasoluna.gfw.functionaltest.app.el.ElSimpleJavaBeanAndListOfJavaBeanController.java
@RequestMapping(value = "6_11/search", method = RequestMethod.GET) public String listOfJavaBeanQueryString(SearchAndBatchUpdateUserForm3 searchAndBatchUpdateUserForm3, @PageableDefault Pageable pageable, Model model) { // Create Dummy Data List<String> dummyList = new ArrayList<String>(); for (int i = 1; i <= 10; i++) { dummyList.add("Dummy"); }/*from w ww. jav a 2 s . co m*/ Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100); model.addAttribute("page", dummyPage); return "el/simpleJavaBeanAndListOfJavaBeanQueryOutput"; }
From source file:com.jiwhiz.rest.admin.BlogRestControllerTest.java
@Test public void getBlogPosts_ShouldReturnAllBlogPostsInSystem() throws Exception { Page<BlogPost> page = new PageImpl<BlogPost>(getTestPublishedBlogPostList(), new PageRequest(0, 10), 2); when(blogPostRepositoryMock.findAll(any(Pageable.class))).thenReturn(page); mockMvc.perform(get(API_ROOT + URL_ADMIN_BLOGS)).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$._embedded.blogPostList", hasSize(2))) .andExpect(jsonPath("$._embedded.blogPostList[0].id", is(BLOGS_1_ID))) .andExpect(jsonPath("$._embedded.blogPostList[0].title", is(BLOGS_1_TITLE))) .andExpect(jsonPath("$._embedded.blogPostList[1].id", is(BLOGS_2_ID))) .andExpect(jsonPath("$._embedded.blogPostList[1].title", is(BLOGS_2_TITLE))) .andExpect(jsonPath("$._links.self.templated", is(true))) .andExpect(jsonPath("$._links.self.href", endsWith(URL_ADMIN_BLOGS + "{?page,size,sort}"))); }