org.springframework.data.domain.Sort

Here are the examples of the java api org.springframework.data.domain.Sort taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

772 Examples 7

19 Source : QueryUtils.java
with Apache License 2.0
from zhongxunking

/**
 * 查询工具类
 */
public final clreplaced QueryUtils {

    /**
     * 查询排序
     */
    public static final Sort QUERY_SORT = Sort.by(new Sort.Order(Sort.Direction.DESC, "id"));

    /**
     * 构建通用分页查询附件
     *
     * @param daoClreplaced dao类型
     * @return 附件
     */
    public static Map<Object, Object> buildCommonQueryAttachment(Clreplaced daoClreplaced) {
        Map<Object, Object> attachment = new HashMap<>();
        attachment.put(CommonQueries.DAO_CLreplaced_KEY, daoClreplaced);
        attachment.put(CommonQueries.SORT_KEY, QUERY_SORT);
        return attachment;
    }
}

19 Source : QueryUtils.java
with Apache License 2.0
from zhongxunking

/**
 * 查询工具类
 */
public final clreplaced QueryUtils {

    /**
     * 查询排序
     */
    public static final Sort QUERY_SORT = Sort.by(new Sort.Order(Sort.Direction.DESC, "id"));

    /**
     * 构建通用查询附件
     *
     * @param daoClreplaced dao类型
     * @return 附件
     */
    public static Map<Object, Object> buildCommonQueryAttachment(Clreplaced daoClreplaced) {
        Map<Object, Object> attachment = new HashMap<>();
        attachment.put(CommonQueries.DAO_CLreplaced_KEY, daoClreplaced);
        attachment.put(CommonQueries.SORT_KEY, QUERY_SORT);
        return attachment;
    }
}

19 Source : AccountService.java
with Apache License 2.0
from xunibidev

/**
 * 分页获取账户
 * @param pageNo
 * @param pageSize
 * @return
 */
public List<Account> find(int pageNo, int pageSize) {
    Sort.Order order = new Sort.Order(Sort.Direction.ASC, "_id");
    Sort sort = new Sort(order);
    PageRequest page = new PageRequest(pageNo, pageSize, sort);
    Query query = new Query();
    query.with(page);
    return mongoTemplate.find(query, Account.clreplaced, getCollectionName());
}

19 Source : AdvertiseService.java
with Apache License 2.0
from xunibidev

public List<MemberAdvertise> getAllAdvertiseByMemberId(Long memberId, Sort sort) {
    List<Advertise> list = advertiseDao.findAllByMemberIdAndStatusNot(memberId, AdvertiseControlStatus.TURNOFF, sort);
    return list.stream().map(x -> MemberAdvertise.toMemberAdvertise(x)).collect(Collectors.toList());
}

19 Source : PageModel.java
with Apache License 2.0
from xunibidev

public Pageable getPageable() {
    Sort sort = getSort();
    if (sort == null) {
        return new PageRequest(pageNo - 1, pageSize);
    }
    return new PageRequest(pageNo - 1, pageSize, sort);
}

19 Source : CommonService.java
with Apache License 2.0
from xujeff

/**
 * 根据查询条件和排序条件获取某个结果集列表
 * @param spec
 * @param sort
 * @return
 */
public List<E> findAll(Specification<E> spec, Sort sort) {
    return commonDao.findAll(spec);
}

19 Source : PermittedRepository.java
with Apache License 2.0
from xm-online

private static String applyOrder(String sql, Sort sort) {
    StringBuilder builder = new StringBuilder(sql);
    if (sort != null && !sort.equals(Sort.unsorted())) {
        builder.append(ORDER_BY_SQL);
        String sep = "";
        for (Sort.Order order : sort) {
            builder.append(sep).append(order.getProperty()).append(" ").append(order.getDirection());
            sep = ", ";
        }
    }
    return builder.toString();
}

19 Source : UserController.java
with Apache License 2.0
from xiuhuai

