com.holonplatform.core.query.Query.filter()方法的使用及代码示例

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

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

Query.filter介绍

暂无

代码示例

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

@Override
public BeanQuery<T> filter(QueryFilter filter) {
  getExecutor().filter(filter);
  return this;
}

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

@SuppressWarnings({ "rawtypes", "unchecked" })
protected <P extends Property<?>> void setupItemConverter(Datastore datastore, DataTarget<?> dataTarget,
    Iterable<P> properties) {
  if (selectProperty != null && PathProperty.class.isAssignableFrom(selectProperty.getClass())
      && !getInstance().getItemConverter().isPresent()) {
    itemConverter(value -> {
      if (value != null) {
        return datastore.query().target(dataTarget).filter(((PathProperty) selectProperty).eq(value))
            .findOne(properties).orElse(null);
      }
      return null;
    });
  }
}

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

@SuppressWarnings({ "rawtypes", "unchecked" })
protected <P extends Property<?>> void setupItemConverter(Datastore datastore, DataTarget<?> dataTarget,
    Iterable<P> properties) {
  if (selectProperty != null && PathProperty.class.isAssignableFrom(selectProperty.getClass())
      && !getInstance().getItemConverter().isPresent()) {
    itemConverter(value -> {
      if (value != null) {
        return datastore.query().target(dataTarget).filter(((PathProperty) selectProperty).eq(value))
            .findOne(properties).orElse(null);
      }
      return null;
    });
  }
}

代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa

void query() {
  Datastore datastore = getJpaDatastore();
  List<Test> resultEntities = datastore.query(JPA_TARGET).filter(ID.gt(0L)).list(JPA_TARGET); // <2>
}
// end::model4[]

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

/**
 * Setup a item converter function if the current item converter is a {@link PropertyItemConverter}, using the
 * selection property to retrieve an item.
 * @param datastore The datastore
 * @param target The query target
 * @param propertySet The query projection
 */
protected void setupDatastoreItemConverter(Datastore datastore, DataTarget<?> target, PropertySet<?> propertySet) {
  if (propertyItemConverter != null && propertyItemConverter.getToItemConverter() == null) {
    propertyItemConverter.setToItemConverter(value -> {
      return (value == null) ? Optional.empty()
          : datastore.query(target).filter(QueryFilter.eq(selectionProperty, value)).findOne(propertySet);
    });
  }
}

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

/**
 * Setup a item converter function if the current item converter is a {@link PropertyItemConverter}, using the
 * selection property to retrieve an item.
 * @param datastore The datastore
 * @param target The query target
 * @param propertySet The query projection
 */
protected void setupDatastoreItemConverter(Datastore datastore, DataTarget<?> target, PropertySet<?> propertySet) {
  if (propertyItemConverter != null && propertyItemConverter.getToItemConverter() == null) {
    propertyItemConverter.setToItemConverter(value -> {
      return (value == null) ? Optional.empty()
          : datastore.query(target).filter(QueryFilter.eq(selectionProperty, value)).findOne(propertySet);
    });
  }
}

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

/**
 * Setup a item converter function if the current item converter is a {@link PropertyItemConverter}, using the
 * selection property to retrieve an item.
 * @param datastore The datastore
 * @param target The query target
 * @param propertySet The query projection
 */
protected void setupDatastoreItemConverter(Datastore datastore, DataTarget<?> target, PropertySet<?> propertySet) {
  if (propertyItemConverter != null && propertyItemConverter.getToItemConverter() == null) {
    propertyItemConverter.setToItemConverter(value -> {
      return (value == null) ? Optional.empty()
          : datastore.query(target).filter(QueryFilter.eq(selectionProperty, value)).findOne(propertySet);
    });
  }
}

代码示例来源:origin: com.holon-platform.jdbc/documentation-datastore-jdbc

public void where1() {
  // tag::where1[]
  QueryFilter whereFilter = WhereFilter.create("name='John'"); // <1>
  Stream<Long> results = getDatastore().query().target(TARGET).filter(whereFilter).stream(ID); // <2>
  // end::where1[]
}

代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa

