use of io.spine.server.tenant.TenantAwareOperation in project core-java by SpineEventEngine.
the class EventRootCommandIdShould method readEvents.
/**
* Reads all events from the bounded context event store.
*/
private List<Event> readEvents() {
final MemoizingObserver<Event> observer = StreamObservers.memoizingObserver();
final TenantAwareOperation operation = new TenantAwareOperation(TENANT_ID) {
@Override
public void run() {
boundedContext.getEventBus().getEventStore().read(allEventsQuery(), observer);
}
};
operation.execute();
final List<Event> results = observer.responses();
return results;
}
use of io.spine.server.tenant.TenantAwareOperation in project core-java by SpineEventEngine.
the class EventBusTestEnv method readEvents.
/**
* Reads all events from the event bus event store for a tenant specified by
* the {@link EventBusTestEnv#TENANT_ID}.
*/
public static List<Event> readEvents(final EventBus eventBus) {
final MemoizingObserver<Event> observer = memoizingObserver();
final TenantAwareOperation operation = new TenantAwareOperation(TENANT_ID) {
@Override
public void run() {
eventBus.getEventStore().read(allEventsQuery(), observer);
}
};
operation.execute();
final List<Event> results = observer.responses();
return results;
}
use of io.spine.server.tenant.TenantAwareOperation in project core-java by SpineEventEngine.
the class AggregateTestEnv method readAllEvents.
/**
* Reads all events from the bounded context for the provided tenant.
*/
public static List<Event> readAllEvents(final BoundedContext boundedContext, TenantId tenantId) {
final MemoizingObserver<Event> queryObserver = memoizingObserver();
final TenantAwareOperation operation = new TenantAwareOperation(tenantId) {
@Override
public void run() {
boundedContext.getEventBus().getEventStore().read(allEventsQuery(), queryObserver);
}
};
operation.execute();
final List<Event> responses = queryObserver.responses();
return responses;
}
use of io.spine.server.tenant.TenantAwareOperation in project core-java by SpineEventEngine.
the class CommandStore method store.
/**
* Stores the command.
*
* <p>The underlying storage must be opened.
*
* @param command the command to store
* @throws IllegalStateException if the storage is closed
*/
public void store(final Command command) {
keepTenantId(command);
final TenantAwareOperation op = new Operation(this, command) {
@Override
public void run() {
repository.store(command);
}
};
op.execute();
}
use of io.spine.server.tenant.TenantAwareOperation in project core-java by SpineEventEngine.
the class CommandStore method updateStatus.
/**
* Updates the status of the command with the rejection.
* @param commandEnvelope the command to update
* @param rejection why the command was rejected
*/
private void updateStatus(CommandEnvelope commandEnvelope, final Rejection rejection) {
keepTenantId(commandEnvelope.getCommand());
final TenantAwareOperation op = new Operation(this, commandEnvelope) {
@Override
public void run() {
repository.updateStatus(commandId(), rejection);
}
};
op.execute();
}
Aggregations