# com.beasys.commerce.foundation
Workflow Interface

public interface Workflow
extends `BusinessSmartComponent`

A Business Smart Component (BSC) Workflow provides access to a remote instance of a BSC Workflow Implementation. A workflow defines an abstract interface to an object that implements a set of states and legal transitions between those states. This is a powerful metaphor that represents a variety of decision support structures. An implementation of a Workflow is the StateMachine class in The Theory Center's Axiom package. The Theory Center's SmartGenerator generates a workflow based on that StateMachine, directly from a State Diagram

Related Topics

``StateMachine``

All Known Implementing Classes
  `PaymentWorkflow`, `StateMachine`

All Superinterfaces
  `BusinessSmartComponent`, `Serializable`

## Method Summary

`public `String`` | `doTransition`(`String` transitionName) Atempt to execute the specified transition and return the resulting state.
`public `WorkflowContext`` | `getContext`() This method returns a Workflow context that can be used to later restore a Workflow.
`public `String`` | `getCurrentStateName`() Get the name of the current state
`public `String`` | `getInitialStateName`() Get the name of the initial state
`public `String`[]` | `getOutgoingTransitions`(`String` state) Get all transition names with the start state passed in.
`public `String`[]` | `getStateNames`() Get all State names in an array of Strings.
`public `String`[]` | `getTransitionNames`() Get all transition names in an array of Strings.
`public `String`` | `lookAheadTransition`(`String` transition) Given the name of the transition, look ahead the transition and return the predicted new state.
`public void` | `reset`() Reset the current workflow state to the initial state
`public void` | `setContext`(`WorkflowContext` workflowContext) Set the new context for the underlying workflow engine.

## Method Detail

### doTransition(String) Method

    public String doTransition(String transitionName)
         throws IllegalWorkflowTransitionException

Atempt to execute the specified transition and return the resulting state. If the specified transition is not allowed by the Workflow specification an InvalidWorkflowTransitionException will be thrown.

#### Parameters

transitionName
  the name of the transition to be performed

#### Returns

new state.

#### Exceptions

``IllegalWorkflowTransitionException``
  if the transition is invalid

### getContext() Method

    public WorkflowContext getContext()

This method returns a Workflow context that can be used to later restore a Workflow. WorkflowContext is serializable and thus the WorkflowContext is the mechanism by which a Workflow is persisted. This method should be used only by the classes that implement the Workflow interface.

#### Returns

WorkflowContext

### getCurrentStateName() Method

    public String getCurrentStateName()

Get the name of the current state

#### Returns

current state name

### getInitialStateName() Method

    public String getInitialStateName()

Get the name of the initial state

#### Returns

initial state name

### getOutgoingTransitions(String) Method

    public String[] getOutgoingTransitions(String state)
         throws IllegalWorkflowTransitionException

Get all transition names with the start state passed in.

#### Returns

String[] an array of Strings

#### Exceptions

``IllegalWorkflowTransitionException``

### getStateNames() Method

    public String[] getStateNames()

Get all State names in an array of Strings.

#### Returns

String[] an array of Strings

### getTransitionNames() Method

    public String[] getTransitionNames()

Get all transition names in an array of Strings.

#### Returns

String[] an array of Strings

### lookAheadTransition(String) Method

    public String lookAheadTransition(String transition)
         throws IllegalWorkflowTransitionException

Given the name of the transition, look ahead the transition and return the predicted new state. If transition is invalid for the current state of the state machine, throw IllegalWorkflowTransitionException.

#### Parameters

transition
  the name of the transition to be performed

#### Returns

predicted new state.

#### Exceptions

``IllegalWorkflowTransitionException``
  if the transition is invalid

### reset() Method

    public void reset()

Reset the current workflow state to the initial state

### setContext(WorkflowContext) Method

    public void setContext(WorkflowContext workflowContext)

Set the new context for the underlying workflow engine. This method should be used only by the classes that implement the Workflow interface.

#### Parameters

workflowContext
  the new context for the underlying workflow engine.