use of io.spine.server.tenant.QueryOperation in project core-java by SpineEventEngine.
the class Stand method execute.
/**
* Reads a particular set of items from the read-side of the application and
* feed the result into an instance.
*
* <p>{@link Query} defines the query target and the expected detail level for response.
*
* <p>The query results are fed to an instance
* of {@link StreamObserver}<{@link QueryResponse}>.
*
* @param query an instance of query
* @param responseObserver an observer to feed the query results to.
*/
public void execute(final Query query, final StreamObserver<QueryResponse> responseObserver) {
queryValidator.validate(query, responseObserver);
final TypeUrl type = Queries.typeOf(query);
final QueryProcessor queryProcessor = processorFor(type);
final QueryOperation op = new QueryOperation(query) {
@Override
public void run() {
final ImmutableCollection<Any> readResult = queryProcessor.process(query());
final QueryResponse response = QueryResponse.newBuilder().addAllMessages(readResult).setResponse(Responses.ok()).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
};
op.execute();
}
Aggregations