From bea39845e0903b3e631b7b0839b48ac47f025699 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Fri, 16 Oct 2020 11:51:21 +0200 Subject: [PATCH] [New] Added ConfirmationPolicy.doConfirmation(Action) This is then called in the ExecuteActivityCommand class after calling the ExecutionPolicy, so that the correct confirmation method is called depending on the new state of the action --- .../command/ExecuteActivityCommand.java | 2 +- .../execution/policy/ConfirmationPolicy.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/li.strolch.service/src/main/java/li/strolch/execution/command/ExecuteActivityCommand.java b/li.strolch.service/src/main/java/li/strolch/execution/command/ExecuteActivityCommand.java index 421a4b56a..e133c92ad 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/command/ExecuteActivityCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/command/ExecuteActivityCommand.java @@ -91,7 +91,7 @@ public class ExecuteActivityCommand extends BasePlanningAndExecutionCommand logger.info("Action " + action.getLocator() + " is now being executed..."); executionPolicy.toExecution(action); - confirmationPolicy.toExecution(action); + confirmationPolicy.doConfirmation(action); if (action.getState() == State.EXECUTED) this.needsRetriggerOfExecution = true; diff --git a/li.strolch.service/src/main/java/li/strolch/execution/policy/ConfirmationPolicy.java b/li.strolch.service/src/main/java/li/strolch/execution/policy/ConfirmationPolicy.java index e8e4173a8..0f9af8a1e 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/policy/ConfirmationPolicy.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/policy/ConfirmationPolicy.java @@ -24,6 +24,10 @@ public class ConfirmationPolicy extends StrolchPolicy { // do nothing } + public void toPlanning(Action action) { + // do nothing + } + public void toPlanned(Action action) { // do nothing } @@ -60,4 +64,46 @@ public class ConfirmationPolicy extends StrolchPolicy { public void undo() { // nothing to undo } + + /** + * Calls the appropriate confirmation method depending on the state of the {@link Action} + * + * @param action + * the action for which to perform the confirmation call + */ + public void doConfirmation(Action action) { + switch (action.getState()) { + + case CREATED: + toCreated(action); + break; + case PLANNING: + toPlanning(action); + break; + case PLANNED: + toPlanned(action); + break; + case EXECUTABLE: + toExecutable(action); + break; + case EXECUTION: + toExecution(action); + break; + case WARNING: + toWarning(action); + break; + case ERROR: + toError(action); + break; + case STOPPED: + toStopped(action); + break; + case EXECUTED: + toExecuted(action); + break; + case CLOSED: + toClosed(action); + break; + } + } }