本文整理汇总了Java中com.google.appengine.api.datastore.Query.FilterOperator.EQUAL属性的典型用法代码示例。如果您正苦于以下问题:Java FilterOperator.EQUAL属性的具体用法?Java FilterOperator.EQUAL怎么用?Java FilterOperator.EQUAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.appengine.api.datastore.Query.FilterOperator
的用法示例。
在下文中一共展示了FilterOperator.EQUAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNationalHighScores
/**
* 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));
}
示例2: getMonthlyHighScores
/**
* 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));
}
示例3: getWeeklyHighScores
/**
* 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));
}
示例4: getDailyHighScores
/**
* 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));
}
示例5: removeObject
/**
* 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());
}
示例6: updateObjectInstanceTimestamp
/**
* 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);
}
示例7: getAllObjectInstances
/**
* 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;
}
示例8: getMostRecentObjectInstance
/**
* 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);
}
示例9: getUserByHandle
/**
* Gets the user from the Datastore using their unique user handle.
*
* @param handle the handle of the user
* @return the {@link GameUser}
*/
@SuppressWarnings("unchecked")
@ApiMethod(path = "users/name/{handle}", name = "users.getByHandle")
public GameUser getUserByHandle(@Named("handle") String handle) {
Filter userHandleFilter =
new Query.FilterPredicate("user_handle", FilterOperator.EQUAL, handle);
Query q = new Query("User").setFilter(userHandleFilter);
Entity entity = StorageUtils.getDatastore().prepare(q).asSingleEntity();
if (entity == null) {
return null;
}
GameUser user = new GameUser();
user.setAccount(entity.getKey().getName());
user.setHandle((String) entity.getProperty("user_handle"));
user.setFriends((ArrayList<String>) entity.getProperty("friends"));
user.setTotalGames((Long) entity.getProperty("total_games"));
user.setTotalGems((Long) entity.getProperty("total_gems"));
user.setTotalMobsKilled((Long) entity.getProperty("total_mobs_killed"));
return user;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-cloud-adventure-sample-backend-java,代码行数:25,代码来源:GameUserEndpoint.java
示例10: getByDeviceId
/**
* Gets a not null list of device entities by device id.
*
* @param deviceId the id of the device.
*/
protected List<DeviceEntity> getByDeviceId(String deviceId) {
List<DeviceEntity> result = new ArrayList<DeviceEntity>();
Filter deviceIdFilter =
new FilterPredicate(DeviceEntity.DEVICEID_PROPERTY, FilterOperator.EQUAL, deviceId);
Query query = new Query(DeviceEntity.KIND).setFilter(deviceIdFilter);
PreparedQuery preparedQuery = dataStore.prepare(query);
for (Entity entity : preparedQuery.asIterable()) {
result.add(new DeviceEntity(entity));
}
return result;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:20,代码来源:DeviceService.java
示例11: getPlayers
/**
* Gets a list of players that a given user can play with. This implementation simply returns the
* list of all players other than the current user.
*
* @param user user making the request.
*/
public List<Player> getPlayers(User user) {
List<Player> results = new ArrayList<Player>();
Filter activePlayersFilter =
new FilterPredicate(PlayerEntity.ACTIVE_PROPERTY, FilterOperator.EQUAL, true);
Query query = new Query(PlayerEntity.KIND).setFilter(activePlayersFilter);
PreparedQuery preparedQuery = dataStore.prepare(query);
for (Entity entity : preparedQuery.asIterable()) {
PlayerEntity playerEntity = new PlayerEntity(entity);
if (!playerEntity.getEmail().equalsIgnoreCase(user.getEmail())) {
results.add(new Player(playerEntity.getId(), playerEntity.getNickname()));
}
}
return results;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:23,代码来源:PlayerService.java
示例12: updateRegistrations
private static void updateRegistrations(Level level, Map<String, School> schools) {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
for (School school : schools.values()) {
Filter schoolNameFilter = new FilterPredicate("schoolName", FilterOperator.EQUAL, school.getName());
Filter schoolLevelFilter = new FilterPredicate("schoolLevel", FilterOperator.EQUAL, level.toString());
Filter regTypeFilter = new FilterPredicate("registrationType", FilterOperator.EQUAL, "coach");
Query query = new Query("registration").setFilter(CompositeFilterOperator.and(schoolNameFilter, schoolLevelFilter, regTypeFilter));
List<Entity> registrations = datastore.prepare(query).asList(FetchOptions.Builder.withDefaults());
if (registrations.size() > 0) {
Entity registration = registrations.get(0);
for (Entry<Test, Integer> numTest : school.getNumTests().entrySet()) {
registration.setProperty(numTest.getKey().toString(), numTest.getValue());
}
datastore.put(registration);
}
}
}
示例13: isObjectRegistered
/**
* Check whether a specific object is in the datastore
*
* @param uri The URI of the object
* @return true if present, false otherwise
*/
public boolean isObjectRegistered(String uri) {
Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
Query query = new Query(OBJECT).setFilter(uriFilter);
Entity object = datastoreService.prepare(query).asSingleEntity();
return (object != null);
}
示例14: getObjectsSubscribed
/**
* Get the list of objects a user is subscribed to
*
* @param email The user email address
* @return The list of objects' URIs
*/
public List<String> getObjectsSubscribed(String email) {
Filter emailFilter = new FilterPredicate("email", FilterOperator.EQUAL, email);
Query query = new Query(SUBSCRIPTION).setFilter(emailFilter);
List<Entity> entity = datastoreService.prepare(query)
.asList(FetchOptions.Builder.withDefaults());
List<String> uri = new ArrayList<String>();
for (Entity e : entity) {
uri.add((String) e.getProperty("uri"));
}
return uri;
}
示例15: getSubscribers
/**
* Get a list of subscribed users for a given object
*
* @param uri The URI of the object
* @return The list of subscribed users
*/
public List<String> getSubscribers(String uri) {
Filter uriFilter = new FilterPredicate("uri", FilterOperator.EQUAL, uri);
Query query = new Query(SUBSCRIPTION).setFilter(uriFilter);
List<Entity> entity = datastoreService.prepare(query).asList(
FetchOptions.Builder.withDefaults());
List<String> email = new ArrayList<String>();
for (Entity e : entity) {
email.add((String) e.getProperty("email"));
}
return email;
}