@GetMapping("/user")
public ModelAndView userlist(@RequestParam(value = "start", defaultValue = "0") Integer start, @RequestParam(value = "limit", defaultValue = "5") Integer limit) {
    start = start < 0 ? 0 : start;
    // Sort sort = new Sort(Sort.DEFAULT_DIRECTION, "categoryid","desc");
    Sort sort = new Sort(Sort.Direction.DESC, "id");
    // Pageable pageable = new PageRequest(start, limit, sort);
    Pageable pageable = new PageRequest(start, limit, sort);
    Page<User> page = userRepository.findAll(pageable);
    ModelAndView mav = new ModelAndView("user/userlist");
    mav.addObject("page", page);
    return mav;
}

19 Source : EntityService.java
with Apache License 2.0
from xiangxik

public Iterable<T> findAll(Predicate predicate, Sort sort) {
    return getRepository().findAll(predicate, sort);
}

19 Source : EntityService.java
with Apache License 2.0
from xiangxik

public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
    return getRepository().findAll(example, sort);
}

19 Source : EntityService.java
with Apache License 2.0
from xiangxik

public List<T> findAll(Sort sort) {
    return getRepository().findAll(sort);
}

19 Source : SettingController.java
with MIT License
from tarpha

@GetMapping(value = "/watch-list/search")
public List<WatchList> searchWatchList(@RequestParam("replacedle") String replacedle, Sort sort) {
    return watchListRepository.findByreplacedleContaining(replacedle, sort);
}

19 Source : SettingController.java
with MIT License
from tarpha

@GetMapping(value = "/download-list")
public List<DownloadList> getDownloadList(Sort sort) {
    return downloadListRepository.findAll(sort);
}

19 Source : SpannerStatementQueryExecutor.java
with Apache License 2.0
from spring-cloud

public static StringBuilder applySort(Sort sort, StringBuilder sql, SpannerPersistentEnreplacedy<?> persistentEnreplacedy) {
    if (sort == null || sort.isUnsorted()) {
        return sql;
    }
    sql.append(" ORDER BY ");
    StringJoiner sj = new StringJoiner(" , ");
    sort.iterator().forEachRemaining((o) -> {
        SpannerPersistentProperty property = persistentEnreplacedy.getPersistentProperty(o.getProperty());
        String sortedPropertyName = (property != null) ? property.getColumnName() : o.getProperty();
        String sortedProperty = o.isIgnoreCase() ? "LOWER(" + sortedPropertyName + ")" : sortedPropertyName;
        sj.add(sortedProperty + (o.isAscending() ? " ASC" : " DESC"));
    });
    return sql.append(sj);
}

19 Source : SpannerPageableQueryOptions.java
with Apache License 2.0
from spring-cloud

/**
 * Encapsulates Cloud Spanner query options with sort and paging.
 *
 * @author Chengyuan Zhao
 * @author Mike Eltsufin
 *
 * @since 1.1
 */
public clreplaced SpannerPageableQueryOptions extends SpannerQueryOptions {

    private Integer limit;

    private Long offset;

    private Sort sort = Sort.unsorted();

    public Integer getLimit() {
        return this.limit;
    }

    public SpannerPageableQueryOptions setLimit(Integer limit) {
        this.limit = limit;
        return this;
    }

    public Long getOffset() {
        return this.offset;
    }

    public SpannerPageableQueryOptions setOffset(Long offset) {
        this.offset = offset;
        return this;
    }

    public Sort getSort() {
        return this.sort;
    }

    public SpannerPageableQueryOptions setSort(Sort sort) {
        replacedert.notNull(sort, "A valid sort is required.");
        this.sort = sort;
        return this;
    }

    @Override
    public SpannerPageableQueryOptions addQueryOption(Options.QueryOption queryOption) {
        super.addQueryOption(queryOption);
        return this;
    }

    @Override
    public SpannerPageableQueryOptions setIncludeProperties(Set<String> includeProperties) {
        super.setIncludeProperties(includeProperties);
        return this;
    }

    @Override
    public SpannerPageableQueryOptions setTimestampBound(TimestampBound timestampBound) {
        super.setTimestampBound(timestampBound);
        return this;
    }

    @Override
    public SpannerPageableQueryOptions setTimestamp(Timestamp timestamp) {
        super.setTimestamp(timestamp);
        return this;
    }

    @Override
    public SpannerPageableQueryOptions setAllowPartialRead(boolean allowPartialRead) {
        super.setAllowPartialRead(allowPartialRead);
        return this;
    }
}

