org.apache.lenya.workflow.impl
Class History

java.lang.Object
  extended by org.apache.lenya.workflow.impl.History
All Implemented Interfaces:
WorkflowListener
Direct Known Subclasses:
CMSHistory

public abstract class History
extends java.lang.Object
implements WorkflowListener

The history of a workflow instance contains a list of all versions of the instance. A version contains


Field Summary
static java.lang.String DATE_ATTRIBUTE
           
static java.lang.String EVENT_ATTRIBUTE
           
static java.lang.String HISTORY_ELEMENT
           
static java.lang.String NAME_ATTRIBUTE
           
static java.lang.String STATE_ATTRIBUTE
           
static java.lang.String VALUE_ATTRIBUTE
           
static java.lang.String VARIABLE_ELEMENT
           
static java.lang.String VERSION_ELEMENT
           
static java.lang.String WORKFLOW_ATTRIBUTE
           
 
Constructor Summary
protected History()
          Creates a new history object for a workflow instance.
 
Method Summary
protected  org.w3c.dom.Element createInitialVersionElement(NamespaceHelper helper, Situation situation, java.lang.String workflowId)
          Creates a new version element.
protected abstract  WorkflowInstanceImpl createInstance()
          Factory method to create a workflow instance object.
protected  org.w3c.dom.Element createVersionElement(NamespaceHelper helper, Situation situation)
          Creates a version element based on a situation.
protected  org.w3c.dom.Element createVersionElement(NamespaceHelper helper, StateImpl state, Situation situation, Event event)
          Creates a new version element.
 void delete()
          Deletes the history.
protected abstract  java.io.File getHistoryFile()
          Factory method to obtain the history file.
 WorkflowInstanceImpl getInstance()
          Restores the workflow, state and variables of a workflow instance from this history.
protected  NamespaceHelper getNamespaceHelper()
          Returns the namespace helper for the history file.
 Version[] getVersions()
          Returns the versions of this history.
protected  java.lang.String getWorkflowId()
          Returns the workflow ID for this history.
protected  java.lang.String getWorkflowId(NamespaceHelper helper)
          Returns the workflow ID for this history.
 void initialize(java.lang.String workflowId, Situation situation)
          Creates a new history object.
 boolean isInitialized()
          Returns if the history has been initialized.
protected  void move(java.io.File newFile)
          Moves this history to a new file.
protected  void restoreState(WorkflowInstanceImpl instance, NamespaceHelper helper)
          Restores the state of a workflow instance.
protected  void restoreVariables(WorkflowInstanceImpl instance, NamespaceHelper helper)
          Restores the state variables of a workflow instance.
protected  Version restoreVersion(NamespaceHelper helper, org.w3c.dom.Element element)
          Restores a version from an XML element.
protected  void saveVariables(NamespaceHelper helper)
          Saves the state variables as children of the document element.
 void setInstance(WorkflowInstanceImpl impl)
          Sets the workflow instance.
 void transitionFired(WorkflowInstance instance, Situation situation, Event event)
          Advances the workflow history when a tranistion was invoked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORKFLOW_ATTRIBUTE

public static final java.lang.String WORKFLOW_ATTRIBUTE
See Also:
Constant Field Values

HISTORY_ELEMENT

public static final java.lang.String HISTORY_ELEMENT
See Also:
Constant Field Values

VERSION_ELEMENT

public static final java.lang.String VERSION_ELEMENT
See Also:
Constant Field Values

STATE_ATTRIBUTE

public static final java.lang.String STATE_ATTRIBUTE
See Also:
Constant Field Values

EVENT_ATTRIBUTE

public static final java.lang.String EVENT_ATTRIBUTE
See Also:
Constant Field Values

VARIABLE_ELEMENT

public static final java.lang.String VARIABLE_ELEMENT
See Also:
Constant Field Values

NAME_ATTRIBUTE

public static final java.lang.String NAME_ATTRIBUTE
See Also:
Constant Field Values

VALUE_ATTRIBUTE

public static final java.lang.String VALUE_ATTRIBUTE
See Also:
Constant Field Values

DATE_ATTRIBUTE

public static final java.lang.String DATE_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

History

protected History()
Creates a new history object for a workflow instance.

Method Detail

initialize

public void initialize(java.lang.String workflowId,
                       Situation situation)
                throws WorkflowException
Creates a new history object. A new history file is created and initialized.

Parameters:
workflowId - The workflow ID.
situation - The current situation.
Throws:
WorkflowException - when something went wrong.

getNamespaceHelper

protected NamespaceHelper getNamespaceHelper()
                                      throws WorkflowException
