当前位置: 首页>>代码示例>>Java>>正文


Java Pageable类代码示例

本文整理汇总了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);
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:11,代码来源:UserRepository.java

示例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));
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:23,代码来源:PermittedRepository.java

示例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);
}
 
开发者ID:asanzdiego,项目名称:codemotion-2017-taller-de-jhipster,代码行数:20,代码来源:TaskResource.java

示例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);
    }
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:12,代码来源:SnowdropTemplate.java

示例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()));
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:12,代码来源:JpaRelationDao.java

示例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);
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:18,代码来源:PrivilegeResource.java

示例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);
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:17,代码来源:EntryResource.java

示例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);
}
 
开发者ID:Microsoft,项目名称:MTC_Labrat,代码行数:20,代码来源:AuditResource.java

示例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);
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:15,代码来源:ProductResource.java

示例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";
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:27,代码来源:StoresController.java

示例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;
}
 
开发者ID:waylau,项目名称:mongodb-file-server,代码行数:13,代码来源:FileServiceImpl.java

示例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());
    }
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:12,代码来源:AbstractQueryAdapter.java

示例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;
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:14,代码来源:YadaSql.java


注:本文中的org.springframework.data.domain.Pageable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。