List of usage examples for org.springframework.data.domain Pageable getPageNumber
int getPageNumber();
From source file:curly.artifact.ArtifactServiceImpl.java
@Loggable @Override//from w w w . ja v a2 s.c om @HystrixCommand(fallbackMethod = "defaultFindAll") public Observable<Optional<Page<Artifact>>> findAll(Pageable pageable) { log.trace("Finding for page {}", pageable.getPageNumber()); return new ObservableResult<Optional<Page<Artifact>>>() { @Override public Optional<Page<Artifact>> invoke() { return Optional.ofNullable(repository.findAll(pageable)); } }; }
From source file:com.pos.web.MasterSatuanCtrl.java
@RequestMapping(value = "/satuan", method = RequestMethod.GET) @ResponseBody/*from ww w .j av a 2 s. co m*/ public Page<Satuan> listAll(@RequestParam(required = false) String search, Pageable pageable, HttpServletResponse response) { PageRequest pr = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.ASC, "nama"); logger.debug("pageNumber [{}], pageSize: [{}]", pageable.getPageNumber(), pageable.getPageSize()); return satuanDao.findAll(pr); }
From source file:com.pos.web.MasterItemKategoriCtrl.java
@RequestMapping(value = "/item-kategori", method = RequestMethod.GET) @ResponseBody//from ww w. java 2s.c o m public Page<ItemKategori> listAll(@RequestParam(required = false) String search, Pageable pageable, HttpServletResponse response) { PageRequest pr = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.ASC, "nama"); logger.debug("pageNumber [{}], pageSize: [{}]", pageable.getPageNumber(), pageable.getPageSize()); return itemKategoriDao.findAll(pr); }
From source file:curly.artifact.ArtifactResourceController.java
@RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE) public DeferredResult<HttpEntity<PagedArtifact>> artifactResources(@PageableDefault(20) Pageable pageable) { log.trace("Querying resources with page {}, size {}", pageable.getPageNumber(), pageable.getPageSize()); artifactService.findAll(pageable).forEach(System.out::println); return defer(artifactService.findAll(pageable) .map(o -> o.<ResourceNotFoundException>orElseThrow(ResourceNotFoundException::new)) .map(PagedArtifact::new).map(ResponseEntity::ok)); }
From source file:com.pos.web.MasterItemCtrl.java
@RequestMapping(value = "/item", method = RequestMethod.GET) @ResponseBody/*from w ww . j a v a2 s . c o m*/ public Page<Item> listAll(@RequestParam(required = false) String search, Pageable pageable, HttpServletResponse response) { PageRequest pr = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.ASC, "nama"); logger.debug("pageNumber [{}], pageSize: [{}]", pageable.getPageNumber(), pageable.getPageSize()); return itemDao.findAll(pr); }
From source file:com.trenako.web.controllers.admin.AdminScalesControllerMappingTests.java
@Test public void shouldShowTheFirstPageOfScalesByDefault() throws Exception { ArgumentCaptor<Pageable> arg = ArgumentCaptor.forClass(Pageable.class); mockMvc().perform(get("/admin/scales")).andExpect(status().isOk()); verify(mockService, times(1)).findAll(arg.capture()); Pageable p = arg.getValue(); assertEquals(0, p.getPageNumber()); assertEquals(10, p.getPageSize());/* w ww . j a v a2 s. c o m*/ }
From source file:com.trenako.web.controllers.admin.AdminScalesControllerMappingTests.java
@Test public void shouldProcessPagingParametersForScales() throws Exception { ArgumentCaptor<Pageable> arg = ArgumentCaptor.forClass(Pageable.class); mockMvc().perform(get("/admin/scales").param("page.page", "2").param("page.size", "25") .param("page.sort", "name").param("page.sort.dir", "desc")).andExpect(status().isOk()); verify(mockService, times(1)).findAll(arg.capture()); Pageable p = arg.getValue(); assertEquals(1, p.getPageNumber()); assertEquals(25, p.getPageSize());/*from ww w. j a va 2 s. c o m*/ assertNotNull("Sort is null", p.getSort().getOrderFor("name")); assertEquals(Sort.Direction.DESC, p.getSort().getOrderFor("name").getDirection()); }
From source file:io.curly.artifact.service.DefaultArtifactCommand.java
@Loggable @SuppressWarnings("unused") @HystrixCommand/*www . java 2 s . c o m*/ private Optional<Page<Artifact>> defaultFindAll(Pageable pageable) { log.warn("Default find all owned triggered on page {}", pageable.getPageNumber()); return Optional.of(new PageImpl<>(Collections.emptyList())); }
From source file:io.curly.advisor.command.ReviewHystrixCommands.java
private Page<Review> defaultFindAllByArtifact(Pageable pageable, String artifact) { log.warn("Requested reviews for artifact {} on page {} but fell back", artifact, pageable.getPageNumber()); return new PageImpl<>(Collections.<Review>emptyList(), pageable, 0); }
From source file:com.trenako.web.controllers.admin.AdminBrandsControllerMappingTests.java
@Test public void shouldShowTheFirstPageOfBrandsByDefault() throws Exception { ArgumentCaptor<Pageable> arg = ArgumentCaptor.forClass(Pageable.class); mockMvc().perform(get("/admin/brands")).andExpect(status().isOk()); verify(mockService, times(1)).findAll(arg.capture()); Pageable p = arg.getValue(); assertEquals(0, p.getPageNumber()); assertEquals(10, p.getPageSize());//from w ww. j ava 2 s .c o m }