use of io.spine.core.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;
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class CEntity method createForError.
static CEntity createForError(Command command, Error error) {
checkNotNull(command);
checkNotNull(error);
final CommandId id = Records.getOrGenerateCommandId(command);
final CEntity result = create(id);
result.setError(id, command, error);
return result;
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class CEntity method createForStatus.
static CEntity createForStatus(Command command, CommandStatus status) {
checkNotNull(command);
checkNotNull(status);
final CommandId commandId = command.getId();
final CEntity entity = create(commandId);
entity.setCommandAndStatus(command, status);
return entity;
}
use of io.spine.core.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.getId();
if (cause instanceof ThrowableMessage) {
final ThrowableMessage throwableMessage = (ThrowableMessage) cause;
log.rejectedWith(throwableMessage, commandMessage, commandId);
updateStatus(commandEnvelope, toRejection(throwableMessage, 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);
}
}
use of io.spine.core.CommandId in project core-java by SpineEventEngine.
the class CommandStore method getStatus.
/**
* Obtains the processing status for the command with the passed ID.
*
* <p>Invoking this method must be performed within a {@link TenantAwareFunction} or
* {@link TenantAwareOperation}.
*/
public ProcessingStatus getStatus(CommandId commandId) {
final Func<CommandId, ProcessingStatus> func = new Func<CommandId, ProcessingStatus>(this) {
@Override
public ProcessingStatus apply(@Nullable CommandId input) {
checkNotNull(input);
final ProcessingStatus status = repository.getStatus(input);
return status;
}
};
return func.execute(commandId);
}
Aggregations