use of com.google.appengine.api.datastore.Query.FilterPredicate in project Cached-Datastore by Emperorlou.
the class QueryHelper method getFilteredList.
public List<CachedEntity> getFilteredList(String kind, int limit, Cursor cursor, String fieldName, FilterOperator operator, Object equalToValue, String fieldName2, FilterOperator operator2, Object equalToValue2, String fieldName3, FilterOperator operator3, Object equalToValue3, String fieldName4, FilterOperator operator4, Object equalToValue4) {
FilterPredicate f1 = new FilterPredicate(fieldName, operator, equalToValue);
FilterPredicate f2 = new FilterPredicate(fieldName2, operator2, equalToValue2);
FilterPredicate f3 = new FilterPredicate(fieldName3, operator3, equalToValue3);
FilterPredicate f4 = new FilterPredicate(fieldName4, operator4, equalToValue4);
Filter filter = CompositeFilterOperator.and(f1, f2, f3, f4);
return ds.fetchAsList(kind, filter, limit, cursor);
}
use of com.google.appengine.api.datastore.Query.FilterPredicate in project getting-started-java by GoogleCloudPlatform.
the class DatastoreSessionFilter method deleteSessionWithValue.
// [END deleteSessionVariables]
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();
}
}
}
use of com.google.appengine.api.datastore.Query.FilterPredicate in project codeu-2018-team12 by codeu-2018-team12.
the class PersistentDataStore method setUpConversationEntity.
/**
* Retrieves a Conversation Entity object
*
* @param conversation user in application
* @return Conversation Entity
*/
private Entity setUpConversationEntity(Conversation conversation) {
Query query = new Query("chat-conversations").setFilter(new FilterPredicate("uuid", FilterOperator.EQUAL, conversation.getId().toString()));
PreparedQuery preparedQuery = datastore.prepare(query);
return preparedQuery.asSingleEntity();
}
use of com.google.appengine.api.datastore.Query.FilterPredicate in project codeu-2018-team12 by codeu-2018-team12.
the class PersistentDataStore method updateEntity.
/**
* Updates a User object in the Datstore service
*/
public void updateEntity(User user) {
Query query = new Query("chat-users").setFilter(new FilterPredicate("uuid", FilterOperator.EQUAL, user.getId().toString()));
PreparedQuery preparedQuery = datastore.prepare(query);
Entity resultEntity = preparedQuery.asSingleEntity();
resultEntity.setProperty("biography", user.getBio());
datastore.put(resultEntity);
}
use of com.google.appengine.api.datastore.Query.FilterPredicate in project java-docs-samples by GoogleCloudPlatform.
the class MetadataPropertiesTest method representationsOfProperty.
// [START property_representation_query_example]
Collection<String> representationsOfProperty(DatastoreService ds, String kind, String property) {
// Start with unrestricted non-keys-only property query
Query q = new Query(Entities.PROPERTY_METADATA_KIND);
// Limit to specified kind and property
q.setFilter(new FilterPredicate("__key__", Query.FilterOperator.EQUAL, Entities.createPropertyKey(kind, property)));
// Get query result
Entity propInfo = ds.prepare(q).asSingleEntity();
// Return collection of property representations
return (Collection<String>) propInfo.getProperty("property_representation");
}
Aggregations