com.vaadin.data.provider.Query.getSortOrders()方法的使用及代码示例

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

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

Query.getSortOrders介绍

[英]Gets the sorting for items to fetch. This list of sort orders is used for sorting backends. The sort orders are only used when fetching items, but not when counting the number of available items.

Note: Sort orders and in-memory sorting are mutually exclusive. If the DataProvider handles one, it should ignore the other.
[中]

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

private Query<T, F> mixInSortOrders(Query<T, F> query) {
  if (sortOrders.isEmpty()) {
    return query;
  }
  Set<String> sortedPropertyNames = query.getSortOrders().stream()
      .map(SortOrder::getSorted).collect(Collectors.toSet());
  List<QuerySortOrder> combinedSortOrders = Stream
      .concat(query.getSortOrders().stream(),
          sortOrders.stream()
              .filter(order -> !sortedPropertyNames
                  .contains(order.getSorted())))
      .collect(Collectors.toList());
  return new Query<>(query.getOffset(), query.getLimit(),
      combinedSortOrders, query.getInMemorySorting(),
      query.getFilter().orElse(null));
}

代码示例来源:origin: com.vaadin/vaadin-server

@Override
  public Stream<T> fetch(Query<T, C> t) {
    if (t instanceof HierarchicalQuery<?, ?>) {
      return dataProvider.fetch(new HierarchicalQuery<>(
          t.getOffset(), t.getLimit(), t.getSortOrders(),
          t.getInMemorySorting(), getFilter(t),
          ((HierarchicalQuery<T, C>) t).getParent()));
    }
    throw new IllegalArgumentException(
        "Hierarchical data provider doesn't support non-hierarchical queries");
  }
};

代码示例来源:origin: com.vaadin/vaadin-server

@Override
public int size(Query<T, C> t) {
  if (t instanceof HierarchicalQuery<?, ?>) {
    return dataProvider.size(new HierarchicalQuery<>(
        t.getOffset(), t.getLimit(), t.getSortOrders(),
        t.getInMemorySorting(), getFilter(t),
        ((HierarchicalQuery<T, C>) t).getParent()));
  }
  throw new IllegalArgumentException(
      "Hierarchical data provider doesn't support non-hierarchical queries");
}

代码示例来源:origin: com.vaadin/vaadin-server

@Override
public int size(Query<T, F> t) {
  return dataProvider.size(new Query<>(t.getOffset(), t.getLimit(),
      t.getSortOrders(), t.getInMemorySorting(), getFilter(t)));
}

代码示例来源:origin: com.vaadin/vaadin-server

@Override
public Stream<T> fetch(Query<T, F> t) {
  return dataProvider.fetch(new Query<>(t.getOffset(), t.getLimit(),
      t.getSortOrders(), t.getInMemorySorting(), getFilter(t)));
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Sets a CallbackDataProvider using the given fetch items callback and a
 * size callback.
 * <p>
 * This method is a shorthand for making a {@link CallbackDataProvider} that
 * handles a partial {@link Query} object.
 *
 * @param fetchItems
 *            a callback for fetching items
 * @param sizeCallback
 *            a callback for getting the count of items
 *
 * @see CallbackDataProvider
 * @see #setDataProvider(DataProvider)
 */
public void setDataProvider(FetchItemsCallback<T> fetchItems,
    SerializableSupplier<Integer> sizeCallback) {
  internalSetDataProvider(
      new CallbackDataProvider<>(
          q -> fetchItems.fetchItems(q.getSortOrders(),
              q.getOffset(), q.getLimit()),
          q -> sizeCallback.get()));
}

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

@Override
public QuerySort getQuerySort() {
  List<QuerySort> sorts = getDataProviderQuery().map(q -> q.getSortOrders())
      .orElse(Collections.emptyList()).stream().map(o -> sortFromOrder(o))
      .flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty()).collect(Collectors.toList());
  return sorts.isEmpty() ? null : QuerySort.of(sorts);
}

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

