diff --git a/li.strolch.model/src/main/java/li/strolch/model/State.java b/li.strolch.model/src/main/java/li/strolch/model/State.java index d5074e527..5259f499e 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/State.java +++ b/li.strolch.model/src/main/java/li/strolch/model/State.java @@ -135,21 +135,21 @@ public enum State { * @return true if {@link #inExecutionPhase()} but not executed and not already in warning */ public boolean canSetToWarning() { - return inExecutionPhase() && this != State.EXECUTED && this != State.WARNING; + return inExecutionPhase() && this != State.EXECUTED; } /** * @return true if {@link #inExecutionPhase()} but not executed and not already stopped */ public boolean canSetToStopped() { - return inExecutionPhase() && this != State.EXECUTED && this != State.STOPPED; + return inExecutionPhase() && this != State.EXECUTED; } /** * @return true if {@link #inExecutionPhase()} but not executed and not already in error */ public boolean canSetToError() { - return inExecutionPhase() && this != State.EXECUTED && this != State.ERROR; + return inExecutionPhase() && this != State.EXECUTED; } /** diff --git a/li.strolch.service/src/main/java/li/strolch/execution/command/ExecutionCommand.java b/li.strolch.service/src/main/java/li/strolch/execution/command/ExecutionCommand.java index c509fb181..4a1955954 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/command/ExecutionCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/command/ExecutionCommand.java @@ -87,8 +87,11 @@ public abstract class ExecutionCommand extends Command implements TimeOrderingVi continue; // in series we can never have two Actions in execution, so if we found the action in execution, we stop - if (element instanceof Action && state == State.EXECUTION) + if (element instanceof Action // + && (state == State.EXECUTION // + || state == State.WARNING)) { break; + } boolean canExecute = isExecutable(element); if (canExecute) { @@ -118,9 +121,19 @@ public abstract class ExecutionCommand extends Command implements TimeOrderingVi } protected boolean isExecutable(IActivityElement element) { - if (element.getState().compareTo(State.EXECUTED) >= 0) + State state = element.getState(); + if (state.compareTo(State.EXECUTED) >= 0) return false; - return element instanceof Activity || element.getState().compareTo(State.EXECUTION) < 0; + + if (element instanceof Activity) + return true; + + // not yet in execution + if (state.compareTo(State.EXECUTION) < 0) + return true; + + // in stopped or error + return state == State.STOPPED || state == State.ERROR; } @Override diff --git a/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToErrorCommand.java b/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToErrorCommand.java index 64edb717d..3234b365d 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToErrorCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToErrorCommand.java @@ -38,6 +38,11 @@ public class SetActionToErrorCommand extends ExecutionCommand { Activity rootElement = this.action.getRootElement(); tx().lock(rootElement); + if (this.action.getState() == State.ERROR) { + logger.warn("Action " + this.action.getLocator() + " is already in ERROR! Not changing."); + return; + } + State currentState = rootElement.getState(); getExecutionPolicy(this.action).toError(this.action); diff --git a/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToStoppedCommand.java b/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToStoppedCommand.java index ba045ca86..c299aa530 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToStoppedCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToStoppedCommand.java @@ -38,6 +38,11 @@ public class SetActionToStoppedCommand extends ExecutionCommand { Activity rootElement = this.action.getRootElement(); tx().lock(rootElement); + if (this.action.getState() == State.STOPPED) { + logger.warn("Action " + this.action.getLocator() + " is already in STOPPED! Not changing."); + return; + } + State currentState = rootElement.getState(); getExecutionPolicy(this.action).toStopped(this.action); diff --git a/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToWarningCommand.java b/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToWarningCommand.java index cf93d9497..267cf3984 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToWarningCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/command/SetActionToWarningCommand.java @@ -38,6 +38,11 @@ public class SetActionToWarningCommand extends ExecutionCommand { Activity rootElement = this.action.getRootElement(); tx().lock(rootElement); + if (this.action.getState() == State.WARNING) { + logger.warn("Action " + this.action.getLocator() + " is already in WARNING! Not changing."); + return; + } + State currentState = rootElement.getState(); getExecutionPolicy(this.action).toWarning(this.action);