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

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

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

Query.getOffset介绍

[英]Gets the first index of items to fetch. The offset is only used when fetching items, but not when counting the number of available items.
[中]获取要获取的项的第一个索引。偏移量仅在获取项目时使用,但在计算可用项目数时不使用。

代码示例

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

@Override
public Stream<T> fetch(Query<T, SerializablePredicate<T>> query) {
  Stream<T> stream = getFilteredStream(query);
  Optional<Comparator<T>> comparing = Stream
      .of(query.getInMemorySorting(), sortOrder)
      .filter(c -> c != null)
      .reduce((c1, c2) -> c1.thenComparing(c2));
  if (comparing.isPresent()) {
    stream = stream.sorted(comparing.get());
  }
  return stream.skip(query.getOffset()).limit(query.getLimit());
}

代码示例来源: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

/**
 * 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 com.vaadin.data.provider.Query 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,
    SerializableToIntFunction<String> sizeCallback) {
  setDataProvider(new CallbackDataProvider<>(
      q -> fetchItems.fetchItems(q.getFilter().orElse(""),
          q.getOffset(), q.getLimit()),
      q -> sizeCallback.applyAsInt(q.getFilter().orElse(""))));
}

代码示例来源: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.haulmont.cuba/cuba-web

@Override
public Stream<T> fetch(Query<T, SerializablePredicate<T>> query) {
  if (dataGridItems.getState() == BindingState.INACTIVE) {
    return Stream.empty();
  }
  return dataGridItems.getItems()
      .skip(query.getOffset())
      .limit(query.getLimit());
}

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

@Override
protected Stream<ITEM> fetchFromBackEnd(Query<ITEM, QueryFilter> query) {
  getDataSource().setDataProviderQuery(query);
  if (query.getLimit() == Integer.MAX_VALUE) {
    return getAllItems().stream();
  }
  return getItemsByIndex(query.getOffset(), query.getLimit()).stream();
}

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

@Override
protected Stream<ITEM> fetchFromBackEnd(Query<ITEM, QueryFilter> query) {
  return getDataProvider().load(getConfiguration(query), query.getOffset(), query.getLimit());
}

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

q.offset(query.getOffset());

代码示例来源: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);
        }
        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();
}

代码示例来源: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: AxonIQ/giftcard-demo

new FetchCardSummariesQuery(query.getOffset(), query.getLimit(), filter);
log.trace("submitting {}", fetchCardSummariesQuery);

相关文章