本文整理匯總了Java中org.springframework.data.domain.Pageable類的典型用法代碼示例。如果您正苦於以下問題:Java Pageable類的具體用法?Java Pageable怎麽用?Java Pageable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Pageable類屬於org.springframework.data.domain包,在下文中一共展示了Pageable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: LOWER
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
@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);
示例2: findAll
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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));
}
示例3: getAllTasks
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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);
}
示例4: findSlice
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
@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);
}
}
示例5: findRelations
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
@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()));
}
示例6: getAllPrivileges
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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);
}
示例7: searchEntries
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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);
}
示例8: basicSelectFilterWithoutPaging
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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);
}
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:15,代碼來源:TransferTimingPageRepositoryImplPureJooq.java
示例9: testValidCommandAndSearchReturn3Documents
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
@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")));
}
開發者ID:hmcts,項目名稱:document-management-store-app,代碼行數:31,代碼來源:StoredDocumentSearchControllerTests.java
示例10: getByDates
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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);
}
示例11: getAllProducts
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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);
}
示例12: index
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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";
}
示例13: listFilesByPage
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
@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;
}
示例14: addPagingToQuery
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
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());
}
}
示例15: orderBy
import org.springframework.data.domain.Pageable; //導入依賴的package包/類
/**
* 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;
}