Search in sources :

Example 6 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class CommandScheduler method isScheduledAlready.

private static boolean isScheduledAlready(Command command) {
    final CommandId id = command.getId();
    final boolean isScheduledAlready = scheduledCommandIds.contains(id);
    return isScheduledAlready;
}
Also used : CommandId(io.spine.base.CommandId)

Example 7 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class CommandStore method updateCommandStatus.

// OK for this consolidated error handling.
@SuppressWarnings("ChainOfInstanceofChecks")
public void updateCommandStatus(CommandEnvelope commandEnvelope, Throwable cause, Log log) {
    final Message commandMessage = commandEnvelope.getMessage();
    final CommandId commandId = commandEnvelope.getCommandId();
    if (cause instanceof FailureThrowable) {
        final FailureThrowable failure = (FailureThrowable) cause;
        log.failureHandling(failure, commandMessage, commandId);
        updateStatus(commandEnvelope, failure.toFailure(commandEnvelope.getCommand()));
    } else if (cause instanceof Exception) {
        final Exception exception = (Exception) cause;
        log.errorHandling(exception, commandMessage, commandId);
        updateStatus(commandEnvelope, exception);
    } else {
        log.errorHandlingUnknown(cause, commandMessage, commandId);
        final Error error = Errors.fromThrowable(cause);
        updateStatus(commandEnvelope, error);
    }
}
Also used : Message(com.google.protobuf.Message) FailureThrowable(io.spine.base.FailureThrowable) Error(io.spine.base.Error) CommandId(io.spine.base.CommandId) CommandException(io.spine.server.commandbus.CommandException)

Example 8 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class Entity method createForError.

static Entity createForError(Command command, Error error) {
    checkNotNull(command);
    checkNotNull(error);
    final CommandId id = Records.getOrGenerateCommandId(command);
    final Entity result = create(id);
    result.setError(id, command, error);
    return result;
}
Also used : AbstractEntity(io.spine.server.entity.AbstractEntity) CommandId(io.spine.base.CommandId)

Example 9 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class Entity method createForStatus.

static Entity createForStatus(Command command, CommandStatus status) {
    checkNotNull(command);
    checkNotNull(status);
    final CommandId commandId = command.getId();
    final Entity entity = create(commandId);
    entity.setCommandAndStatus(command, status);
    return entity;
}
Also used : AbstractEntity(io.spine.server.entity.AbstractEntity) CommandId(io.spine.base.CommandId)

Example 10 with CommandId

use of io.spine.base.CommandId in project core-java by SpineEventEngine.

the class TestActorRequestFactory method createCommandId.

public CommandId createCommandId() {
    final String uid = Identifiers.newUuid();
    final CommandId commandId = CommandId.newBuilder().setUuid(uid).build();
    return commandId;
}
Also used : CommandId(io.spine.base.CommandId)

Aggregations

CommandId (io.spine.base.CommandId)20 Test (org.junit.Test)7 Command (io.spine.base.Command)6 Message (com.google.protobuf.Message)5 Error (io.spine.base.Error)4 CommandRecord (io.spine.server.commandbus.CommandRecord)4 CommandContext (io.spine.base.CommandContext)3 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)3 TenantId (io.spine.users.TenantId)3 Commands.getMessage (io.spine.base.Commands.getMessage)2 CommandEnvelope (io.spine.envelope.CommandEnvelope)2 CommandMessage.createProjectMessage (io.spine.server.commandbus.Given.CommandMessage.createProjectMessage)2 AbstractEntity (io.spine.server.entity.AbstractEntity)2 Nullable (javax.annotation.Nullable)2 ImmutableList (com.google.common.collect.ImmutableList)1 Duration (com.google.protobuf.Duration)1 Timestamp (com.google.protobuf.Timestamp)1 CommandStatus (io.spine.base.CommandStatus)1 FailureThrowable (io.spine.base.FailureThrowable)1 Identifiers.idToString (io.spine.base.Identifiers.idToString)1