19 Source : PartTreeDatastoreQueryTests.java
with Apache License 2.0
from spring-cloud

public List<Trade> tradeMethod(String action, String symbol, double pless, double pgreater, Sort sort) {
    return null;
}

19 Source : DatastoreQueryOptions.java
with Apache License 2.0
from spring-cloud

/**
 * Encapsulates Cloud Datastore query options.
 *
 * @author Dmitry Solomakha
 */
public final clreplaced DatastoreQueryOptions {

    private Integer limit;

    private Integer offset;

    private Sort sort;

    private Cursor cursor;

    private DatastoreQueryOptions(Integer limit, Integer offset, Sort sort, Cursor cursor) {
        this.limit = limit;
        this.offset = offset;
        this.sort = sort;
        this.cursor = cursor;
    }

    public Integer getLimit() {
        return this.limit;
    }

    public Integer getOffset() {
        return this.offset;
    }

    public Sort getSort() {
        return this.sort;
    }

    public Cursor getCursor() {
        return this.cursor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClreplaced() != o.getClreplaced()) {
            return false;
        }
        DatastoreQueryOptions that = (DatastoreQueryOptions) o;
        return Objects.equals(getLimit(), that.getLimit()) && Objects.equals(getOffset(), that.getOffset()) && Objects.equals(getSort(), that.getSort()) && Objects.equals(getCursor(), that.getCursor());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getLimit(), getOffset(), getSort(), getCursor());
    }

    public static clreplaced Builder {

        private Integer limit;

        private Integer offset;

        private Sort sort;

        private Cursor cursor;

        public Builder setLimit(Integer limit) {
            this.limit = limit;
            return this;
        }

        public Builder setOffset(Integer offset) {
            this.offset = offset;
            return this;
        }

        public Builder setSort(Sort sort) {
            this.sort = sort;
            return this;
        }

        public Builder setCursor(Cursor cursor) {
            this.cursor = cursor;
            return this;
        }

        public DatastoreQueryOptions build() {
            return new DatastoreQueryOptions(this.limit, this.offset, this.sort, this.cursor);
        }
    }
}

19 Source : PageUtil.java
with Apache License 2.0
from reportportal

/**
 * Iterates over all pages found
 *
 * @param getFunc  Get Page function
 * @param consumer Page processor
 * @param <T>      Type of page enreplacedy
 */
public static <T> void iterateOverPages(Sort sort, Function<Pageable, Page<T>> getFunc, Consumer<List<T>> consumer) {
    iterateOverPages(DEFAULT_PAGE_SIZE, sort, getFunc, consumer);
}

19 Source : SimplePageBuilder.java
with Apache License 2.0
from realXuJiang

public static Pageable generate(int page, int size, Sort sort) {
    if (sort == null)
        return new PageRequest(page, size);
    return new PageRequest(page, size, sort);
}

19 Source : SimplePageBuilder.java
with Apache License 2.0
from realXuJiang

public static Pageable generate(int page, Sort sort) {
    return generate(page, size, sort);
}

19 Source : PermissionServiceImpl.java
with GNU General Public License v3.0
from qiushi123

/**
 * @author - langhsu on 2018/2/11
 */
