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

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

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

Query.getFilter介绍

[英]Gets the filter for items to fetch.
[中]获取要获取的项的筛选器。

代码示例

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

@Override
  protected F getFilter(Query<T, C> query) {
    return query.getFilter().map(filterConverter).orElse(null);
  }
};

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

@Override
protected SerializablePredicate<T> getFilter(Query<T, C> query) {
  return query.getFilter().map(filterConverter).orElse(null);
}

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

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/vaadin-server

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

/**
 * 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.holon-platform.vaadin/holon-vaadin

@Override
public QueryFilter getQueryFilter() {
  return getDataProviderQuery().flatMap(q -> q.getFilter()).orElse(null);
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

@Override
public Stream<OptionDefinition> fetch(Query<OptionDefinition, DataFilter> query) {
  final Stream<OptionDefinition> stream = definition.getOptions()
      .stream()
      .filter(property ->
          query.getFilter()
              .map(f -> isValueMatching(f, property.getValue()))
              .orElse(true));
  return definition.isSortable() ? stream.sorted(PRECONFIGURED_OPTION_COMPARATOR) : stream;
}

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

query.getFilter().ifPresent(f -> filters.add(f));

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

query.getFilter().ifPresent(f -> filters.add(f));

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

相关文章