Class AbstractStep
- All Implemented Interfaces:
Serializable,Step
public abstract class AbstractStep extends Object implements Step
execute() and
getActor().- Since:
- 2.5
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from interface org.apache.wiki.workflow.Step
TIME_NOT_SET -
Constructor Summary
Constructors Modifier Constructor Description AbstractStep(int workflowId, Map<String,Serializable> workflowContext, String messageKey)Constructs a new Step belonging to a specified Workflow and having a specified message key.protectedAbstractStep(String messageKey)Protected constructor that creates a new Step with a specified message key. -
Method Summary
Modifier and Type Method Description protected voidaddError(String message)Protected helper method that adds a String representing an error message to the Step's cached errors list.voidaddSuccessor(Outcome outcome, Step step)Adds a successor Step to this one, which will be triggered by a supplied Outcome.abstract Outcomeexecute()Executes the processing for this Step and returns an Outcome indicating if it succeeded (Outcome.STEP_COMPLETEorOutcome.STEP_ABORT).abstract PrincipalgetActor()The Principal responsible for completing this Step, such as a system user or actor assigned to a Decision.Collection<Outcome>getAvailableOutcomes()Returns a Collection of available outcomes, such as "approve", "deny" or "reassign", in the order in which they were added viaStep.addSuccessor(Outcome, Step).DategetEndTime()The end time for this Step.List<String>getErrors()Returns a List of error strings generated by this Step.StringgetMessageKey()Message key for human-friendly name of this Step, including any parameter substitutions.OutcomegetOutcome()Returns the Outcome of this Step's processing; by default,Outcome.STEP_CONTINUE.DategetStartTime()The start time for this Step.StepgetSuccessor(Outcome outcome)Identifies the next Step for a particular Outcome; if there is no next Step for this Outcome, this method returnsnull.Map<String,Serializable>getWorkflowContext()intgetWorkflowId()booleanisCompleted()Determines whether the Step is completed; if not, it is by definition awaiting action by the owner or in process.booleanisStarted()Determines whether the Step has started.voidsetOutcome(Outcome outcome)Sets the current Outcome for the step.voidsetWorkflow(int workflowId, Map<String,Serializable> workflowContext)method that sets the parent Workflow id and context post-construction.voidstart()Starts the Step, and sets the start time to the moment when this method is first invoked.
-
Constructor Details
-
AbstractStep
Protected constructor that creates a new Step with a specified message key. After construction, the methodsetWorkflow(int, Map)should be called.- Parameters:
messageKey- the Step's message key, such asdecision.editPageApproval. By convention, the message prefix should be a lower-case version of the Step's type, plus a period (e.g.,task.anddecision.).
-
AbstractStep
Constructs a new Step belonging to a specified Workflow and having a specified message key.- Parameters:
workflowId- the parent workflow id to setworkflowContext- the parent workflow context to setmessageKey- the Step's message key, such asdecision.editPageApproval. By convention, the message prefix should be a lower-case version of the Step's type, plus a period (e.g.,task.anddecision.).
-
-
Method Details
-
addSuccessor
Adds a successor Step to this one, which will be triggered by a supplied Outcome. Implementations should respect the order in which Outcomes are added;Step.getAvailableOutcomes()should return them in the same order they were added.- Specified by:
addSuccessorin interfaceStep- Parameters:
outcome- the Outcome triggering a particular successor Stepstep- the Step to associated with this Outcomes (nulldenotes no Steps)
-
getAvailableOutcomes
Returns a Collection of available outcomes, such as "approve", "deny" or "reassign", in the order in which they were added viaStep.addSuccessor(Outcome, Step). Concrete implementations should always return a defensive copy of the outcomes, not the original backing collection.- Specified by:
getAvailableOutcomesin interfaceStep- Returns:
- the set of outcomes
-
getErrors
Returns a List of error strings generated by this Step. If this Step generated no errors, this method returns a zero-length array. -
execute
Executes the processing for this Step and returns an Outcome indicating if it succeeded (
Outcome.STEP_COMPLETEorOutcome.STEP_ABORT). Processing instructions can do just about anything, such as executing custom business logic or changing the Step's final outcome viaStep.setOutcome(Outcome). A return value ofSTEP_COMPLETEindicates that the instructions executed completely, without errors;STEP_ABORTindicates that the Step and its parent Workflow should be aborted (that is, fail silently without error). If the execution step encounters any errors, it should throw a WikiException or a subclass.Note that successful execution of this methods does not necessarily mean that the Step is considered "complete"; rather, it just means that it has executed. Therefore, it is possible that
executecould run multiple times.- Specified by:
executein interfaceStep- Returns:
- the result of the Step, expressed as an Outcome
- Throws:
WikiException- if the step encounters errors while executing
-
getActor
The Principal responsible for completing this Step, such as a system user or actor assigned to a Decision. -
getEndTime
The end time for this Step. This value should be set when the step completes. ReturnsStep.TIME_NOT_SETif not completed yet.- Specified by:
getEndTimein interfaceStep- Returns:
- the end time
-
getMessageKey
Message key for human-friendly name of this Step, including any parameter substitutions. By convention, the message prefix should be a lower-case version of the Step's type, plus a period (e.g.,task.anddecision.).- Specified by:
getMessageKeyin interfaceStep- Returns:
- the message key for this Step.
-
getOutcome
Returns the Outcome of this Step's processing; by default,Outcome.STEP_CONTINUE.- Specified by:
getOutcomein interfaceStep- Returns:
- the outcome
-
getStartTime
The start time for this Step. ReturnsStep.TIME_NOT_SETif not started yet.- Specified by:
getStartTimein interfaceStep- Returns:
- the start time
-
isCompleted
Determines whether the Step is completed; if not, it is by definition awaiting action by the owner or in process. If a Step has completed, it must also return a non-nullresult forStep.getOutcome().- Specified by:
isCompletedin interfaceStep- Returns:
trueif the Step has completed;falseif not.
-
isStarted
Determines whether the Step has started. -
setOutcome
Sets the current Outcome for the step. If the Outcome is a "completion" Outcome, it should also sets the completon time and mark the Step as complete. Once a Step has been marked complete, this method cannot be called again. If the supplied Outcome is not in the set returned byStep.getAvailableOutcomes(), or is notOutcome.STEP_CONTINUEorOutcome.STEP_ABORT, this method returns an IllegalArgumentException. If the caller attempts to set an Outcome and the Step has already completed, this method throws an IllegalStateException.- Specified by:
setOutcomein interfaceStep- Parameters:
outcome- whether the step should be considered completed
-
start
Starts the Step, and sets the start time to the moment when this method is first invoked. If this Step has already been started, this method throws an IllegalStateException. If the Step cannot be started because the underlying implementation encounters an error, it the implementation should throw a WikiException.- Specified by:
startin interfaceStep- Throws:
WikiException- if the step encounters errors while starting
-
getSuccessor
Identifies the next Step for a particular Outcome; if there is no next Step for this Outcome, this method returnsnull.- Specified by:
getSuccessorin interfaceStep- Parameters:
outcome- the outcome- Returns:
- the next step
-
setWorkflow
method that sets the parent Workflow id and context post-construction.- Specified by:
setWorkflowin interfaceStep- Parameters:
workflowId- the parent workflow id to setworkflowContext- the parent workflow context to set
-
getWorkflowId
-
getWorkflowContext
-
addError
Protected helper method that adds a String representing an error message to the Step's cached errors list.- Parameters:
message- the error message
-