@Query("SELECT u FROM UserEntity u WHERE u.tenantId = :tenantId " + "AND u.customerId = :customerId AND u.authority = :authority " + "AND LOWER(u.searchText) LIKE LOWER(CONCAT(:searchText, '%'))" + "AND u.id > :idOffset ORDER BY u.id") List<UserEntity> findUsersByAuthority(@Param("tenantId") String tenantId, @Param("customerId") String customerId, @Param("idOffset") String idOffset, @Param("searchText") String searchText, @Param("authority") Authority authority, Pageable pageable);
/** * Looks up the stores in the given distance around the given location. * * @param model the {@link Model} to populate. * @param location the optional location, if none is given, no search results will be returned. * @param distance the distance to use, if none is given the {@link #DEFAULT_DISTANCE} is used. * @param pageable the pagination information * @return */ @RequestMapping(value = "/", method = RequestMethod.GET) String index(Model model, @RequestParam Optional<Point> location, @RequestParam Optional<Distance> distance, Pageable pageable) { Point point = location.orElse(KNOWN_LOCATIONS.get("Timesquare NY")); Page<Store> stores = repository.findByAddressLocationNear(point, distance.orElse(DEFAULT_DISTANCE), pageable); model.addAttribute("stores", stores); model.addAttribute("distances", DISTANCES); model.addAttribute("selectedDistance", distance.orElse(DEFAULT_DISTANCE)); model.addAttribute("location", point); model.addAttribute("locations", KNOWN_LOCATIONS); model.addAttribute("api", entityLinks.linkToSearchResource(Store.class, "by-location", pageable).getHref()); return "index"; }
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.TEXT_HTML_VALUE, MediaType.APPLICATION_XHTML_XML_VALUE }) public String listAllUsers(@RequestParam(name = "type", required = false) String editType, @RequestParam(name = "edit", required = false) String editUsername, Model model, Pageable pageable) { model.addAttribute("roles", roleRepository.findAll()); if (!StringUtils.isEmpty(editType)) { if (!StringUtils.isEmpty(editUsername)) { model.addAttribute("editUser", userRepository.findOneByUsername(editUsername).map(userEntity -> { Map<String, Object> editUserMap = new HashMap<>(); editUserMap.put("username", userEntity.getUsername()); editUserMap.put("roles", userEntity.getRoles().stream().map(xref -> xref.getRole().getName()).collect(Collectors.toList())); return editUserMap; }).orElse(null)); } return "userrole/user"; } model.addAttribute("users", userRepository.findAll(pageable)); return "userrole/users"; }
protected void init() { Set<Class<?>> documentClasses = metadata.getAnnotatedDocuments(); documentClasses.forEach(clazz -> { PagingAndSortingRepository repository = getRepositoryBean(clazz); addTask(new IndexTask() { @Override public Class<?> getDomainClass() { return clazz; } @Override public long count() { return repository.count(); } @Override public Page<?> getData(Pageable pageable) { return repository.findAll(pageable); } }); this.progress.put(clazz.getCanonicalName(), new IndexProgress(clazz, repository.count(), (long) 0)); }); }
/** * GET /game-servers : get all the gameServers. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of gameServers in body * @throws URISyntaxException if there is an error to generate the pagination HTTP headers */ @GetMapping("/game-servers") @Timed @Secured(AuthoritiesConstants.SUPPORT) public ResponseEntity<List<GameServerDTO>> getAllGameServers(@ApiParam Pageable pageable) throws URISyntaxException { log.debug("REST request to get a page of GameServers"); Page<GameServerDTO> page = gameServerService.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/game-servers"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * 获取所有订单 * @param pageindex * @param pageSize * @return */ @ResponseBody @RequestMapping("/list.do") public ResultBean<List<Order>> listData(int pageindex, @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) { Pageable pageable = new PageRequest(pageindex, pageSize, null); List<Order> list = orderService.findAll(pageable).getContent(); return new ResultBean<>(list); }
@ApiOperation(value = "Search title and content by bo or keywords") @RequestMapping(value="/search", method = RequestMethod.GET) public Page<Article> get( @RequestParam(name = "bo", required = false) Integer boTypeId, @RequestParam(name = "keywords", required = false) String keywords, @PageableDefault(value = 10, sort = { "lastUpdate" }, direction = Sort.Direction.DESC) Pageable pageable) { if (boTypeId != null && boTypeId > 0 && keywords != null && keywords.length() > 0) { return this.articleService.findByBoAndKeywords(boTypeId, keywords, pageable); } else if (keywords != null && keywords.length() > 0) { return this.articleService.findByKeywords(keywords, pageable); } else if (boTypeId != null && boTypeId > 0) { return this.articleService.findByBoTypeId(boTypeId, pageable); } return this.articleService.findAll(pageable); }
@Override public String selectAll(TableDescription table, String whereClause, Pageable page) { Sort sort = page.getSort() != null ? page.getSort() : sortById(table); return format("%s OFFSET %d ROWS FETCH NEXT %d ROW ONLY", selectAll(table, whereClause, sort), page.getOffset(), page.getPageSize()); }
/** * GET /tasks : get all the tasks. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of tasks in body */ @GetMapping("/tasks") @Timed public ResponseEntity<List<Task>> getAllTasks(@ApiParam Pageable pageable) { log.debug("REST request to get a page of Tasks"); final Page<Task> page; if (SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN)) { page = this.taskRepository.findAll(pageable); } else { page = this.taskRepository.findAllByUser(SecurityUtils.getCurrentUserLogin(), pageable); } HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/tasks"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * Find all pageable permitted entities. * @param pageable the page info * @param entityClass the entity class to get * @param privilegeKey the privilege key for permission lookup * @param <T> the type of entity * @return page of permitted entities */ public <T> Page<T> findAll(Pageable pageable, Class<T> entityClass, String privilegeKey) { String selectSql = String.format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = String.format(COUNT_ALL_SQL, entityClass.getSimpleName()); String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += WHERE_SQL + permittedCondition; countSql += WHERE_SQL + permittedCondition; } log.debug("Executing SQL '{}'", selectSql); return execute(createCountQuery(countSql), pageable, createSelectQuery(selectSql, pageable, entityClass)); }
/** * GET /sub-categories : get all the subCategories. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of subCategories in body */ @GetMapping("/sub-categories") @Timed public ResponseEntity<List<SubCategory>> getAllSubCategories(@ApiParam Pageable pageable) { log.debug("REST request to get a page of SubCategories"); Page<SubCategory> page = subCategoryService.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/sub-categories"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
@Override public <T> Slice<T> findSlice(Query<T> query) { List<T> list = findAllInternal(query); Pageable pageable = query.getPageable(); if (pageable != null) { boolean hasNext = ((pageable.getPageNumber() + 1) * pageable.getPageSize() < total(query)); return new SliceImpl<T>(list, query.getPageable(), hasNext); } else { return new SliceImpl<T>(list); } }
@Override public ListenableFuture<List<EntityRelation>> findRelations(EntityId from, String relationType, RelationTypeGroup typeGroup, ThingType childType, TimePageLink pageLink) { Specification<RelationEntity> timeSearchSpec = JpaAbstractSearchTimeDao .<RelationEntity>getTimeSearchPageSpec(pageLink, "toId"); Specification<RelationEntity> fieldsSpec = getEntityFieldsSpec(from, relationType, typeGroup, childType); Pageable pageable = new PageRequest(0, pageLink.getLimit(), new Sort(new Order(ASC, "relationTypeGroup"), new Order(ASC, "relationType"), new Order(ASC, "toType"))); return service.submit(() -> DaoUtil .convertDataList(relationRepository.findAll(where(timeSearchSpec).and(fieldsSpec), pageable).getContent())); }
/** * GET /privileges : get all the privileges. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of privileges in body * @throws URISyntaxException if there is an error to generate the pagination HTTP headers */ @GetMapping("/privileges") @Timed @Secured(AuthoritiesConstants.SUPPORT) public ResponseEntity<List<Privilege>> getAllPrivileges(@ApiParam Pageable pageable) throws URISyntaxException { log.debug("REST request to get a page of Privileges"); Page<Privilege> page = privilegeRepository.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/privileges"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * SEARCH /_search/entries?query=:query : search for the entry corresponding * to the query. * * @param query the query of the entry search * @param pageable the pagination information * @return the result of the search */ @GetMapping("/_search/entries") @Timed public ResponseEntity<List<Entry>> searchEntries(@RequestParam String query, @ApiParam Pageable pageable) { log.debug("REST request to search for a page of Entries for query {}", query); Page<Entry> page = entrySearchRepository.search(queryStringQuery(query), pageable); HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/entries"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * Build full select query with filter without paging * * @param pageable the pagination information * @param requestParams the queries of the search * @return list of dtos */ private List<TransferTimingListingDTO> basicSelectFilterWithoutPaging(Pageable pageable, Map<String, String> requestParams) { return buildQuery(basicSelectQuery()) .and(buildConditions(requestParams)) .orderBy(buildSort(pageable.getSort())) .fetch() .map(TransferTimingPageRepositoryImpl::recordToDto); }
@Test public void testValidCommandAndSearchReturn3Documents() throws Exception { MetadataSearchCommand searchCommand = new MetadataSearchCommand("name", "thename"); List<StoredDocument> documents = Arrays.asList( new StoredDocument(), new StoredDocument(), new StoredDocument()); PageRequest pageRequest = new PageRequest(0, 2); when( this.searchService .findStoredDocumentsByMetadata(eq(searchCommand), any(Pageable.class))) .thenReturn(new PageImpl<>(documents, pageRequest, 3)); restActions .withAuthorizedUser("userId") .withAuthorizedService("divorce") .post("/documents/filter", searchCommand) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.size", is(2))) .andExpect(jsonPath("$.page.totalElements", is(3))) .andExpect(jsonPath("$.page.totalPages", is(2))) .andExpect(jsonPath("$.page.number", is(0))) .andExpect(jsonPath("$._links.first.href", is("http://localhost/documents/filter?page=0&size=2"))) .andExpect(jsonPath("$._links.self.href", is("http://localhost/documents/filter?page=0&size=2"))) .andExpect(jsonPath("$._links.next.href", is("http://localhost/documents/filter?page=1&size=2"))) .andExpect(jsonPath("$._links.last.href", is("http://localhost/documents/filter?page=1&size=2"))); }
/** * GET /audits : get a page of AuditEvents between the fromDate and toDate. * * @param fromDate the start of the time period of AuditEvents to get * @param toDate the end of the time period of AuditEvents to get * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body */ @GetMapping(params = {"fromDate", "toDate"}) public ResponseEntity<List<AuditEvent>> getByDates( @RequestParam(value = "fromDate") LocalDate fromDate, @RequestParam(value = "toDate") LocalDate toDate, @ApiParam Pageable pageable) { Page<AuditEvent> page = auditEventService.findByDates(fromDate.atTime(0, 0), toDate.atTime(23, 59), pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * GET /products : get all the products. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of products in body */ @GetMapping("/products") @Timed public ResponseEntity<List<Product>> getAllProducts(@ApiParam Pageable pageable) { log.debug("REST request to get a page of Products"); Page<Product> page = productService.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/products"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
@Override public List<File> listFilesByPage(int pageIndex, int pageSize) { Page<File> page = null; List<File> list = null; Sort sort = new Sort(Direction.DESC,"uploadDate"); Pageable pageable = new PageRequest(pageIndex, pageSize, sort); page = fileRepository.findAll(pageable); list = page.getContent(); return list; }
protected void addPagingToQuery(me.snowdrop.data.core.spi.Query<T> query) { Pageable pageable = query.getPageable(); if (pageable != null && pageable.isPaged()) { org.springframework.data.domain.Sort sort = pageable.getSort(); if (query.getSort() == null && sort.isSorted()) { addSortToQuery(sort); } setFirstResult(pageable.getOffset()); setMaxResults(pageable.getPageSize()); } }
/** * Add sorting from a Spring Data Pageable * @param pageable * @return */ public YadaSql orderBy(Pageable pageable) { Iterator<Sort.Order> orders = pageable.getSort().iterator(); while (orders.hasNext()) { Sort.Order order = orders.next(); orderBy(order.getProperty() + " " + order.getDirection()); } return this; }
/** * GET /applications : get all the applications. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and the list of applications in body */ @GetMapping("/applications") @Timed public ResponseEntity<List<Application>> getAllApplications(Pageable pageable) { log.debug("REST request to get a page of Applications"); Page<Application> page = applicationService.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/applications"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * Build full select query * * @param pageable the pagination information * @return list of dtos */ private List<TransferTimingListingDTO> basicSelect(Pageable pageable) { return buildQuery(basicSelectQuery()) .orderBy(buildOrderBy(pageable.getSort())) .limit(pageable.getOffset(), pageable.getPageSize()) .fetch() .map(TransferTimingPageRepositoryImpl::recordToDto); }
/** * GET /users : get all users. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and with body all users */ @GetMapping("/users") @Timed @Secured(AuthoritiesConstants.ADMIN) public ResponseEntity<List<UserDTO>> getAllUsers(Pageable pageable) { final Page<UserDTO> page = userService.getAllManagedUsers(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/users"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
/** * Search for the operino corresponding to the query. * * @param query the query of the search * @return the list of entities */ @Override @Transactional(readOnly = true) public Page<Operino> search(String query, Pageable pageable) { log.debug("Request to search for a page of Operinos for query {}", query); Page<Operino> result = operinoSearchRepository.search(queryStringQuery(query), pageable); return result; }
@ApiOperation(value = "queryCompanys", notes = "获取 公司分页") @GetMapping("/all_company/page") public ModelResult<List<Company>> queryCompanys(Pageable pageable, HttpServletRequest request, HttpServletResponse response) throws URISyntaxException { ModelResult<List<Company>> result = new ModelResult<>(); Page<Company> companies = companyMapper.selectAllPageable(pageable); result.setData(companies.getContent()); PaginationUtil.setPaginationHttpHeaders(companies, request,response); return result; }
public static List<Parameter> getParametersBody(Method m) { return Arrays.asList(m.getParameters()).stream().filter(p -> { boolean ok = p.getAnnotation(PathVariable.class) == null; ok = ok && p.getAnnotation(RequestParam.class) == null; ok = ok && !Pageable.class.isAssignableFrom(p.getType()); return ok; }).collect(Collectors.toList()); }
@RequestMapping(path = "/submissionEnvelopes/{sub_id}/assays", method = RequestMethod.GET) ResponseEntity<?> getAssays(@PathVariable("sub_id") SubmissionEnvelope submissionEnvelope, Pageable pageable, final PersistentEntityResourceAssembler resourceAssembler) { Page<Assay> assays = getAssayRepository().findBySubmissionEnvelopesContaining(submissionEnvelope, pageable); return ResponseEntity.ok(getPagedResourcesAssembler().toResource(assays, resourceAssembler)); }
/** * SEARCH /_search/tags?query=:query : search for the tag corresponding * to the query. * * @param query the query of the tag search * @param pageable the pagination information * @return the result of the search */ @GetMapping("/_search/tags") @Timed public ResponseEntity<List<Tag>> searchTags(@RequestParam String query, @ApiParam Pageable pageable) { log.debug("REST request to search for a page of Tags for query {}", query); Page<Tag> page = tagSearchRepository.search(queryStringQuery(query), pageable); HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/tags"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
@Override public final Page<T> findAll(final Specification<T> spec, final Pageable pageable) { final int fromIndex = pageable.getPageNumber() * pageable.getPageSize(); if (fromIndex >= values.size()) { return new PageImpl<>(Collections.<T>emptyList(), pageable, values.size()); } int toIndex = pageable.getPageNumber() * pageable.getPageSize() + pageable.getPageSize(); if (toIndex > values.size()) { toIndex = values.size(); } return new PageImpl<>(values.subList(fromIndex, toIndex), pageable, values.size()); }
@Test @Rollback public void testFindActiveInstanceConfigs() throws Exception { long someInstanceId = 1; long anotherInstanceId = 2; String someConfigAppId = "someConfigAppId"; String someConfigClusterName = "someConfigClusterName"; String someConfigNamespaceName = "someConfigNamespaceName"; Date someValidDate = new Date(); Pageable pageable = new PageRequest(0, 10); String someReleaseKey = "someReleaseKey"; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -2); Date someInvalidDate = calendar.getTime(); prepareInstanceConfigForInstance(someInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someValidDate); prepareInstanceConfigForInstance(anotherInstanceId, someConfigAppId, someConfigClusterName, someConfigNamespaceName, someReleaseKey, someInvalidDate); Page<InstanceConfig> validInstanceConfigs = instanceService .findActiveInstanceConfigsByReleaseKey(someReleaseKey, pageable); assertEquals(1, validInstanceConfigs.getContent().size()); assertEquals(someInstanceId, validInstanceConfigs.getContent().get(0).getInstanceId()); }
/** * GET /users : get all users. * * @param pageable the pagination information * @return the ResponseEntity with status 200 (OK) and with body all users */ @GetMapping("/users") @Timed public ResponseEntity<List<UserDTO>> getAllUsers(@ApiParam Pageable pageable) { final Page<UserDTO> page = userService.getAllManagedUsers(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/users"); return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK); }
@GetMapping(value = "/mahasiswas") @CrossOrigin public HttpEntity<Page<Mahasiswa>> getMahasiswas(Pageable pageable) { return new ResponseEntity<>(mahasiswaService.getMahasiswas(pageable), HttpStatus.OK); }
@Override public Pageable next() { return null; }
@Override public Response lista(String nome, int page, int limit, String sort, String direction) { Pageable pageagle = new PageRequest(page, limit, Sort.Direction.fromString(direction), sort); return Response.ok(service.lista(pageagle, nome)).build(); }
public Page<AuditEvent> findAll(Pageable pageable) { return persistenceAuditEventRepository.findAll(pageable) .map(auditEventConverter::convertToAuditEvent); }
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.TEXT_HTML_VALUE, MediaType.APPLICATION_XHTML_XML_VALUE }) public String listAllRoles(Model model, Pageable pageable) { model.addAttribute("roles", roleRepository.findAll(pageable)); return "userrole/roles"; }
/** * Get all the programs. * * @param pageable the pagination information * @return the list of entities */ @Override @Transactional(readOnly = true) public Page<ProgramDTO> findAll(Pageable pageable) { log.debug("Request to get all Programs"); Page<Program> result = programRepository.findAll(pageable); return result.map(program -> programMapper.programToProgramDTO(program)); }
public void setPageable(Pageable pageable) { this.pageable = pageable; }