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


Java FilterOperator类代码示例

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


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

示例1: getNationalHighScores

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Method to retrieve the national high scores 
 * @return
 */
public List<Entity> getNationalHighScores(String countryCode){
	log.info("Retrieving national high scores");
	
	//create the country code filter
	Filter country = new FilterPredicate(Constants.COUNTRY_CODE,FilterOperator.EQUAL,countryCode);
	//create the query to read the records sorted by score
	Query q = new Query(Constants.RECORD).addSort(Constants.SCORE, SortDirection.DESCENDING);
	//set the filter to the query
	q.setFilter(country);
	
	PreparedQuery pq = datastore.prepare(q);
	
	//retrieve and return the list of records	
	return pq.asList(FetchOptions.Builder.withLimit(100));
}
 
开发者ID:mastorak,项目名称:LeaderboardServer,代码行数:20,代码来源:ScoreDAO.java

示例2: getMonthlyHighScores

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Method to retrieve the monthly high scores 
 * @return
 */
public List<Entity> getMonthlyHighScores(){
	log.info("Retrieving monthly high scores");
	
	//calculate calendar info
	Calendar calendar= Calendar.getInstance();		
	int year=calendar.get(Calendar.YEAR);
	int month=calendar.get(Calendar.MONTH);
	
	//create filters
	Filter yearFilter = new FilterPredicate(Constants.YEAR,FilterOperator.EQUAL,year);
	Filter monthFilter = new FilterPredicate(Constants.MONTH,FilterOperator.EQUAL,month);
		
	//create the query to read the records sorted by score
	Query q = new Query(Constants.RECORD).addSort(Constants.SCORE, SortDirection.DESCENDING);
	//set filters to the query
	q.setFilter(yearFilter);
	q.setFilter(monthFilter);
	
	//prepare query
	PreparedQuery pq = datastore.prepare(q);
	
	//retrieve and return the list of records	
	return pq.asList(FetchOptions.Builder.withLimit(100));
}
 
开发者ID:mastorak,项目名称:LeaderboardServer,代码行数:29,代码来源:ScoreDAO.java

示例3: getWeeklyHighScores

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Method to retrieve the weekly high scores 
 * @return
 */
public List<Entity> getWeeklyHighScores(){
	log.info("Retrieving weekly high scores");
	
	//calculate calendar info
	Calendar calendar= Calendar.getInstance();		
	int year=calendar.get(Calendar.YEAR);
	int week=calendar.get(Calendar.WEEK_OF_YEAR);
	
	//create filters
	Filter yearFilter = new FilterPredicate(Constants.YEAR,FilterOperator.EQUAL,year);
	Filter weekFilter = new FilterPredicate(Constants.WEEK_OF_THE_YEAR,FilterOperator.EQUAL,week);
		
	//create the query to read the records sorted by score
	Query q = new Query(Constants.RECORD).addSort(Constants.SCORE, SortDirection.DESCENDING);
	//set filters to the query
	q.setFilter(yearFilter);
	q.setFilter(weekFilter);
	
	//prepare query
	PreparedQuery pq = datastore.prepare(q);
	
	//retrieve and return the list of records	
	return pq.asList(FetchOptions.Builder.withLimit(100));
}
 
开发者ID:mastorak,项目名称:LeaderboardServer,代码行数:29,代码来源:ScoreDAO.java

示例4: getDailyHighScores

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Method to retrieve the daily high scores 
 * @return
 */
public List<Entity> getDailyHighScores(){
	log.info("Retrieving weekly high scores");
	
	//calculate calendar info
	Calendar calendar= Calendar.getInstance();
	int year=calendar.get(Calendar.YEAR);
	int day=calendar.get(Calendar.DAY_OF_YEAR);
	
	//create filters
	Filter yearFilter = new FilterPredicate(Constants.YEAR,FilterOperator.EQUAL,year);
	Filter dayFilter = new FilterPredicate(Constants.DAY_OF_THE_YEAR,FilterOperator.EQUAL,day);
	
	//create the query to read the records sorted by score
	Query q = new Query(Constants.RECORD).addSort(Constants.SCORE, SortDirection.DESCENDING);
	
	//set filters to the query
	q.setFilter(yearFilter);
	q.setFilter(dayFilter);
	
	//prepare query
	PreparedQuery pq = datastore.prepare(q);
	
	//retrieve and return the list of records	
	return pq.asList(FetchOptions.Builder.withLimit(100));
}
 