@Service
@Transactional(readOnly = true)
public clreplaced PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionRepository permissionRepository;

    private Sort sort = Sort.by(new Sort.Order(Sort.Direction.DESC, "weight"), new Sort.Order(Sort.Direction.ASC, "id"));

    @Override
    public Page<Permission> paging(Pageable pageable, String name) {
        Page<Permission> page = permissionRepository.findAll((root, query, builder) -> {
            Predicate predicate = builder.conjunction();
            if (StringUtils.isNoneBlank(name)) {
                predicate.getExpressions().add(builder.like(root.get("name"), "%" + name + "%"));
            }
            query.orderBy(builder.desc(root.get("id")));
            return predicate;
        }, pageable);
        return page;
    }

    @Override
    public List<PermissionTree> tree() {
        List<Permission> data = permissionRepository.findAll(sort);
        List<PermissionTree> results = new LinkedList<>();
        Map<Long, PermissionTree> map = new LinkedHashMap<>();
        for (Permission po : data) {
            PermissionTree m = new PermissionTree();
            BeanUtils.copyProperties(po, m);
            map.put(po.getId(), m);
        }
        for (PermissionTree m : map.values()) {
            if (m.getParentId() == 0) {
                results.add(m);
            } else {
                PermissionTree p = map.get(m.getParentId());
                if (p != null) {
                    p.addItem(m);
                }
            }
        }
        return results;
    }

    @Override
    public List<PermissionTree> tree(int parentId) {
        List<Permission> list = permissionRepository.findAllByParentId(parentId, sort);
        List<PermissionTree> results = new ArrayList<>();
        list.forEach(po -> {
            PermissionTree menu = new PermissionTree();
            BeanUtils.copyProperties(po, menu);
            results.add(menu);
        });
        return results;
    }

    @Override
    public List<Permission> list() {
        return permissionRepository.findAll(new Sort(Sort.Direction.DESC, "id"));
    }

    @Override
    public Permission get(long id) {
        return permissionRepository.findById(id).get();
    }
}

19 Source : LotService.java
with GNU Affero General Public License v3.0
from progilone

@Transactional(readOnly = true)
public Page<Lot> search(final String search, final List<String> libraries, final List<String> projects, final boolean active, final List<LotStatus> lotStatuses, final List<String> providers, final Integer docNumber, final List<String> fileFormats, final List<String> identifiers, final Integer page, final Integer size, final List<String> sorts) {
    Sort sort = SortUtils.getSort(sorts);
    if (sort == null) {
        sort = new Sort("label");
    }
    final Pageable pageRequest = new PageRequest(page, size, sort);
    return lotRepository.search(new LotSearchBuilder().setSearch(search).setLibraries(libraries).setProjects(projects).setActive(active).setLotStatuses(lotStatuses).setProviders(providers).setDocNumber(docNumber).setFileFormats(fileFormats).setIdentifiers(identifiers), pageRequest);
}

19 Source : ImportReportService.java
with GNU Affero General Public License v3.0
from progilone

@Transactional(readOnly = true)
public Page<ImportReport> findAllByLibraryIn(final List<String> libraries, final int page, final int size) {
    final Sort order = new Sort(Sort.Direction.DESC, "createdDate");
    final Pageable pageable = new PageRequest(page, size, order);
    if (CollectionUtils.isEmpty(libraries)) {
        return importReportRepository.findAll(pageable);
    } else {
        return importReportRepository.findByLibraryIdentifierIn(libraries, pageable);
    }
}

19 Source : DocUnitService.java
with GNU Affero General Public License v3.0
from progilone

@Transactional(readOnly = true)
public Page<DocUnit> search(final String search, final boolean hasDigitalDoreplacedents, final boolean active, final boolean archived, final boolean nonArchived, final boolean archivable, final boolean nonArchivable, final boolean distributed, final boolean nonDistributed, final boolean distributable, final boolean nonDistributable, final List<String> libraries, final List<String> projects, final List<String> lots, final List<String> trains, final List<String> statuses, final LocalDate lastModifiedDateFrom, final LocalDate lastModifiedDateTo, final LocalDate createdDateFrom, final LocalDate createdDateTo, final List<String> identifiers, final Integer page, final Integer size, final List<String> sorts) {
    Sort sort = SortUtils.getSort(sorts);
    if (sort == null) {
        sort = new Sort(DocUnit_.pgcnId.getName());
    }
    final Pageable pageRequest = new PageRequest(page, size, sort);
    return docUnitRepository.search(search, hasDigitalDoreplacedents, active, archived, nonArchived, archivable, nonArchivable, distributed, nonDistributed, distributable, nonDistributable, libraries, projects, lots, trains, statuses, lastModifiedDateFrom, lastModifiedDateTo, createdDateFrom, createdDateTo, identifiers, pageRequest);
}

19 Source : ConditionReportService.java
with GNU Affero General Public License v3.0
from progilone

/**
 * Recherche paginée de constats d'états
 *
 * @param libraries
 *         Filtrage: sites
 * @param dimensions
 *         Filtrage: dimensions du doreplacedent
 * @param from
 *         Filtrage: date min du constat d'état
 * @param to
 *         Filtrage: date max du constat d'état
 * @param descriptions
 *         Filtrage: descriptions
 * @param docIdentifiers
 * @param page
 *         Pagination: n° de page
 * @param size
 *         Pagination: taille de la page
 * @param sorts
 *         Critères de tri
 * @return
 */
