当前位置: 首页>>代码示例>>Java>>正文


Java FilterOperator.GREATER_THAN_OR_EQUAL属性代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.Query.FilterOperator.GREATER_THAN_OR_EQUAL属性的典型用法代码示例。如果您正苦于以下问题:Java FilterOperator.GREATER_THAN_OR_EQUAL属性的具体用法?Java FilterOperator.GREATER_THAN_OR_EQUAL怎么用?Java FilterOperator.GREATER_THAN_OR_EQUAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.appengine.api.datastore.Query.FilterOperator的用法示例。


在下文中一共展示了FilterOperator.GREATER_THAN_OR_EQUAL属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: propertyFilterExample_returnsMatchingEntities

@Test
public void propertyFilterExample_returnsMatchingEntities() throws Exception {
  // Arrange
  Entity p1 = new Entity("Person");
  p1.setProperty("height", 120);
  Entity p2 = new Entity("Person");
  p2.setProperty("height", 180);
  Entity p3 = new Entity("Person");
  p3.setProperty("height", 160);
  datastore.put(ImmutableList.<Entity>of(p1, p2, p3));

  // Act
  long minHeight = 160;
  // [START property_filter_example]
  Filter propertyFilter =
      new FilterPredicate("height", FilterOperator.GREATER_THAN_OR_EQUAL, minHeight);
  Query q = new Query("Person").setFilter(propertyFilter);
  // [END property_filter_example]

  // Assert
  List<Entity> results =
      datastore.prepare(q.setKeysOnly()).asList(FetchOptions.Builder.withDefaults());
  assertThat(results).named("query results").containsExactly(p2, p3);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:24,代码来源:QueriesTest.java

示例2: queryInterface_singleFilter_returnsMatchedEntities

@Test
public void queryInterface_singleFilter_returnsMatchedEntities() throws Exception {
  // Arrange
  Entity a = new Entity("Person", "a");
  a.setProperty("height", 100);
  Entity b = new Entity("Person", "b");
  b.setProperty("height", 150);
  Entity c = new Entity("Person", "c");
  c.setProperty("height", 300);
  datastore.put(ImmutableList.<Entity>of(a, b, c));

  // Act
  long minHeight = 150;
  // [START interface_2]
  Filter heightMinFilter =
      new FilterPredicate("height", FilterOperator.GREATER_THAN_OR_EQUAL, minHeight);

  Query q = new Query("Person").setFilter(heightMinFilter);
  // [END interface_2]

  // Assert
  List<Entity> results =
      datastore.prepare(q.setKeysOnly()).asList(FetchOptions.Builder.withDefaults());
  assertThat(results).named("query results").containsExactly(b, c);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:25,代码来源:QueriesTest.java

示例3: queryRestrictions_compositeFilter_isInvalid

@Test
public void queryRestrictions_compositeFilter_isInvalid() throws Exception {
  long minBirthYear = 1940;
  long maxHeight = 200;
  // [START inequality_filters_one_property_invalid_example]
  Filter birthYearMinFilter =
      new FilterPredicate("birthYear", FilterOperator.GREATER_THAN_OR_EQUAL, minBirthYear);

  Filter heightMaxFilter =
      new FilterPredicate("height", FilterOperator.LESS_THAN_OR_EQUAL, maxHeight);

  Filter invalidFilter = CompositeFilterOperator.and(birthYearMinFilter, heightMaxFilter);

  Query q = new Query("Person").setFilter(invalidFilter);
  // [END inequality_filters_one_property_invalid_example]

  // Note: The local devserver behavior is different than the production
  // version of Cloud Datastore, so there aren't any assertions we can make
  // in this test.  The query appears to work with the local test runner,
  // but will fail in production.
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:21,代码来源:QueriesTest.java

示例4: queryRestrictions_missingSortOnInequality_isInvalid

@Test
public void queryRestrictions_missingSortOnInequality_isInvalid() throws Exception {
  long minBirthYear = 1940;
  // [START inequality_filters_sort_orders_invalid_example_1]
  Filter birthYearMinFilter =
      new FilterPredicate("birthYear", FilterOperator.GREATER_THAN_OR_EQUAL, minBirthYear);

  // Not valid. Missing sort on birthYear.
  Query q =
      new Query("Person")
          .setFilter(birthYearMinFilter)
          .addSort("lastName", SortDirection.ASCENDING);
  // [END inequality_filters_sort_orders_invalid_example_1]

  // Note: The local devserver behavior is different than the production
  // version of Cloud Datastore, so there aren't any assertions we can make
  // in this test.  The query appears to work with the local test runner,
  // but will fail in production.
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:19,代码来源:QueriesTest.java

示例5: queryRestrictions_sortWrongOrderOnInequality_isInvalid

@Test
public void queryRestrictions_sortWrongOrderOnInequality_isInvalid() throws Exception {
  long minBirthYear = 1940;
  // [START inequality_filters_sort_orders_invalid_example_2]
  Filter birthYearMinFilter =
      new FilterPredicate("birthYear", FilterOperator.GREATER_THAN_OR_EQUAL, minBirthYear);

  // Not valid. Sort on birthYear needs to be first.
  Query q =
      new Query("Person")
          .setFilter(birthYearMinFilter)
          .addSort("lastName", SortDirection.ASCENDING)
          .addSort("birthYear", SortDirection.ASCENDING);
  // [END inequality_filters_sort_orders_invalid_example_2]

  // Note: The local devserver behavior is different than the production
  // version of Cloud Datastore, so there aren't any assertions we can make
  // in this test.  The query appears to work with the local test runner,
  // but will fail in production.
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:20,代码来源:QueriesTest.java

示例6: queryRestrictions_compositeFilter_returnsMatchedEntities

@Test
public void queryRestrictions_compositeFilter_returnsMatchedEntities() throws Exception {
  // Arrange
  Entity a = new Entity("Person", "a");
  a.setProperty("birthYear", 1930);
  Entity b = new Entity("Person", "b");
  b.setProperty("birthYear", 1960);
  Entity c = new Entity("Person", "c");
  c.setProperty("birthYear", 1990);
  datastore.put(ImmutableList.<Entity>of(a, b, c));

  // Act
  long minBirthYear = 1940;
  long maxBirthYear = 1980;
  // [START inequality_filters_one_property_valid_example_1]
  Filter birthYearMinFilter =
      new FilterPredicate("birthYear", FilterOperator.GREATER_THAN_OR_EQUAL, minBirthYear);

  Filter birthYearMaxFilter =
      new FilterPredicate("birthYear", FilterOperator.LESS_THAN_OR_EQUAL, maxBirthYear);

  Filter birthYearRangeFilter =
      CompositeFilterOperator.and(birthYearMinFilter, birthYearMaxFilter);

  Query q = new Query("Person").setFilter(birthYearRangeFilter);
  // [END inequality_filters_one_property_valid_example_1]

  // Assert
  List<Entity> results =
      datastore.prepare(q.setKeysOnly()).asList(FetchOptions.Builder.withDefaults());
  assertThat(results).named("query results").containsExactly(b);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:32,代码来源:QueriesTest.java

示例7: queryRestrictions_inequalitySortedFirst_returnsMatchedEntities

@Test
public void queryRestrictions_inequalitySortedFirst_returnsMatchedEntities() throws Exception {
  // Arrange
  Entity a = new Entity("Person", "a");
  a.setProperty("birthYear", 1930);
  a.setProperty("lastName", "Someone");
  Entity b = new Entity("Person", "b");
  b.setProperty("birthYear", 1990);
  b.setProperty("lastName", "Bravo");
  Entity c = new Entity("Person", "c");
  c.setProperty("birthYear", 1960);
  c.setProperty("lastName", "Charlie");
  Entity d = new Entity("Person", "d");
  d.setProperty("birthYear", 1960);
  d.setProperty("lastName", "Delta");
  datastore.put(ImmutableList.<Entity>of(a, b, c, d));
  long minBirthYear = 1940;

  // [START inequality_filters_sort_orders_valid_example]
  Filter birthYearMinFilter =
      new FilterPredicate("birthYear", FilterOperator.GREATER_THAN_OR_EQUAL, minBirthYear);

  Query q =
      new Query("Person")
          .setFilter(birthYearMinFilter)
          .addSort("birthYear", SortDirection.ASCENDING)
          .addSort("lastName", SortDirection.ASCENDING);
  // [END inequality_filters_sort_orders_valid_example]

  // Assert
  List<Entity> results =
      datastore.prepare(q.setKeysOnly()).asList(FetchOptions.Builder.withDefaults());
  assertThat(results).named("query results").containsExactly(c, d, b).inOrder();
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:34,代码来源:QueriesTest.java

示例8: checkAndGetCompletedBackup

private String checkAndGetCompletedBackup(String backupName) throws IOException {
	System.err.println("backupName: " + backupName);
	
	DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
	
	Query q = new Query("_AE_Backup_Information");
	
	// for some reason the datastore admin code appends the date to the backup name even when creating programatically, 
	// so test for greater than or equal to and then take the first result
	FilterPredicate fp = new FilterPredicate("name", FilterOperator.GREATER_THAN_OR_EQUAL, backupName);
	q.setFilter(fp);
	
	PreparedQuery pq = datastore.prepare(q);
	List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(1));
	if (results.size() != 1) {
		throw new IOException("fatal error - can't find the datastore backup entity, big trouble");
	}
	Entity result = results.get(0);
	
	Object completion = result.getProperty("complete_time");
	String keyResult = null;
	if (completion != null) {
		keyResult = KeyFactory.keyToString(result.getKey());
	}
	
	System.err.println("result: " + result);
	System.err.println("complete_time: " + completion);
	System.err.println("Backup complete: " + completion != null);
	System.err.println("keyResult: " + keyResult);
	return keyResult;
}
 
开发者ID:steveseo,项目名称:l2bq,代码行数:31,代码来源:BuiltinDatastoreToBigqueryIngesterTask.java

示例9: queryRestrictions_compositeEqualFilter_returnsMatchedEntities

@Test
public void queryRestrictions_compositeEqualFilter_returnsMatchedEntities() throws Exception {
  // Arrange
  Entity a = new Entity("Person", "a");
  a.setProperty("birthYear", 1930);
  a.setProperty("city", "Somewhere");
  a.setProperty("lastName", "Someone");
  Entity b = new Entity("Person", "b");
  b.setProperty("birthYear", 1960);
  b.setProperty("city", "Somewhere");
  b.setProperty("lastName", "Someone");
  Entity c = new Entity("Person", "c");
  c.setProperty("birthYear", 1990);
  c.setProperty("city", "Somewhere");
  c.setProperty("lastName", "Someone");
  Entity d = new Entity("Person", "d");
  d.setProperty("birthYear", 1960);
  d.setProperty("city", "Nowhere");
  d.setProperty("lastName", "Someone");
  Entity e = new Entity("Person", "e");
  e.setProperty("birthYear", 1960);
  e.setProperty("city", "Somewhere");
  e.setProperty("lastName", "Noone");
  datastore.put(ImmutableList.<Entity>of(a, b, c, d, e));
  long minBirthYear = 1940;
  long maxBirthYear = 1980;
  String targetCity = "Somewhere";
  String targetLastName = "Someone";

  // [START inequality_filters_one_property_valid_example_2]
  Filter lastNameFilter = new FilterPredicate("lastName", FilterOperator.EQUAL, targetLastName);

  Filter cityFilter = new FilterPredicate("city", FilterOperator.EQUAL, targetCity);

  Filter birthYearMinFilter =
      new FilterPredicate("birthYear", FilterOperator.GREATER_THAN_OR_EQUAL, minBirthYear);

  Filter birthYearMaxFilter =
      new FilterPredicate("birthYear", FilterOperator.LESS_THAN_OR_EQUAL, maxBirthYear);

  Filter validFilter =
      CompositeFilterOperator.and(
          lastNameFilter, cityFilter, birthYearMinFilter, birthYearMaxFilter);

  Query q = new Query("Person").setFilter(validFilter);
  // [END inequality_filters_one_property_valid_example_2]

  // Assert
  List<Entity> results =
      datastore.prepare(q.setKeysOnly()).asList(FetchOptions.Builder.withDefaults());
  assertThat(results).named("query results").containsExactly(b);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:52,代码来源:QueriesTest.java


注:本文中的com.google.appengine.api.datastore.Query.FilterOperator.GREATER_THAN_OR_EQUAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。