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 String
ACTION_Abort
Abortstatic String
ACTION_Complete
Completestatic String
ACTION_Resume
Resumestatic String
ACTION_Start
Startstatic String
ACTION_Suspend
Suspendstatic String
ACTION_Terminate
Terminateprotected CLogger
log
Loggerstatic String
STATE_Aborted
Closed - Aborted - Environment/Setup Errorstatic String
STATE_Completed
Closed - Completed - normal exitstatic String
STATE_NotStarted
Open - Not Startedstatic String
STATE_Running
Open - Runningstatic String
STATE_Suspended
Open - Suspendedstatic String
STATE_Terminated
Closed - 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 boolean
abort()
Abort: open -> abortedboolean
complete()
Complete: running -> completedString[]
getActionOptions()
Get Action Options based on current StateString
getNewStateIfAction(String action)
Get New State If Action performedString[]
getNewStateOptions()
Get New State Options based on current StateString
getState()
Get StateString
getStateInfo()
Get clear text State Info.boolean
isAborted()
State is Aborted (Environment/Setup issue)boolean
isClosed()
State is Closedboolean
isCompleted()
State is Completedboolean
isNotRunning()
State is Not Runningboolean
isNotStarted()
State is Not Startedboolean
isOpen()
State is Openboolean
isRunning()
State is Runningboolean
isSuspended()
State is Suspendedboolean
isTerminated()
State is Terminated (Execution issue)boolean
isThrowException()
Are Exception Thrownboolean
isValidAction(String action)
Is The Action Valid based on current stateboolean
isValidNewState(String newState)
Is the new State valid based on current stateboolean
process(String action)
Processboolean
resume()
Resume: suspended -> runningboolean
setState(String newState)
Set State to new Statevoid
setThrowException(boolean throwException)
Set if Exceptions are Thrown * @param throwException booleanboolean
start()
Start: not started -> runningboolean
suspend()
Suspend: running -> suspendedboolean
terminate()
Terminate: open -> terminatedString
toString()
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
-
-