@Transactional(readOnly = true)
public Page<SearchResult> search(final List<String> libraries, final List<String> projects, final List<String> lots, final ConditionReportRepositoryCustom.DimensionFilter dimensions, final LocalDate from, final LocalDate to, final List<String> descriptions, final List<String> docIdentifiers, final boolean toValidateOnly, final Integer page, final Integer size, final List<String> sorts) {
    Sort sort = SortUtils.getSort(sorts);
    if (sort == null) {
        sort = new Sort(DocUnit_.pgcnId.getName());
    }
    final Pageable pageable = new PageRequest(page, size, sort);
    // Recherche de la page d'identifiants
    final Page<String> pageOfIds = conditionReportRepository.search(libraries, projects, lots, from, to, dimensions, parseDescriptions(descriptions), docIdentifiers, toValidateOnly, pageable);
    if (pageOfIds.getNumberOfElements() > 0) {
        final List<SearchResult> results = findSearchResultByIdentifierIn(pageOfIds.getContent(), toValidateOnly);
        return new PageImpl<>(results, pageable, pageOfIds.getTotalElements());
    } else {
        return new PageImpl<>(Collections.emptyList(), pageable, pageOfIds.getTotalElements());
    }
}

19 Source : BibliographicRecordService.java
with GNU Affero General Public License v3.0
from progilone

@Transactional(readOnly = true)
public Page<BibliographicRecord> search(final String search, final List<String> libraries, final List<String> projects, final List<String> lots, final List<String> statuses, final List<String> trains, final LocalDate lastModifiedDateFrom, final LocalDate lastModifiedDateTo, final LocalDate createdDateFrom, final LocalDate createdDateTo, final Boolean orphan, final Integer page, final Integer size, final List<String> sorts) {
    Sort sort = SortUtils.getSort(sorts);
    if (sort == null) {
        sort = new Sort("docUnit.label");
    }
    final Pageable pageRequest = new PageRequest(page, size, sort);
    return bibliographicRecordRepository.search(search, libraries, projects, lots, statuses, trains, lastModifiedDateFrom, lastModifiedDateTo, createdDateFrom, createdDateTo, orphan, pageRequest);
}

19 Source : DocUnitRepositoryImpl.java
with GNU Affero General Public License v3.0
from progilone

/**
 * Gère le tri
 *
 * @param sort
 * @param query
 * @param doc
 * @param project
 * @param lot
 * @return
 */
protected JPQLQuery applySorting(final Sort sort, final JPQLQuery query, final QDocUnit doc, final QProject project, final QLot lot) {
    final List<OrderSpecifier> orders = new ArrayList<>();
    if (sort == null) {
        return query;
    }
    for (final Sort.Order order : sort) {
        final Order qOrder = order.isAscending() ? Order.ASC : Order.DESC;
        switch(order.getProperty()) {
            case "pgcnId":
                orders.add(new OrderSpecifier(qOrder, doc.pgcnId));
                break;
            case "label":
                orders.add(new OrderSpecifier(qOrder, doc.label));
                break;
            case "project.name":
                orders.add(new OrderSpecifier(qOrder, project.name));
                break;
            case "lot.label":
                orders.add(new OrderSpecifier(qOrder, lot.label));
                break;
            case "parent.pgcnId":
                orders.add(new OrderSpecifier(qOrder, doc.parent.pgcnId));
                break;
            default:
                LOG.warn("Tri non implémenté: {}", order.getProperty());
                break;
        }
    }
    OrderSpecifier[] orderArray = new OrderSpecifier[orders.size()];
    orderArray = orders.toArray(orderArray);
    return query.orderBy(orderArray);
}

19 Source : RSQLJPASupport.java
with MIT License
from perplexhub

/**
 * Returns all enreplacedies matching the given {@link Specification} and {@link Sort}.
 *
 * @param jpaSpecificationExecutor JPA repository
 * @param rsqlQuery can be {@literal null}.
 * @param sort must not be {@literal null}.
 * @return never {@literal null}.
 */
