use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method queryKeys.
@Override
public Iterable<Key> queryKeys(Query<Key> query) {
Iterable<Key> keys = () -> getDatastoreReadWriter().run(query);
maybeEmitEvent(new AfterQueryEvent(keys, query));
return keys;
}
use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method queryKeysOrEntities.
@Override
public <T> DatastoreResultsIterable<?> queryKeysOrEntities(Query query, Class<T> entityClass) {
QueryResults results = getDatastoreReadWriter().run(query);
DatastoreResultsIterable resultsIterable;
if (results.getResultClass() == Key.class) {
resultsIterable = new DatastoreResultsIterable(results, results.getCursorAfter());
} else {
resultsIterable = new DatastoreResultsIterable<>(convertEntitiesForRead(results, entityClass), results.getCursorAfter());
}
maybeEmitEvent(new AfterQueryEvent(resultsIterable, query));
return resultsIterable;
}
use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method findAll.
@Override
public <T> DatastoreResultsCollection<T> findAll(Class<T> entityClass, DatastoreQueryOptions queryOptions) {
DatastorePersistentEntity<?> persistentEntity = getPersistentEntity(entityClass);
EntityQuery.Builder builder = Query.newEntityQueryBuilder().setKind(persistentEntity.kindName());
applyQueryOptions(builder, queryOptions, persistentEntity);
Query query = builder.build();
QueryResults queryResults = getDatastoreReadWriter().run(query);
Collection<T> convertedResults = convertEntitiesForRead(queryResults, entityClass);
maybeEmitEvent(new AfterQueryEvent(convertedResults, query));
return new DatastoreResultsCollection<>(convertedResults, queryResults != null ? queryResults.getCursorAfter() : null);
}
use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method keyQueryByExample.
@Override
public <T> Iterable<Key> keyQueryByExample(Example<T> example, DatastoreQueryOptions queryOptions) {
Query query = exampleToQuery(example, queryOptions, true);
Iterable<Key> results = () -> getDatastoreReadWriter().run(query);
maybeEmitEvent(new AfterQueryEvent(results, query));
return results;
}
use of com.google.cloud.spring.data.datastore.core.mapping.event.AfterQueryEvent in project spring-cloud-gcp by GoogleCloudPlatform.
the class DatastoreTemplate method query.
@Override
public <T> DatastoreResultsIterable<T> query(Query<? extends BaseEntity> query, Class<T> entityClass) {
QueryResults<? extends BaseEntity> results = getDatastoreReadWriter().run(query);
List<T> convertedResults = convertEntitiesForRead(results, entityClass);
maybeEmitEvent(new AfterQueryEvent(convertedResults, query));
return results != null ? new DatastoreResultsIterable<>(convertedResults, results.getCursorAfter()) : null;
}
Aggregations