Package org.compiere.process
Class StateEngine
- java.lang.Object
-
- org.compiere.process.StateEngine
-
public class StateEngine extends Object
Process State Engine. Based on OMG Workflow State- Version:
- $Id: StateEngine.java,v 1.3 2006/07/30 00:54:44 jjanke Exp $
- Author:
- Jorg Janke
-
-
Field Summary
Fields Modifier and Type Field Description static StringACTION_AbortAbortstatic StringACTION_CompleteCompletestatic StringACTION_ResumeResumestatic StringACTION_StartStartstatic StringACTION_SuspendSuspendstatic StringACTION_TerminateTerminateprotected CLoggerlogLoggerstatic StringSTATE_AbortedClosed - Aborted - Environment/Setup Errorstatic StringSTATE_CompletedClosed - Completed - normal exitstatic StringSTATE_NotStartedOpen - Not Startedstatic StringSTATE_RunningOpen - Runningstatic StringSTATE_SuspendedOpen - Suspendedstatic StringSTATE_TerminatedClosed - Teminated - Execution Error
-
Constructor Summary
Constructors Constructor Description StateEngine()Default Constructor (not started)StateEngine(String startState)Initialized Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanabort()Abort: open -> abortedbooleancomplete()Complete: running -> completedString[]getActionOptions()Get Action Options based on current StateStringgetNewStateIfAction(String action)Get New State If Action performedString[]getNewStateOptions()Get New State Options based on current StateStringgetState()Get StateStringgetStateInfo()Get clear text State Info.booleanisAborted()State is Aborted (Environment/Setup issue)booleanisClosed()State is ClosedbooleanisCompleted()State is CompletedbooleanisNotRunning()State is Not RunningbooleanisNotStarted()State is Not StartedbooleanisOpen()State is OpenbooleanisRunning()State is RunningbooleanisSuspended()State is SuspendedbooleanisTerminated()State is Terminated (Execution issue)booleanisThrowException()Are Exception ThrownbooleanisValidAction(String action)Is The Action Valid based on current statebooleanisValidNewState(String newState)Is the new State valid based on current statebooleanprocess(String action)Processbooleanresume()Resume: suspended -> runningbooleansetState(String newState)Set State to new StatevoidsetThrowException(boolean throwException)Set if Exceptions are Thrown * @param throwException booleanbooleanstart()Start: not started -> runningbooleansuspend()Suspend: running -> suspendedbooleanterminate()Terminate: open -> terminatedStringtoString()String Representation
-
-
-
Field Detail
-
STATE_NotStarted
public static final String STATE_NotStarted
Open - Not Started- See Also:
- Constant Field Values
-
STATE_Running
public static final String STATE_Running
Open - Running- See Also:
- Constant Field Values
-
STATE_Suspended
public static final String STATE_Suspended
Open - Suspended- See Also:
- Constant Field Values
-
STATE_Completed
public static final String STATE_Completed
Closed - Completed - normal exit- See Also:
- Constant Field Values
-
STATE_Aborted
public static final String STATE_Aborted
Closed - Aborted - Environment/Setup Error- See Also:
- Constant Field Values
-
STATE_Terminated
public static final String STATE_Terminated
Closed - Teminated - Execution Error- See Also:
- Constant Field Values
-
ACTION_Suspend
public static final String ACTION_Suspend
Suspend- See Also:
- Constant Field Values
-
ACTION_Start
public static final String ACTION_Start
Start- See Also:
- Constant Field Values
-
ACTION_Resume
public static final String ACTION_Resume
Resume- See Also:
- Constant Field Values
-
ACTION_Complete
public static final String ACTION_Complete
Complete- See Also:
- Constant Field Values
-
ACTION_Abort
public static final String ACTION_Abort
Abort- See Also:
- Constant Field Values
-
ACTION_Terminate
public static final String ACTION_Terminate
Terminate- See Also:
- Constant Field Values
-
log
protected CLogger log
Logger
-
-
Constructor Detail
-
StateEngine
public StateEngine()
Default Constructor (not started)
-
StateEngine
public StateEngine(String startState)
Initialized Constructor- Parameters:
startState- start state
-
-
Method Detail
-
isThrowException
public boolean isThrowException()
Are Exception Thrown- Returns:
- trie if exceptions thrown
-
setThrowException
public void setThrowException(boolean throwException)
Set if Exceptions are Thrown * @param throwException boolean
-
getState
public String getState()
Get State- Returns:
- state
-
getStateInfo
public String getStateInfo()
Get clear text State Info.- Returns:
- state info
-
isOpen
public boolean isOpen()
State is Open- Returns:
- true if open (running, not started, suspended)
-
isNotRunning
public boolean isNotRunning()
State is Not Running- Returns:
- true if not running (not started, suspended)
-
isClosed
public boolean isClosed()
State is Closed- Returns:
- true if closed (completed, aborted, terminated)
-
isNotStarted
public boolean isNotStarted()
State is Not Started- Returns:
- true if Not Started
-
isRunning
public boolean isRunning()
State is Running- Returns:
- true if Running
-
isSuspended
public boolean isSuspended()
State is Suspended- Returns:
- true if Suspended
-
isCompleted
public boolean isCompleted()
State is Completed- Returns:
- true if Completed
-
isAborted
public boolean isAborted()
State is Aborted (Environment/Setup issue)- Returns:
- true if Aborted
-
isTerminated
public boolean isTerminated()
State is Terminated (Execution issue)- Returns:
- true if Terminated
-
start
public boolean start()
Start: not started -> running- Returns:
- true if set to running
-
resume
public boolean resume()
Resume: suspended -> running- Returns:
- true if set to sunning
-
suspend
public boolean suspend()
Suspend: running -> suspended- Returns:
- true if suspended
-
complete
public boolean complete()
Complete: running -> completed- Returns:
- true if set to completed
-
abort
public boolean abort()
Abort: open -> aborted- Returns:
- true if set to aborted
-
terminate
public boolean terminate()
Terminate: open -> terminated- Returns:
- true if set to terminated
-
getNewStateOptions
public String[] getNewStateOptions()
Get New State Options based on current State- Returns:
- array of new states
-
isValidNewState
public boolean isValidNewState(String newState)
Is the new State valid based on current state- Parameters:
newState- new state- Returns:
- true valid new state
-
setState
public boolean setState(String newState)
Set State to new State- Parameters:
newState- new state- Returns:
- true if set to new state
-
getActionOptions
public String[] getActionOptions()
Get Action Options based on current State- Returns:
- array of actions
-
isValidAction
public boolean isValidAction(String action)
Is The Action Valid based on current state- Parameters:
action- action- Returns:
- true if valid
-
process
public boolean process(String action)
Process- Parameters:
action- action- Returns:
- true if set to new state
-
getNewStateIfAction
public String getNewStateIfAction(String action)
Get New State If Action performed- Parameters:
action- action- Returns:
- potential new state
-
-