[Fix] Fixed re-executing ERRORed Action
This commit is contained in:
parent
b8b0806e12
commit
3e2e21da6d
|
@ -135,21 +135,21 @@ public enum State {
|
||||||
* @return true if {@link #inExecutionPhase()} but not executed and not already in warning
|
* @return true if {@link #inExecutionPhase()} but not executed and not already in warning
|
||||||
*/
|
*/
|
||||||
public boolean canSetToWarning() {
|
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
|
* @return true if {@link #inExecutionPhase()} but not executed and not already stopped
|
||||||
*/
|
*/
|
||||||
public boolean canSetToStopped() {
|
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
|
* @return true if {@link #inExecutionPhase()} but not executed and not already in error
|
||||||
*/
|
*/
|
||||||
public boolean canSetToError() {
|
public boolean canSetToError() {
|
||||||
return inExecutionPhase() && this != State.EXECUTED && this != State.ERROR;
|
return inExecutionPhase() && this != State.EXECUTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,8 +87,11 @@ public abstract class ExecutionCommand extends Command implements TimeOrderingVi
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// in series we can never have two Actions in execution, so if we found the action in execution, we stop
|
// 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;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
boolean canExecute = isExecutable(element);
|
boolean canExecute = isExecutable(element);
|
||||||
if (canExecute) {
|
if (canExecute) {
|
||||||
|
@ -118,9 +121,19 @@ public abstract class ExecutionCommand extends Command implements TimeOrderingVi
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isExecutable(IActivityElement element) {
|
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 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
|
@Override
|
||||||
|
|
|
@ -38,6 +38,11 @@ public class SetActionToErrorCommand extends ExecutionCommand {
|
||||||
Activity rootElement = this.action.getRootElement();
|
Activity rootElement = this.action.getRootElement();
|
||||||
tx().lock(rootElement);
|
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();
|
State currentState = rootElement.getState();
|
||||||
|
|
||||||
getExecutionPolicy(this.action).toError(this.action);
|
getExecutionPolicy(this.action).toError(this.action);
|
||||||
|
|
|
@ -38,6 +38,11 @@ public class SetActionToStoppedCommand extends ExecutionCommand {
|
||||||
Activity rootElement = this.action.getRootElement();
|
Activity rootElement = this.action.getRootElement();
|
||||||
tx().lock(rootElement);
|
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();
|
State currentState = rootElement.getState();
|
||||||
|
|
||||||
getExecutionPolicy(this.action).toStopped(this.action);
|
getExecutionPolicy(this.action).toStopped(this.action);
|
||||||
|
|
|
@ -38,6 +38,11 @@ public class SetActionToWarningCommand extends ExecutionCommand {
|
||||||
Activity rootElement = this.action.getRootElement();
|
Activity rootElement = this.action.getRootElement();
|
||||||
tx().lock(rootElement);
|
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();
|
State currentState = rootElement.getState();
|
||||||
|
|
||||||
getExecutionPolicy(this.action).toWarning(this.action);
|
getExecutionPolicy(this.action).toWarning(this.action);
|
||||||
|
|
Loading…
Reference in New Issue