public static List<?> findAll(JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery, Sort sort) {
    return jpaSpecificationExecutor.findAll(toSpecification(rsqlQuery), sort);
}

19 Source : AdminAuth.java
with MIT License
from odenktools

// =========================== #START GROUP# ==============================//
/**
 * Get all available groups on database.
 *
 * @param name search by name.
 * @param coded search by coded.
 * @param page pagenumber. Default 0.
 * @param size display limit, Default 10.
 * @param direction sorting "ASC OR DESC", default to DESC.
 * @return Groups Model.
 */
@RequestMapping(value = "/group/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEnreplacedy<?> findAllGroups(@RequestParam(name = "name", defaultValue = "") String name, @RequestParam(name = "coded", defaultValue = "") String coded, @RequestParam(required = false, defaultValue = "0") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false, defaultValue = "DESC") String direction) {
    List<String> sortProperties = new ArrayList<>();
    sortProperties.add("createdAt");
    Sort sort = new Sort(Sort.Direction.fromString(direction), sortProperties);
    Page<Group> listData = this.groupService.findUserByNamedOrCoded(name, coded, sort, PageRequest.of(page, size));
    return new ResponseEnreplacedy<>(listData, HttpStatus.FOUND);
}

19 Source : SqlGenerator.java
with Apache License 2.0
from naver

private List<OrderByField> extractOrderByFields(Sort sort) {
    return // 
    sort.stream().map(// 
    this::orderToOrderByField).collect(Collectors.toList());
}

19 Source : SqlGenerator.java
with Apache License 2.0
from naver

private SelectBuilder.SelectOrdered selectBuilder(Collection<SqlIdentifier> keyColumns, Sort sort, Pageable pageable) {
    SelectBuilder.SelectOrdered sortable = this.selectBuilder(keyColumns);
    sortable = applyPagination(pageable, sortable);
    return sortable.orderBy(extractOrderByFields(sort));
}

19 Source : Page.java
with MIT License
from microapp-store

public void setSort(Sort sort) {
    this.sort = sort;
}

19 Source : RoleServiceImpl.java
with Apache License 2.0
from mawensen

@Override
public List<RoleDto> queryAll() {
    Sort sort = new Sort(Sort.Direction.ASC, "level");
    return roleMapper.toDto(roleRepository.findAll(sort));
}

19 Source : OffsetBasedPageRequest.java
with GNU General Public License v3.0
from marcinadd

public clreplaced OffsetBasedPageRequest implements Pageable, Serializable {

    private final Sort sort;

    private long limit;

    private long offset;

    public OffsetBasedPageRequest(long offset, long limit, Sort sort) {
        this.limit = limit;
        this.offset = offset;
        this.sort = sort;
    }

    public OffsetBasedPageRequest(long offset, long limit) {
        this(offset, limit, Sort.by(Sort.Direction.ASC, "id"));
    }

    @Override
    public int getPageNumber() {
        return (int) (offset / limit);
    }

    @Override
    public int getPageSize() {
        return (int) limit;
    }

    @Override
    public long getOffset() {
        return offset;
    }

    @Override
    public Sort getSort() {
        return sort;
    }

    @Override
    public Pageable next() {
        return new OffsetBasedPageRequest(getOffset() + getPageSize(), getPageSize(), getSort());
    }

    public OffsetBasedPageRequest previous() {
        return hasPrevious() ? new OffsetBasedPageRequest(getOffset() - getPageSize(), getPageSize(), getSort()) : this;
    }

    @Override
    public Pageable previousOrFirst() {
        return hasPrevious() ? previous() : first();
    }

    @Override
    public Pageable first() {
        return new OffsetBasedPageRequest(0, getPageSize(), getSort());
    }

    @Override
    public boolean hasPrevious() {
        return offset > limit;
    }
}

19 Source : ResourceService.java
with Apache License 2.0
from luotuo

/**
 * @name 搜索资源
 * @param resourceType 资源类型
 * @param resourceName 资源名称
 * @param page 分页的页码
 * @param size 每页的数量
 * @return
 * @throws Exception
 */