sorts.addAll((query.getSortOrders() == null) ? Collections.emptyList()
    : query.getSortOrders().stream().map(o -> sortFromOrder(o))
        .flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty())
        .collect(Collectors.toList()));

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

final List<QuerySort> sorts = new LinkedList<>();
List<QuerySortOrder> orders = query.getSortOrders();
if (orders != null && !orders.isEmpty()) {
  orders.forEach(o -> sorts.add(fromOrder(getPropertySet(), o)));

代码示例来源:origin: jpos/jPOS-EE

public DataProvider getParentDataProvider() {
  Map<String,Boolean> orders = new HashMap<>();
  DataProvider dataProvider = DataProvider.fromCallbacks(
      (CallbackDataProvider.FetchCallback) query -> {
        int offset = query.getOffset();
        int limit = query.getLimit();
        Iterator it = query.getSortOrders().iterator();
        while (it.hasNext()) {
          QuerySortOrder order = (QuerySortOrder) it.next();
          orders.put(order.getSorted(),order.getDirection() == SortDirection.DESCENDING);
        }
        try {
          return getPossibleParents(offset,limit,orders);
        } catch (Exception e) {
          getApp().getLog().error(e);
          return null;
        }
      },
      (CallbackDataProvider.CountCallback<Account, Void>) query -> {
        try {
          return getPossibleParentsCount();
        } catch (Exception e) {
          getApp().getLog().error(e);
          return 0;
        }
      });
  return dataProvider;
}

代码示例来源:origin: jpos/jPOS-EE

@Override
public DataProvider getDataProvider() {
  Map<String,Boolean> orders = new HashMap<>();
  DataProvider dataProvider = DataProvider.fromCallbacks(
      (CallbackDataProvider.FetchCallback) query -> {
        int offset = query.getOffset();
        int limit = query.getLimit();
        for (Object o : query.getSortOrders()) {
          QuerySortOrder order = (QuerySortOrder) o;
          orders.put(order.getSorted(), order.getDirection() == SortDirection.DESCENDING);
        }
        User user = (User) query.getFilter().orElse(null);
        try {
          return getAll(offset,limit,orders,user);
        } catch (Exception e) {
          getApp().getLog().error(e);
          return null;
        }
      },
      (CallbackDataProvider.CountCallback) query -> {
        User user = (User) query.getFilter().orElse(null);
        try {
          return getItemCount(user);
        } catch (Exception e) {
          getApp().getLog().error(e);
          return 0;
        }
      });
  return (ConfigurableFilterDataProvider<Consumer,Void,User>) dataProvider.withConfigurableFilter();
}

代码示例来源:origin: jpos/jPOS-EE

@Override
public DataProvider getDataProvider() {
  Map<String,Boolean> orders = new HashMap<>();
  DataProvider dataProvider = DataProvider.fromCallbacks(
      (CallbackDataProvider.FetchCallback) query -> {
        int offset = query.getOffset();
        int limit = query.getLimit();
        for (Object o : query.getSortOrders()) {
          QuerySortOrder order = (QuerySortOrder) o;
          orders.put(order.getSorted(), order.getDirection() == SortDirection.DESCENDING);
        }
        DateRange dateRange = (DateRange) query.getFilter().orElse(null);
        try {
          return getAll(offset,limit,orders,defaultJournalId,dateRange);
        } catch (Exception e) {
          getApp().getLog().error(e);
          return null;
        }
      },
      (CallbackDataProvider.CountCallback) query -> {
        DateRange dateRange = (DateRange) query.getFilter().orElse(null);
        try {
          return getItemCount(defaultJournalId,dateRange);
        } catch (Exception e) {
          getApp().getLog().error(e);
          return 0;
        }
      });
  return (ConfigurableFilterDataProvider<GLTransaction,Void,DateRange>) dataProvider.withConfigurableFilter();
}

相关文章