com.vaadin.flow.data.provider.Query类的使用及代码示例

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

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

Query介绍

[英]Immutable query object used to request data from a backend. Contains index limits, sorting and filtering information.
[中]用于从后端请求数据的不可变查询对象。包含索引限制、排序和筛选信息。

代码示例

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

@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/flow-data

private Stream<T> getFilteredStream(
    Query<T, SerializablePredicate<T>> query) {
  Stream<T> stream = backend.stream();
  // Apply our own filters first so that query filters never see the items
  // that would already have been filtered out
  if (filter != null) {
    stream = stream.filter(filter);
  }
  stream = query.getFilter().map(stream::filter).orElse(stream);
  return stream;
}

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

@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(Objects::nonNull)
      .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-charts-flow

/**
 * Returns a list mappings between chart attributes(keys) and values. For
 * example: x->1, x->2, y->2, y->3 for linear chart
 *
 * @return
 */
public List<Map<String, Optional<Object>>> getValues() {
  return dataProvider.fetch(new Query<>())
      .map((item) -> chartAttributeToCallback.entrySet().stream()
          .collect(toMap(Entry::getKey,
              entry -> (entry.getValue() != null)
                  ? Optional.ofNullable(
                      entry.getValue().apply(item))
                  : Optional.empty())))
      .collect(toList());
}

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

query.getFilter().ifPresent(f -> {
  QueryFilter filter = filterConverter.apply(f);
  if (filter != null) {
  List<QuerySortOrder> orders = query.getSortOrders();
  if (orders != null && !orders.isEmpty()) {
    orders.forEach(order -> sorts.add(Optional.ofNullable(querySortOrderConverter.apply(order))
if (query.getLimit() < Integer.MAX_VALUE) {
  q.limit(query.getLimit());
  q.offset(query.getOffset());

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

@Override
public int getLimit() {
  isLimitCalled = true;
  return super.getLimit();
}

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

@Override
public int getOffset() {
  isOffsetCalled = true;
  return super.getOffset();
}

代码示例来源:origin: com.vaadin/vaadin-list-box-flow

private void rebuild() {
  removeAll();
  setValue(null);
  getDataProvider().fetch(new Query<>()).map(this::createItemComponent)
      .forEach(this::add);
}

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

@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-checkbox-flow

private void reset() {
  keyMapper.removeAll();
  removeAll();
  clear();
  getDataProvider().fetch(new Query<>()).map(this::createCheckBox)
      .forEach(this::add);
}

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

/**
   * Gets the filter converted from a query filter by the
   * {@code filterConverter}.
   *
   * @param filterConverter
   *            callback that converts the filter in the query of the wrapped
   *            data provider into a filter supported by this data provider.
   *            Will only be called if the query contains a filter. Not
   *            <code>null</code>
   * @param query
   *            a query with a filter to convert
   * @return a converted filter, may be {@code null} if the query has no
   *         filter
   *
   * @param <C>
   *            the filter type that the wrapped data provider accepts;
   *            typically provided by a Component
   */
  public static <T, C, F> F convertFilter(
      SerializableFunction<C, F> filterConverter, Query<T, C> query) {
    return query.getFilter().map(filterConverter).orElse(null);
  }
}

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

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/flow-data

/**
 * Getter method for finding the size of DataProvider. Can be overridden by
 * a subclass that uses a specific type of DataProvider and/or query.
 *
 * @return the size of data provider with current filter
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected int getDataProviderSize() {
  return getDataProvider().size(new Query(getFilter()));
}

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

@Override
protected F getFilter(Query<T, Q> query) {
  Q queryFilter = query.getFilter().orElse(null);
  if (configuredFilter == null && queryFilter == null) {
    return null;
  }
  return combineFilters(queryFilter, configuredFilter);
}

代码示例来源:origin: com.vaadin/vaadin-radio-button-flow

private void reset() {
  keyMapper.removeAll();
  removeAll();
  clear();
  getDataProvider().fetch(new Query<>()).map(this::createRadioButton)
      .forEach(this::add);
}

代码示例来源:origin: alejandro-du/crudui

protected void findAllButtonClicked() {
  grid.asSingleSelect().clear();
  refreshGrid();
  Notification.show(String.format(rowCountCaption, grid.getDataProvider().size(new Query())));
}

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

private void reset() {
  keyMapper.removeAll();
  listBox.removeAll();
  clear();
  // reset added at this point to avoid unnecessary selected item update
  if (!resetPending) {
    resetPending = true;
    runBeforeClientResponse(ui -> {
      ui.getPage().executeJavaScript("$0.render();", getElement());
      resetPending = false;
    });
  }
  if (isEmptySelectionAllowed()) {
    addEmptySelectionItem();
  }
  getDataProvider().fetch(new Query<>()).map(this::createItem)
      .forEach(this::add);
}

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

ms -> component.getDataProvider().refreshAll(), () -> {
  if (component.getDataProvider() != null) {
    return component.getDataProvider().fetch(new Query<>()).collect(Collectors.toSet());

相关文章