public Object search(String resourceType, String resourceName, int page, int size) throws Exception {
    addResourcesAuto();
    Sort sort = new Sort(Sort.Direction.DESC, "id");
    PageRequest pageRequest = new PageRequest(page, size, sort);
    Specifications<Resource> conditions = null;
    if (StringUtils.isNotBlank(resourceName)) {
        if (conditions == null)
            conditions = Specifications.where(SpecificationFactory.containsLike("resource_name", resourceName));
        else
            conditions = conditions.and(SpecificationFactory.containsLike("resource_name", resourceName));
    }
    if (StringUtils.isNotBlank(resourceType)) {
        if (conditions == null)
            conditions = Specifications.where(SpecificationFactory.containsLike("resource_type", resourceType));
        else
            conditions = conditions.and(SpecificationFactory.containsLike("resource_type", resourceType));
    }
    Page<Resource> page1 = null;
    if (conditions == null)
        page1 = resourceRepository.findAll(pageRequest);
    else
        page1 = resourceRepository.findAll(conditions, pageRequest);
    return page1;
}

19 Source : PageUtils.java
with MIT License
from liuweijw

public static PageRequest of(PageParams pageParams, Sort sort) {
    return new PageRequest(pageParams.getCurrentPage() - 1, pageParams.getPageSize(), sort);
}

19 Source : PageRequest.java
with GNU General Public License v3.0
from liusy456

public Pageable getPageable(Sort sort) {
    return new org.springframework.data.domain.PageRequest(page, pageSize, sort);
}

19 Source : SolrPageRequest.java
with Apache License 2.0
from learningtcc

/**
 * Solr specific implementation of {@code Pageable} allowing zero sized pages.
 *
 * @author Christoph Strobl
 */