Returns the namespace helper for the history file.

Returns:
A namespace helper.
Throws:
WorkflowException - It the helper could not be obtained.

getWorkflowId

protected java.lang.String getWorkflowId()
                                  throws WorkflowException
Returns the workflow ID for this history.

Returns:
A string.
Throws:
WorkflowException - when something went wrong.

getWorkflowId

protected java.lang.String getWorkflowId(NamespaceHelper helper)
                                  throws WorkflowException
Returns the workflow ID for this history.

Parameters:
helper - The namespace helper for the history document.
Returns:
A string.
Throws:
WorkflowException - when something went wrong.

getInstance

public WorkflowInstanceImpl getInstance()
                                 throws WorkflowException
Restores the workflow, state and variables of a workflow instance from this history.

Returns:
The workflow instance to restore.
Throws:
WorkflowException - if something goes wrong.

isInitialized

public boolean isInitialized()
Returns if the history has been initialized.

Returns:
A boolean value.

getHistoryFile

protected abstract java.io.File getHistoryFile()
Factory method to obtain the history file.

Returns:
A file.

createInstance

protected abstract WorkflowInstanceImpl createInstance()
                                                throws WorkflowException
Factory method to create a workflow instance object.

Returns:
A workflow instance object.
Throws:
WorkflowException - if something goes wrong.

createInitialVersionElement

protected org.w3c.dom.Element createInitialVersionElement(NamespaceHelper helper,
                                                          Situation situation,
                                                          java.lang.String workflowId)
                                                   throws WorkflowException
Creates a new version element. This method is called after a tansition invocation.

Parameters:
helper - The namespace helper of the history document.
situation - The current situation.
workflowId - The workflow ID.
Returns:
An XML element.
Throws:
WorkflowException - when something went wrong.

createVersionElement

protected org.w3c.dom.Element createVersionElement(NamespaceHelper helper,
                                                   StateImpl state,
                                                   Situation situation,
                                                   Event event)
Creates a new version element. This method is called after a tansition invocation.

Parameters:
helper - The namespace helper of the history document.
state - The state of the new version.
situation - The current situation.
event - The event that was invoked.
Returns:
An XML element.

createVersionElement

protected org.w3c.dom.Element createVersionElement(NamespaceHelper helper,
                                                   Situation situation)
Creates a version element based on a situation.

Parameters:
helper - The namespace helper of the history document.
situation - The current situation.
Returns:
An XML element.

transitionFired

public void transitionFired(WorkflowInstance instance,
                            Situation situation,
                            Event event)
                     throws WorkflowException
Advances the workflow history when a tranistion was invoked.

Specified by:
transitionFired in interface WorkflowListener
Parameters:
instance - The workflow instance.
situation - The situation before the transition.
event - The invoked event.
Throws:
WorkflowException - when something went wrong.

setInstance

public void setInstance(WorkflowInstanceImpl impl)
Sets the workflow instance.

Parameters:
impl - A workflow instance implementation.

saveVariables

protected void saveVariables(NamespaceHelper helper)
                      throws WorkflowException
Saves the state variables as children of the document element.

Parameters:
helper - The helper that holds the document.
Throws:
WorkflowException - when something went wrong.

restoreVariables

protected void restoreVariables(WorkflowInstanceImpl instance,
                                NamespaceHelper helper)
                         throws WorkflowException
Restores the state variables of a workflow instance.

Parameters:
instance - The instance to restore.
helper - The helper that wraps the history document.
Throws:
WorkflowException - when something went wrong.

restoreState

protected void restoreState(WorkflowInstanceImpl instance,
                            NamespaceHelper helper)
                     throws WorkflowException
Restores the state of a workflow instance.

Parameters:
instance - The instance to restore.
helper - The helper that wraps the history document.
Throws:
WorkflowException - when something went wrong.

move

protected void move(java.io.File newFile)
             throws WorkflowException
Moves this history to a new file.

Parameters:
newFile - The new file.
Throws:
WorkflowException - when something went wrong.

restoreVersion

protected Version restoreVersion(NamespaceHelper helper,
                                 org.w3c.dom.Element element)
                          throws WorkflowException
Restores a version from an XML element.

Parameters:
helper - The namespace helper.
element - An XML element.
Returns:
A version.
Throws:
WorkflowException - when something went wrong.

getVersions

public Version[] getVersions()
                      throws WorkflowException
Returns the versions of this history.

Returns:
An array of versions.
Throws:
WorkflowException - when something went wrong.

delete

public void delete()
            throws WorkflowException
Deletes the history.

Throws:
WorkflowException - when something went wrong.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.