com.psddev.dari.db.Query.getSorters()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(217)

本文整理了Java中com.psddev.dari.db.Query.getSorters方法的一些代码示例,展示了Query.getSorters的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getSorters方法的具体详情如下:
包路径:com.psddev.dari.db.Query
类名称:Query
方法名:getSorters

Query.getSorters介绍

[英]Returns the list of sorters applied to the result.
[中]返回应用于结果的分类器列表。

代码示例

代码示例来源:origin: perfectsense/dari

  1. /** Adds the given {@code sorter}. */
  2. public Query<E> sort(Sorter sorter) {
  3. getSorters().add(sorter);
  4. return this;
  5. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public Iterator<T> iterator() {
  3. return query.getSorters().isEmpty()
  4. ? new ByIdIterator<T>(query, fetchSize)
  5. : new PaginatedIterator<T>(query, fetchSize);
  6. }
  7. }

代码示例来源:origin: perfectsense/dari

  1. public ByIdIterator(Query<T> query, int fetchSize) {
  2. if (!query.getSorters().isEmpty()) {
  3. throw new IllegalArgumentException("Can't iterate over a query that has sorters!");
  4. }
  5. this.query = query.clone().timeout(0.0).sortAscending("_type").sortAscending("_id");
  6. this.fetchSize = fetchSize > 0 ? fetchSize : 200;
  7. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> Iterable<T> readIterable(Query<T> query, int fetchSize) {
  3. if (query.getSorters().isEmpty()) {
  4. if (!ObjectUtils.to(boolean.class, query.getOptions().get(DISABLE_BY_ID_ITERATOR_OPTION))) {
  5. return ByIdIterator.iterable(query, fetchSize);
  6. }
  7. }
  8. return selectIterable(buildSelectStatement(query), fetchSize, query);
  9. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. public Query<?> toPreviousQuery(State state) {
  2. String sortFieldName = getSortFieldName();
  3. Query<?> query = toQuery().and(sortFieldName + " <= ? and _id != ?", state.get(sortFieldName), state.getId());
  4. for (ListIterator<Sorter> i = query.getSorters().listIterator(); i.hasNext();) {
  5. Sorter sorter = i.next();
  6. if (Sorter.ASCENDING_OPERATOR.equals(sorter.getOperator())) {
  7. List<Object> options = sorter.getOptions();
  8. if (options != null
  9. && options.size() > 0
  10. && sortFieldName.equals(options.get(0))) {
  11. i.set(new Sorter(Sorter.DESCENDING_OPERATOR, options));
  12. }
  13. }
  14. }
  15. return query;
  16. }

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Maps all keys used in this query to the fields of the types in the
  3. * given {@code environment}. This is a helper method for database
  4. * implementations and isn't meant for general consumption.
  5. *
  6. * @see #mapEmbeddedKey
  7. */
  8. public Map<String, MappedKey> mapEmbeddedKeys(DatabaseEnvironment environment) {
  9. Map<String, MappedKey> mappedKeys = new HashMap<String, MappedKey>();
  10. addMappedPredicate(mappedKeys, environment, getPredicate());
  11. for (Sorter sorter : getSorters()) {
  12. Object first = sorter.getOptions().get(0);
  13. if (first instanceof String) {
  14. addMappedKey(mappedKeys, environment, (String) first);
  15. }
  16. }
  17. return mappedKeys;
  18. }

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : getSorters()) {
  2. codeBuilder.append(".sort(\"");
  3. codeBuilder.append(sorter.getOperator());

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Returns a list of values to be matched against the ID if and only if
  3. * the query contains a single predicate in the form of {@code _id = ?}.
  4. *
  5. * @return {@code null} if the query matches against anything other than ID.
  6. */
  7. public List<Object> findIdOnlyQueryValues() {
  8. if (getSorters().isEmpty()) {
  9. Predicate predicate = getPredicate();
  10. if (predicate instanceof ComparisonPredicate) {
  11. ComparisonPredicate comparison = (ComparisonPredicate) predicate;
  12. if (ID_KEY.equals(comparison.getKey())
  13. && PredicateParser.EQUALS_ANY_OPERATOR.equals(comparison.getOperator())
  14. && comparison.findValueQuery() == null) {
  15. return comparison.getValues();
  16. }
  17. }
  18. }
  19. return null;
  20. }

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. addOrderByClause(orderByBuilder, sorter, false, true);

代码示例来源:origin: perfectsense/dari

  1. /** Builds MongoDB query based on the given {@code query}. */
  2. public DBObject buildMongoSort(Query<?> query) {
  3. List<Sorter> sorters = query.getSorters();
  4. if (sorters.isEmpty()) {
  5. return new BasicDBObject();
  6. }
  7. BasicDBObject mongoSorter = new BasicDBObject();
  8. for (Sorter sorter : sorters) {
  9. String operator = sorter.getOperator();
  10. if (Sorter.ASCENDING_OPERATOR.equals(operator)) {
  11. String indexKey = query.mapEmbeddedKey(getEnvironment(), (String) sorter.getOptions().get(0)).getIndexKey(null);
  12. mongoSorter.append(indexKey, 1);
  13. } else if (Sorter.DESCENDING_OPERATOR.equals(operator)) {
  14. String indexKey = query.mapEmbeddedKey(getEnvironment(), (String) sorter.getOptions().get(0)).getIndexKey(null);
  15. mongoSorter.append(indexKey, -1);
  16. } else {
  17. throw new UnsupportedSorterException(this, sorter);
  18. }
  19. }
  20. return mongoSorter;
  21. }

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. String op = sorter.getOperator();

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. addOrderByClause(orderByBuilder, sorter, false, true);

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. codeBuilder.append(".sort(\"");
  3. codeBuilder.append(sorter.getOperator());

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> T readFirst(Query<T> query) {
  3. if (query.getSorters().isEmpty()) {

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public <T> T readFirst(Query<T> query) {
  3. if (query.getSorters().isEmpty()) {

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. String operator = sorter.getOperator();
  3. boolean isAscending = Sorter.ASCENDING_OPERATOR.equals(operator);

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public boolean equals(Object other) {
  3. if (this == other) {
  4. return true;
  5. } else if (other instanceof Query) {
  6. Query<?> otherQuery = (Query<?>) other;
  7. return ObjectUtils.equals(group, otherQuery.group)
  8. && ObjectUtils.equals(objectClass, otherQuery.objectClass)
  9. && ObjectUtils.equals(predicate, otherQuery.predicate)
  10. && ObjectUtils.equals(getSorters(), otherQuery.getSorters())
  11. && ObjectUtils.equals(getDatabase(), otherQuery.getDatabase())
  12. && ObjectUtils.equals(getFields(), otherQuery.getFields())
  13. && ObjectUtils.equals(getOptions(), otherQuery.getOptions())
  14. && isResolveToReferenceOnly == otherQuery.isResolveToReferenceOnly
  15. && ObjectUtils.equals(timeout, otherQuery.timeout);
  16. } else {
  17. return false;
  18. }
  19. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public int hashCode() {
  3. return ObjectUtils.hashCode(
  4. getGroup(),
  5. getObjectClass(),
  6. getPredicate(),
  7. getSorters(),
  8. getDatabase(),
  9. getFields(),
  10. getOptions(),
  11. isResolveToReferenceOnly(),
  12. getTimeout());
  13. }

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. SortField<?> sortField = database.sort(sorter, new SqlSortOptions(recordTableAlias));

代码示例来源:origin: perfectsense/dari

  1. for (Sorter sorter : query.getSorters()) {
  2. String op = sorter.getOperator();

相关文章