public clreplaced SolrPageRequest implements Pageable {

    private Sort sort;

    private int page;

    private int size;

    /**
     * Creates a new {@link SolrPageRequest}. Pages are zero indexed.
     *
     * @param page
     *            zero-based page index.
     * @param size
     *            the size of the page to be returned.
     */
    public SolrPageRequest(int page, int size) {
        this(page, size, null);
    }

    /**
     * Creates a new {@link SolrPageRequest} with sort parameters applied.
     *
     * @param page
     *            zero-based page index.
     * @param size
     *            the size of the page to be returned.
     * @param direction
     *            the direction of the
     *            {@link org.springframework.data.domain.Sort} to be specified,
     *            can be {@literal null}.
     * @param properties
     *            the properties to sort by, must not be {@literal null} or
     *            empty.
     */
    public SolrPageRequest(int page, int size, Direction direction, String... properties) {
        this(page, size, new Sort(direction, properties));
    }

    /**
     * Creates a new {@link SolrPageRequest} with sort parameters applied.
     *
     * @param page
     *            zero-based page index.
     * @param size
     *            the size of the page to be returned.
     * @param sort
     *            can be {@literal null}.
     */
    public SolrPageRequest(int page, int size, Sort sort) {
        this.page = page;
        this.size = size;
        this.sort = sort;
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#getPageNumber()
	 */
    @Override
    public int getPageNumber() {
        return page;
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#getPageSize()
	 */
    @Override
    public int getPageSize() {
        return this.size;
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#getOffset()
	 */
    @Override
    public int getOffset() {
        return page * size;
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#getSort()
	 */
    @Override
    public Sort getSort() {
        return sort;
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#next()
	 */
    @Override
    public Pageable next() {
        return new SolrPageRequest(getPageNumber() + 1, getPageSize(), getSort());
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#previousOrFirst()
	 */
    @Override
    public Pageable previousOrFirst() {
        return hasPrevious() ? previous() : first();
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#first()
	 */
    @Override
    public Pageable first() {
        return new SolrPageRequest(0, getPageSize(), getSort());
    }

    /*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.data.domain.Pageable#hasPrevious()
	 */
    @Override
    public boolean hasPrevious() {
        return page > 0;
    }

    /**
     * Returns the {@link org.springframework.data.domain.Pageable} requesting
     * the previous {@link org.springframework.data.domain.Page}.
     *
     * @return
     */
    public Pageable previous() {
        return getPageNumber() == 0 ? this : new SolrPageRequest(getPageNumber() - 1, getPageSize(), getSort());
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + page;
        result = prime * result + size;
        result = prime * result + ((sort == null) ? 0 : sort.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof Pageable)) {
            return false;
        }
        Pageable other = (Pageable) obj;
        if (page != other.getPageNumber()) {
            return false;
        }
        if (size != other.getPageSize()) {
            return false;
        }
        if (sort == null) {
            if (other.getSort() != null) {
                return false;
            }
        } else if (!sort.equals(other.getSort())) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "SolrPageRequest [number=" + page + ", size=" + size + ", sort=" + sort + "]";
    }
}

19 Source : GroupOptions.java
with Apache License 2.0
from learningtcc

/**
 * Adds {@link org.springframework.data.domain.Sort} to instruct how to sort
 * elements within a single group.
 *
 * @param sort
 * @return
 */
public GroupOptions addSort(Sort sort) {
    if (sort == null) {
        return this;
    }
    if (this.sort == null) {
        this.sort = sort;
    } else {
        this.sort = this.sort.and(sort);
    }
    return this;
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<List<T>> findByEnreplacedyWithRefQuery(T baseBean, Sort sort, String matchingText, String... excludeFields) {
    return findByEnreplacedy(baseBean, sort, null, null, 0D, matchingText, false, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<Page<T>> searchByEnreplacedyForPageWithRefQuery(EnreplacedyByPage<T> enreplacedyByPage, Sort sort, Mode forPageMode, String... excludeFields) {
    return searchByEnreplacedyForPage(enreplacedyByPage, sort, null, null, 0D, null, forPageMode, false, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<List<T>> findByEnreplacedy(T baseBean, Sort sort, String matchingText, String... excludeFields) {
    return findByEnreplacedy(baseBean, sort, null, null, 0D, matchingText, true, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<Page<T>> searchByEnreplacedyForPage(EnreplacedyByPage<T> enreplacedyByPage, Sort sort, String pointFieldName, Point point, double rangeKm, Mode forPageMode, String... excludeFields) {
    return searchByEnreplacedyForPage(enreplacedyByPage, sort, pointFieldName, point, rangeKm, null, forPageMode, true, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<List<T>> findByEnreplacedyWithRefQuery(T baseBean, Sort sort, String pointFieldName, Point point, double rangeKm, String... excludeFields) {
    return findByEnreplacedy(baseBean, sort, pointFieldName, point, rangeKm, null, false, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<List<T>> findByEnreplacedyWithRefQuery(T baseBean, Sort sort, String... excludeFields) {
    return findByEnreplacedy(baseBean, sort, null, null, 0D, null, false, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<List<T>> findByEnreplacedy(T baseBean, Sort sort, String... excludeFields) {
    return findByEnreplacedy(baseBean, sort, null, null, 0D, null, true, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<Page<T>> searchByEnreplacedyForPageWithRefQuery(EnreplacedyByPage<T> enreplacedyByPage, Sort sort, String pointFieldName, Point point, double rangeKm, Mode forPageMode, String... excludeFields) {
    return searchByEnreplacedyForPage(enreplacedyByPage, sort, pointFieldName, point, rangeKm, null, forPageMode, false, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<Page<T>> searchByEnreplacedyForPage(EnreplacedyByPage<T> enreplacedyByPage, Sort sort, Mode forPageMode, String... excludeFields) {
    return searchByEnreplacedyForPage(enreplacedyByPage, sort, null, null, 0D, null, forPageMode, true, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<Page<T>> searchByEnreplacedyForPageWithRefQuery(EnreplacedyByPage<T> enreplacedyByPage, Sort sort, String matchingText, Mode forPageMode, String... excludeFields) {
    return searchByEnreplacedyForPage(enreplacedyByPage, sort, null, null, 0D, matchingText, forPageMode, false, excludeFields);
}

19 Source : MongoSpringDataBaseDao.java
with Apache License 2.0
from KeRan213539

@Override
public Mono<List<T>> findByEnreplacedy(T baseBean, Sort sort, String pointFieldName, Point point, double rangeKm, String... excludeFields) {
    return findByEnreplacedy(baseBean, sort, pointFieldName, point, rangeKm, null, true, excludeFields);
}

See More Examples