public void expres2() {
  // tag::expres2[]
  final NumericProperty<Long> KEY = NumericProperty.create("key", long.class);
  final ExpressionResolver<KeyIs, JPQLExpression> keyIsResolver = ExpressionResolver.create( //
      KeyIs.class, // <1>
      JPQLExpression.class, // <2>
      (keyIs, context) -> {
        String path = JPQLResolutionContext.isJPQLResolutionContext(context)
            .flatMap(ctx -> ctx.isStatementCompositionContext()).flatMap(ctx -> ctx.getAliasOrRoot(KEY))
            .map(alias -> alias + ".key").orElse("key");
        return Optional.of(JPQLExpression.create(path + " = " + keyIs.getValue()));
      }); // <3>
  // end::expres2[]
  // tag::expres3[]
  Datastore datastore = JpaDatastore.builder().withExpressionResolver(keyIsResolver) // <1>
      .build();
  Query query = datastore.query().filter(new KeyIs(1L)); // <2>
  // end::expres3[]
}

代码示例来源:origin: com.holon-platform.jdbc/documentation-datastore-jdbc

public void expres2() {
  // tag::expres2[]
  final ExpressionResolver<KeyIs, SQLExpression> keyIsResolver = ExpressionResolver.create( //
      KeyIs.class, // <1>
      SQLExpression.class, // <2>
      (keyIs, ctx) -> Optional.of(SQLExpression.create("key = " + keyIs.getValue()))); // <3>
  // end::expres2[]
  // tag::expres3[]
  Datastore datastore = JdbcDatastore.builder().withExpressionResolver(keyIsResolver) // <1>
      .build();
  Query query = datastore.query().filter(new KeyIs(1L)); // <2>
  // end::expres3[]
}

代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa

void operations() {
  // tag::model3[]
  Datastore datastore = getJpaDatastore();
  Stream<Long> ids = datastore.query().target(TARGET).filter(ID.gt(0L)).sort(VALUE.asc()).stream(ID); // <1>
  Stream<PropertyBox> results = datastore.query().target(TARGET).filter(ID.gt(0L)).sort(VALUE.asc()).stream(TEST); // <2>
  PropertyBox valueToSave = PropertyBox.builder(TEST).set(ID, 1L).set(VALUE, "test").build();
  datastore.save(TARGET, valueToSave); // <3>
  // end::model3[]
}

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

public void customFilter() {
  Datastore datastore = getDatastore(); // build or obtain a concrete Datastore implementation
  datastore.addExpressionResolver(new MyFilterResolver()); // <4>
  Stream<String> results = datastore.query().target(DataTarget.named("test"))
      .filter(PROPERTY.isNotNull().and(new MyFilter(PROPERTY, "testValue"))).stream(PROPERTY); // <5>
}
// end::customfilter[]

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

public void selectable11() {
  // tag::selectable11[]
  Datastore datastore = obtainDatastore();
  final PathProperty<Long> ID = PathProperty.create("id", Long.class);
  final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class);
  final DataTarget<?> TARGET = DataTarget.named("testData");
  final PropertySet<?> PROPERTIES = PropertySet.of(ID, DESCRIPTION);
  SingleSelect<Long> singleSelect = Components.input.singleSelect(ID)
      .dataSource(datastore, DataTarget.named("testData"), PROPERTIES)
      .itemConverter(
          value -> datastore.query().target(TARGET).filter(ID.eq(value)).findOne(PROPERTIES).orElse(null)) // <1>
      .build();
  // end::selectable11[]
}

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

@SuppressWarnings({ "rawtypes", "unchecked" })
public void subquery2() {
  // tag::subquery2[]
  Datastore datastore = getDatastore(); // this is supposed to be a relational Datastore implementation
  final DataTarget TARGET1 = DataTarget.named("testTarget1");
  final PathProperty<Integer> PROPERTY1 = TARGET1.property("test", Integer.class);
  final DataTarget TARGET2 = DataTarget.named("testTarget2");
  final PathProperty<Integer> PROPERTY2 = TARGET2.property("test", Integer.class);
  Stream<Integer> results = datastore.query().target(TARGET1)
      .filter(SubQuery.create().target(TARGET2).filter(PROPERTY2.eq(PROPERTY1)).exists()).stream(PROPERTY2); // <1>
  results = datastore.query().target(TARGET1)
      .filter(SubQuery.create().target(TARGET2).filter(PROPERTY2.eq(PROPERTY1)).notExists())
      .stream(PROPERTY2); // <2>
  // end::subquery2[]
}

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