开发者ID:mastorak,项目名称:LeaderboardServer,代码行数:30,代码来源:ScoreDAO.java

示例5: getAllUdwIds

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
public List<ConvUdwMapping> getAllUdwIds(SlobId convObjectId)
    throws PermanentFailure, RetryableFailure {
  Query q = new Query(ENTITY_KIND)
    .setFilter(FilterOperator.GREATER_THAN_OR_EQUAL.of(Entity.KEY_RESERVED_PROPERTY,
        directory.makeKey(new Key(convObjectId, FIRST))))
    .addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);

  List<ConvUdwMapping> entries = Lists.newArrayList();

  CheckedIterator it = datastore.prepareNontransactionalQuery(q)
      .asIterator(FetchOptions.Builder.withDefaults());
  while (it.hasNext()) {
    ConvUdwMapping entry = directory.parse(it.next());
    if (!entry.getKey().getConvObjectId().equals(convObjectId)) {
      break;
    }
    entries.add(entry);
  }
  log.info("Found " + entries.size() + " user data wavelets for " + convObjectId);
  return entries;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:22,代码来源:UdwDirectory.java

示例6: getDeltaEntityIterator

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
private CheckedIterator getDeltaEntityIterator(long startVersion, @Nullable Long endVersion,
    FetchOptions fetchOptions, boolean forward, boolean keysOnly)
    throws PermanentFailure, RetryableFailure {
  checkRange(startVersion, endVersion);
  if (endVersion != null && startVersion == endVersion) {
    return CheckedIterator.EMPTY;
  }
  Query.Filter filter = FilterOperator.GREATER_THAN_OR_EQUAL.of(Entity.KEY_RESERVED_PROPERTY,
      makeDeltaKey(objectId, startVersion));
  if (endVersion != null) {
    filter = Query.CompositeFilterOperator.and(filter,
        FilterOperator.LESS_THAN.of(Entity.KEY_RESERVED_PROPERTY,
            makeDeltaKey(objectId, endVersion)));
  }
  Query q = new Query(deltaEntityKind)
      .setAncestor(makeRootEntityKey(objectId))
      .setFilter(filter)
      .addSort(Entity.KEY_RESERVED_PROPERTY,
          forward ? SortDirection.ASCENDING : SortDirection.DESCENDING);
  if (keysOnly) {
    q.setKeysOnly();
  }
  return tx.prepare(q).asIterator(fetchOptions);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:25,代码来源:MutationLog.java

示例7: getSnapshotEntryAtOrBefore

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
@Nullable private SnapshotEntry getSnapshotEntryAtOrBefore(@Nullable Long atOrBeforeVersion)
    throws RetryableFailure, PermanentFailure {
  Query q = new Query(snapshotEntityKind)
      .setAncestor(makeRootEntityKey(objectId))
      .addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.DESCENDING);
  if (atOrBeforeVersion != null) {
    q.setFilter(FilterOperator.LESS_THAN_OR_EQUAL.of(Entity.KEY_RESERVED_PROPERTY,
        makeSnapshotKey(objectId, atOrBeforeVersion)));
  }
  Entity e = tx.prepare(q).getFirstResult();
  log.info("query " + q + " returned first result " + e);
  if (e == null) {
    return null;
  } else {
    snapshotPropertyMover.postGet(e);
    return parseSnapshot(e);
  }
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:19,代码来源:MutationLog.java

示例8: deleteSessionWithValue

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
protected void deleteSessionWithValue(String varName, String varValue) {
  Transaction transaction = datastore.beginTransaction();
  try {
    Query query = new Query(SESSION_KIND)
        .setFilter(new FilterPredicate(varName, FilterOperator.EQUAL, varValue));
    Iterator<Entity> results = datastore.prepare(transaction, query).asIterator();
    while (results.hasNext()) {
      Entity stateEntity = results.next();
      datastore.delete(transaction, stateEntity.getKey());
    }
    transaction.commit();
  } finally {
    if (transaction.isActive()) {
      transaction.rollback();
    }
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:getting-started-java,代码行数:18,代码来源:DatastoreSessionFilter.java

示例9: setFilter

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
@Override
void setFilter(ArrayList<com.google.appengine.api.datastore.Query.Filter> filters) {
  if (attribute.getDataType() == DataType.DECIMAL) {
    Set<Double> dvSet = new HashSet<Double>();
    for (Object value : valueSet) {
      Double d = null;
      if (value != null) {
        BigDecimal bd = (BigDecimal) value;
        d = bd.doubleValue();
      }
      dvSet.add(d);
    }
    filters.add(new FilterPredicate( attribute.getName(), FilterOperator.IN, dvSet));
  } else {
    filters.add(new FilterPredicate( attribute.getName(), FilterOperator.IN, valueSet));
  }
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:18,代码来源:ValueSetFilterTracker.java

示例10: removeObject

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Remove an object from the datastore
 * 
 * @param uri The URI
 */
public void removeObject(String uri) {
	if (!isObjectRegistered(uri)) {
		return;
	}
	// Remove all WebObjectInstance entries associated
	Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
	Query instanceQuery = new Query(OBJECT_INSTANCE)
			.setFilter(uriFilter)
			.addSort("timestamp", SortDirection.DESCENDING);
	List<Entity> instances = datastoreService
			.prepare(instanceQuery)
			.asList(FetchOptions.Builder.withDefaults());
	List<Key> keys = new ArrayList<Key>();
	for (Entity e : instances) {
		keys.add(e.getKey());
	}
	datastoreService.delete(keys);
	
	// Remove actual WebObject entry
	Query objectQuery = new Query(OBJECT).setFilter(uriFilter);
	Entity object = datastoreService.prepare(objectQuery).asSingleEntity();
	datastoreService.delete(object.getKey());
}
 
开发者ID:lorenzosaino,项目名称:gae-webmonitor,代码行数:29,代码来源:DataStoreService.java

示例11: updateObjectInstanceTimestamp

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Update the timestamp of an object instance
 * 
 * @param uri The URI of the Web object instance
 * @param oldTimestamp The old timestamp
 * @param newTimestamp The new timestamp
 */
public void updateObjectInstanceTimestamp(String uri, Date oldTimestamp,
		Date newTimestamp) {
	Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
	Filter timestampFilter = new FilterPredicate("timestamp", FilterOperator.EQUAL, oldTimestamp);
	Query query = new Query(OBJECT_INSTANCE)
		.setFilter(uriFilter)
		.setFilter(timestampFilter);
	Entity instance = datastoreService.prepare(query).asSingleEntity();
	if (instance == null) {
		throw new IllegalArgumentException(
				"No record with matching URI and timestamp was found");
	}
	instance.setProperty("timestamp", newTimestamp);
	datastoreService.put(instance);
}
 
开发者ID:lorenzosaino,项目名称:gae-webmonitor,代码行数:23,代码来源:DataStoreService.java

示例12: getAllObjectInstances

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Get all instances of an object present in the data store
 * 
 * @param uri The URI of the Web object
 * @return The list of Web instances
 */
public List<WebObjectInstance> getAllObjectInstances(String uri) {
	Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
	Query query = new Query(OBJECT_INSTANCE)
			.setFilter(uriFilter)
			.addSort("timestamp", SortDirection.DESCENDING);

	List<Entity> instances = datastoreService.prepare(query)
			.asList(FetchOptions.Builder.withDefaults());
	List<WebObjectInstance> instanceList = new ArrayList<WebObjectInstance>();
	for (Entity e : instances) {
		String content = ((Text) e.getProperty("content")).getValue();
		String contentType = (String) e.getProperty("contentType");
		int statusCode = ((Integer) e.getProperty("statusCode")).intValue();
		Date timestamp = (Date) e.getProperty("timestamp");
		instanceList.add(new WebObjectInstance(uri, content, contentType,
				timestamp, statusCode));
	}
	return instanceList;
}
 
开发者ID:lorenzosaino,项目名称:gae-webmonitor,代码行数:26,代码来源:DataStoreService.java

示例13: getMostRecentObjectInstance

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Get the most recent instance of a web object available
 * 
 * @param uri The URI of the Web object
 * @return The instance of the Web object
 */
public WebObjectInstance getMostRecentObjectInstance(String uri) {
	Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
	Query query = new Query(OBJECT_INSTANCE)
			.setFilter(uriFilter)
			.addSort("timestamp", SortDirection.DESCENDING);
	List<Entity> instances = datastoreService.prepare(query).asList(
			FetchOptions.Builder.withDefaults());
	if (instances == null || instances.isEmpty()) {
		return null;
	}
	Entity mostRecentInstance = instances.get(0);
	String content = ((Text) mostRecentInstance.getProperty("content"))
			.getValue();
	String contentType = (String) mostRecentInstance
			.getProperty("contentType");
	Date timestamp = (Date) mostRecentInstance.getProperty("timestamp");
	int statusCode = ((Long) mostRecentInstance.getProperty("statusCode"))
			.intValue();
	return new WebObjectInstance(uri, content, contentType, timestamp,
			statusCode);
}
 
开发者ID:lorenzosaino,项目名称:gae-webmonitor,代码行数:28,代码来源:DataStoreService.java

示例14: getAccountKeyByUser

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Returns the Account key associated with the specified user.
 * @param pm   reference to the persistence manager
 * @param user user to return the account key for
 * @return the Account key associated with the specified user; or <code>null</code> if no account is associated with the specified user
 */
public static Key getAccountKeyByUser( final PersistenceManager pm, final User user ) {
	final String memcacheKey = CACHE_KEY_USER_ACCOUNT_KEY_PREFIX + user.getEmail();
	final String accountKeyString = (String) memcacheService.get( memcacheKey );
	if ( accountKeyString != null )
		return KeyFactory.stringToKey( accountKeyString );
	
	final Query q = new Query( Account.class.getSimpleName() );
	q.setFilter( new FilterPredicate( "user", FilterOperator.EQUAL, user ) );
	q.setKeysOnly();
	final List< Entity > entityList = DatastoreServiceFactory.getDatastoreService().prepare( q ).asList( FetchOptions.Builder.withDefaults() );
	if ( entityList.isEmpty() )
		return null;
	
	final Key accountKey = entityList.get( 0 ).getKey();
	try {
		memcacheService.put( memcacheKey, KeyFactory.keyToString( accountKey ) );
	}
	catch ( final MemcacheServiceException mse ) {
		LOGGER.log( Level.WARNING, "Failed to put key to memcache: " + memcacheKey, mse );
		// Ignore memcache errors, do not prevent serving user request
	}
	
	return accountKey;
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:31,代码来源:CachingService.java

示例15: getAccountKeyByAuthKey

import com.google.appengine.api.datastore.Query.FilterOperator; //导入依赖的package包/类
/**
 * Returns the Account key associated with the specified authorization key.
 * @param pm               reference to the persistence manager
 * @param authorizationKey authorization key to return the account key for
 * @return the Account key associated with the specified authorization key; or <code>null</code> if the authorization key is invalid
 */
public static Key getAccountKeyByAuthKey( final PersistenceManager pm, final String authorizationKey ) {
	final String memcacheKey = CACHE_KEY_AUTH_KEY_ACCOUNT_KEY_PREFIX + authorizationKey;
	final String accountKeyString = (String) memcacheService.get( memcacheKey );
	if ( accountKeyString != null )
		return KeyFactory.stringToKey( accountKeyString );
	
	final Query q = new Query( Account.class.getSimpleName() );
	q.setFilter( new FilterPredicate( "authorizationKey", FilterOperator.EQUAL, authorizationKey ) );
	q.setKeysOnly();
	final List< Entity > entityList = DatastoreServiceFactory.getDatastoreService().prepare( q ).asList( FetchOptions.Builder.withDefaults() );
	if ( entityList.isEmpty() )
		return null;
	
	final Key accountKey = entityList.get( 0 ).getKey();
	try {
		memcacheService.put( memcacheKey, KeyFactory.keyToString( accountKey ) );
	}
	catch ( final MemcacheServiceException mse ) {
		LOGGER.log( Level.WARNING, "Failed to put key to memcache: " + memcacheKey, mse );
		// Ignore memcache errors, do not prevent serving user request
	}
	
	return accountKey;
}
 
开发者ID:icza,项目名称:sc2gears,代码行数:31,代码来源:CachingService.java


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