Search in sources :

Example 11 with TenantAwareOperation

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;
}
Also used : Event(io.spine.core.Event) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation)

Example 12 with TenantAwareOperation

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;
}
Also used : Event(io.spine.core.Event) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation)

Example 13 with TenantAwareOperation

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;
}
Also used : Event(io.spine.core.Event) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation)

Example 14 with TenantAwareOperation

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();
}
Also used : TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation) CommandOperation(io.spine.server.tenant.CommandOperation) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation)

Example 15 with TenantAwareOperation

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();
}
Also used : TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation) CommandOperation(io.spine.server.tenant.CommandOperation) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation)

Aggregations

TenantAwareOperation (io.spine.server.tenant.TenantAwareOperation)18 CommandOperation (io.spine.server.tenant.CommandOperation)7 Event (io.spine.core.Event)4 TenantId (io.spine.core.TenantId)2 EventOperation (io.spine.server.tenant.EventOperation)2 Test (org.junit.Test)2 Subscription (io.spine.client.Subscription)1 Command (io.spine.core.Command)1 ProjectAggregate (io.spine.server.aggregate.given.AggregateRepositoryTestEnv.ProjectAggregate)1 TenantAwareFunction0 (io.spine.server.tenant.TenantAwareFunction0)1 Iterator (java.util.Iterator)1