@SuppressWarnings({ "rawtypes", "unchecked" })
public void subquery1() {
  // tag::subquery1[]
  Datastore datastore = getDatastore(); // this is supposed to be a relational Datastore implementation
  final DataTarget TARGET1 = DataTarget.named("testTarget1");
  final PathProperty<Integer> PROPERTY1 = TARGET1.property("test", Integer.class);
  final DataTarget TARGET2 = DataTarget.named("testTarget2");
  final PathProperty<Integer> PROPERTY2 = TARGET2.property("test", Integer.class);
  SubQuery<Integer> subQuery = SubQuery.create().target(TARGET2).filter(PROPERTY1.goe(1)).select(PROPERTY1); // <1>
  Stream<Integer> results = datastore.query().target(TARGET1).filter(PROPERTY2.in(subQuery)).stream(PROPERTY2); // <2>
  // end::subquery1[]
}

代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa

void operations() {
  Datastore datastore = getJpaDatastore();
  PropertyBox value = PropertyBox.builder(Test.PROPERTIES).set(Test.PROPERTIES.property("id"), 1L)
      .set(Test.PROPERTIES.property("value"), "test").build(); // <3>
  datastore.save(Test.TARGET, value);
  List<PropertyBox> values = datastore.query(Test.TARGET).filter(Test.PROPERTIES.property("id").gt(0L))
      .sort(Test.PROPERTIES.property("value").desc()).list(Test.PROPERTIES); // <4>
}
// end::beans1[]

代码示例来源:origin: com.holon-platform.jdbc/documentation-datastore-jdbc

public void mapping3() {
  // tag::mapping3[]
  Datastore datastore = JdbcDatastore.builder().dataSource(createOrObtainDatasource()).build(); // <1>
  PropertyBox value = PropertyBox.builder(MyEntity.PROPERTIES) //
      .set(MyEntity.PROPERTIES.property("id"), 1L) //
      .set(MyEntity.PROPERTIES.property("value"), "One").build();
  datastore.save(MyEntity.TARGET, value); // <2>
  Stream<PropertyBox> results = datastore.query().target(MyEntity.TARGET)
      .filter(MyEntity.PROPERTIES.property("id").goe(1L)).stream(MyEntity.PROPERTIES); // <3>
  // end::mapping3[]
}

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

q.filter(filter);

代码示例来源:origin: com.holon-platform.jdbc/documentation-datastore-jdbc

public void naming2() {
  // tag::naming2[]
  Datastore datastore = JdbcDatastore.builder().dataSource(createOrObtainDatasource()).build(); // <1>
  PropertyBox value = PropertyBox.builder(TEST).set(ID, 1L).set(VALUE, "One").build();
  datastore.save(TARGET, value); // <2>
  Stream<PropertyBox> results = datastore.query().target(TARGET).filter(ID.goe(1L)).stream(TEST); // <3>
  List<String> values = datastore.query().target(TARGET).sort(ID.asc()).list(VALUE); // <4>
  datastore.bulkDelete(TARGET).filter(ID.gt(0L)).execute(); // <5>
  // end::naming2[]
}

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

public void queryDefinition() {
  // tag::querydefinition[]
  final PathProperty<Integer> PROPERTY = PathProperty.create("test", Integer.class);
  Datastore datastore = getDatastore(); // build or obtain a Datastore
  Query query = datastore.query() // <1>
      .target(DataTarget.named("testTarget")) // <2>
      .filter(PROPERTY.gt(10)) // <3>
      .sort(PROPERTY.asc()) // <4>
      .aggregate(PROPERTY) // <5>
      .limit(100) // <6>
      .offset(200); // <7>
  query = datastore.query(DataTarget.named("testTarget")) // <8>
      .aggregate(QueryAggregation.builder().path(PROPERTY).filter(PROPERTY.gt(10)).build()) // <9>
      .restrict(100, 200); // <10>
  // end::querydefinition[]
}

相关文章