com.atlassian.jira.workflow
Class SimpleWorkflowManager

java.lang.Object
  extended by com.atlassian.jira.workflow.SimpleWorkflowManager
All Implemented Interfaces:
WorkflowManager
Direct Known Subclasses:
OSWorkflowManager

public class SimpleWorkflowManager
extends Object
implements WorkflowManager


Constructor Summary
SimpleWorkflowManager()
           
SimpleWorkflowManager(com.opensymphony.workflow.config.Configuration configuration)
           
 
Method Summary
 void copyAndDeleteDraftWorkflows(User user, Set workflows)
          Provided a set of workflows, this method will check, if the passed in workflows have any draft workflows linked to them.
 JiraWorkflow copyWorkflow(String username, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone)
          Clones a workflow by creating a deep copy of the workflow provided.
 JiraWorkflow createDraftWorkflow(String username, String parentWorkflowName)
          This will create an draft workflow of the named active workflow.
 org.ofbiz.core.entity.GenericValue createIssue(String remoteUserName, Map<String,Object> fields)
          Create an issue in the database.
 void createWorkflow(String username, JiraWorkflow workflow)
           
 void createWorkflow(User user, JiraWorkflow workflow)
           
 boolean deleteDraftWorkflow(String parentWorkflowName)
          Deletes all draft workflows (there should every be only one) for a given parent workflow.
 void deleteWorkflow(JiraWorkflow workflow)
           
 void doWorkflowAction(WorkflowProgressAware from)
           
 com.opensymphony.workflow.loader.ActionDescriptor getActionDescriptor(WorkflowProgressAware workflowProgressAware)
           
 Collection getActiveWorkflows()
          Retrieve all currently active workflows.
protected  com.opensymphony.workflow.config.Configuration getConfiguration()
           
 JiraWorkflow getDefaultWorkflow()
           
 JiraWorkflow getDraftWorkflow(String parentWorkflowName)
          Retrieve a single draft workflow by name.
 Map getPostFunctionsForWorkflow(JiraWorkflow workflow)
          Retrieve a map: actions -> post functions.
 User getRemoteUser(Map transientVars)
           
 String getStepId(long actionDescriptorId, String workflowName)
          Gets the first stepId for the given action and workflow name.
 com.opensymphony.workflow.spi.WorkflowStore getStore()
          This is used for unit testing so we can return our own 'mock store' instead of the static StoreFactory.getPersistence(ctx);

Also used in the migrateIssueToWorkflow method.

 JiraWorkflow getWorkflow(org.ofbiz.core.entity.GenericValue issue)
          Retrieve the workflow for a given issue.
 JiraWorkflow getWorkflow(Issue issue)
          Retrieve the workflow for a given issue.
 JiraWorkflow getWorkflow(Long projectId, String issueTypeId)
          Retrieve the workflow for a given project - issue type pair.
 JiraWorkflow getWorkflow(String name)
          Retrieve a single workflow by name.
 JiraWorkflow getWorkflowClone(String name)
          This method returns a JiraWorkflow, that contains a WorkflowDescriptor that is mutable.
 JiraWorkflow getWorkflowFromScheme(org.ofbiz.core.entity.GenericValue scheme, String issueTypeId)
          Return the workflow in a particular scheme for a given issue type.
 Collection getWorkflows()
          Retrieve all of the workflows in the system
 Collection getWorkflowsFromScheme(org.ofbiz.core.entity.GenericValue workflowScheme)
          Returns all workflows for a given scheme
 boolean isActive(JiraWorkflow workflow)
          Determine whether or not a given workflow is active in the system.
 boolean isEditable(Issue issue)
           
 boolean isSystemWorkflow(JiraWorkflow workflow)
          Determine whether or not a given workflow is a system workflow.
 com.opensymphony.workflow.Workflow makeWorkflow(String userName)
           
 void migrateIssueToWorkflow(org.ofbiz.core.entity.GenericValue issue, JiraWorkflow newWorkflow, org.ofbiz.core.entity.GenericValue status)
           
 void migrateIssueToWorkflow(MutableIssue issue, JiraWorkflow newWorkflow, Status status)
          Migrates given issue to new workflow and sets new status on it.
 void overwriteActiveWorkflow(String username, String parentWorkflowName)
          Saves the draft workflow into the active workflow.
 void removeWorkflowEntries(org.ofbiz.core.entity.GenericValue issue)
           
protected  void resetConfiguration()
           
 void saveWorkflowWithoutAudit(JiraWorkflow workflow)
          This method will save the workflow and it will not affect the updatedDate and updatedAuthorName meta attributes of the workflow.
 void updateWorkflow(String username, JiraWorkflow workflow)
          Saves the given JiraWorkflow, which may be either a "live" or "draft" version.
 void updateWorkflowNameAndDescription(String username, JiraWorkflow currentWorkflow, String newName, String newDescription)
          Used to change the name and description of an existing worfklow with the given name.
 boolean workflowExists(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleWorkflowManager

public SimpleWorkflowManager()

SimpleWorkflowManager

public SimpleWorkflowManager(com.opensymphony.workflow.config.Configuration configuration)
Method Detail

resetConfiguration

protected void resetConfiguration()

getWorkflows

public Collection getWorkflows()
Description copied from interface: WorkflowManager
Retrieve all of the workflows in the system

Specified by:
getWorkflows in interface WorkflowManager
Returns:
A Collection of JiraWorkflow objects.

isActive

public boolean isActive(JiraWorkflow workflow)
                 throws WorkflowException
Description copied from interface: WorkflowManager
Determine whether or not a given workflow is active in the system.

Active workflows are those currently assigned to schemes and associated with projects - they cannot be edited but can be used.

Specified by:
isActive in interface WorkflowManager
Throws:
WorkflowException

isSystemWorkflow

public boolean isSystemWorkflow(JiraWorkflow workflow)
                         throws WorkflowException
Description copied from interface: WorkflowManager
Determine whether or not a given workflow is a system workflow.

Specified by:
isSystemWorkflow in interface WorkflowManager
Throws:
WorkflowException

getActiveWorkflows

public Collection getActiveWorkflows()
                              throws WorkflowException
Description copied from interface: WorkflowManager
Retrieve all currently active workflows.

Specified by:
getActiveWorkflows in interface WorkflowManager
Returns:
Collection of JiraWorkflow objects.
Throws:
WorkflowException

getDefaultWorkflow

public JiraWorkflow getDefaultWorkflow()
                                throws WorkflowException
Specified by:
getDefaultWorkflow in interface WorkflowManager
Throws:
WorkflowException

getWorkflow

public JiraWorkflow getWorkflow(String name)
Description copied from interface: WorkflowManager
Retrieve a single workflow by name. The returned JiraWorkflow contains a descriptor that by default isn't mutable (see ImmutableWorkflowDescriptor

If you need to edit a workflow, please see WorkflowManager.getWorkflowClone(String).

Specified by:
getWorkflow in interface WorkflowManager
Parameters:
name - The workflow name
Returns:
A JiraWorkflow that wraps an ImmutableWorkflowDescriptor or null
See Also:
WorkflowManager.getWorkflowClone(String)

getWorkflowClone

public JiraWorkflow getWorkflowClone(String name)
Description copied from interface: WorkflowManager
This method returns a JiraWorkflow, that contains a WorkflowDescriptor that is mutable. This method should be called, if you require to edit the workflow.

If you only need to view a workflow, please use WorkflowManager.getWorkflow(String) as it will provide better performance. Cloning a workflow is expensive, as it requires de-constructing and re-constructing the underlying WorkflowDescriptor from XML.

Specified by:
getWorkflowClone in interface WorkflowManager
Parameters:
name - The workflow name
Returns:
A JiraWorkflow or null if it doesn't exist.
See Also:
WorkflowManager.getWorkflow(String)

getWorkflow

public JiraWorkflow getWorkflow(org.ofbiz.core.entity.GenericValue issue)
                         throws WorkflowException
Description copied from interface: WorkflowManager
Retrieve the workflow for a given issue.

Specified by:
getWorkflow in interface WorkflowManager
Throws:
WorkflowException

getWorkflow

public JiraWorkflow getWorkflow(Issue issue)
                         throws WorkflowException
Description copied from interface: WorkflowManager
Retrieve the workflow for a given issue.

Specified by:
getWorkflow in interface WorkflowManager
Throws:
WorkflowException

getWorkflow

public JiraWorkflow getWorkflow(Long projectId,
                                String issueTypeId)
                         throws WorkflowException
Description copied from interface: WorkflowManager
Retrieve the workflow for a given project - issue type pair.

Specified by:
getWorkflow in interface WorkflowManager
Throws:
WorkflowException

getWorkflowFromScheme

public JiraWorkflow getWorkflowFromScheme(org.ofbiz.core.entity.GenericValue scheme,
                                          String issueTypeId)
                                   throws WorkflowException
Description copied from interface: WorkflowManager
Return the workflow in a particular scheme for a given issue type.

Specified by:
getWorkflowFromScheme in interface WorkflowManager
Throws:
WorkflowException

getWorkflowsFromScheme

public Collection getWorkflowsFromScheme(org.ofbiz.core.entity.GenericValue workflowScheme)
                                  throws WorkflowException
Description copied from interface: WorkflowManager
Returns all workflows for a given scheme

Specified by:
getWorkflowsFromScheme in interface WorkflowManager
Returns:
Collection of workflow schemes, empty collection if none exists
Throws:
WorkflowException

copyAndDeleteDraftWorkflows

public void copyAndDeleteDraftWorkflows(User user,
                                        Set workflows)
Description copied from interface: WorkflowManager
Provided a set of workflows, this method will check, if the passed in workflows have any draft workflows linked to them. If they do, it will create an inactive copy of the draft workflow, and delete the draft workflow.

Specified by:
copyAndDeleteDraftWorkflows in interface WorkflowManager
Parameters:
user - The user performing the operation
workflows - A set of parent JiraWorkflows

createIssue

public org.ofbiz.core.entity.GenericValue createIssue(String remoteUserName,
                                                      Map<String,Object> fields)
                                               throws WorkflowException
Description copied from interface: WorkflowManager
Create an issue in the database.

Specified by:
createIssue in interface WorkflowManager
Parameters:
remoteUserName - Issue creator
fields - Map of fields. The key is the name of the field, and the type of the value depends on the key. Must include a key "issue", which contains MutableIssue object (holding values, not yet persisted to disk). May include other fields (eg "pkey"->String key of project, "originalissueobject"->Issue object) passed onto the workflow engine.
Returns:
The created issue GenericValue
Throws:
WorkflowException - If any errors occur while trying to create the issue.

removeWorkflowEntries

public void removeWorkflowEntries(org.ofbiz.core.entity.GenericValue issue)
                           throws org.ofbiz.core.entity.GenericEntityException
Specified by:
removeWorkflowEntries in interface WorkflowManager
Throws:
org.ofbiz.core.entity.GenericEntityException

doWorkflowAction

public void doWorkflowAction(WorkflowProgressAware from)
Specified by:
doWorkflowAction in interface WorkflowManager

getRemoteUser

public User getRemoteUser(Map transientVars)
                   throws EntityNotFoundException
Specified by:
getRemoteUser in interface WorkflowManager
Throws:
EntityNotFoundException

getStore

public com.opensymphony.workflow.spi.WorkflowStore getStore()
                                                     throws com.opensymphony.workflow.StoreException
This is used for unit testing so we can return our own 'mock store' instead of the static StoreFactory.getPersistence(ctx);

Also used in the migrateIssueToWorkflow method.

Specified by:
getStore in interface WorkflowManager
Throws:
com.opensymphony.workflow.StoreException

createWorkflow

public void createWorkflow(String username,
                           JiraWorkflow workflow)
                    throws WorkflowException
Specified by:
createWorkflow in interface WorkflowManager
Throws:
WorkflowException

createWorkflow

public void createWorkflow(User user,
                           JiraWorkflow workflow)
                    throws WorkflowException
Specified by:
createWorkflow in interface WorkflowManager
Throws:
WorkflowException

saveWorkflowWithoutAudit

public void saveWorkflowWithoutAudit(JiraWorkflow workflow)
                              throws WorkflowException
Description copied from interface: WorkflowManager
This method will save the workflow and it will not affect the updatedDate and updatedAuthorName meta attributes of the workflow. This should only ever be invoked by system operations such as upgrade tasks. All other saves should use the method WorkflowManager.updateWorkflow(String, JiraWorkflow)

Specified by:
saveWorkflowWithoutAudit in interface WorkflowManager
Parameters:
workflow - the workflow to save.
Throws:
WorkflowException

deleteWorkflow

public void deleteWorkflow(JiraWorkflow workflow)
                    throws WorkflowException
Specified by:
deleteWorkflow in interface WorkflowManager
Throws:
WorkflowException

getActionDescriptor

public com.opensymphony.workflow.loader.ActionDescriptor getActionDescriptor(WorkflowProgressAware workflowProgressAware)
                                                                      throws Exception
Specified by:
getActionDescriptor in interface WorkflowManager
Throws:
Exception

migrateIssueToWorkflow

public void migrateIssueToWorkflow(org.ofbiz.core.entity.GenericValue issue,
                                   JiraWorkflow newWorkflow,
                                   org.ofbiz.core.entity.GenericValue status)
                            throws WorkflowException
Specified by:
migrateIssueToWorkflow in interface WorkflowManager
Throws:
WorkflowException

getDraftWorkflow

public JiraWorkflow getDraftWorkflow(String parentWorkflowName)
Description copied from interface: WorkflowManager
Retrieve a single draft workflow by name. If there is not an draft workflow associated with the name this will return null.

Specified by:
getDraftWorkflow in interface WorkflowManager
Parameters:
parentWorkflowName - is the name of the Saved workflow which identifies then paritally edited draft workflow to retrieve.
Returns:
a JiraWorkflow that represents an draft edited workflow. This is an instance of JiraDraftWorkflow.

createDraftWorkflow

public JiraWorkflow createDraftWorkflow(String username,
                                        String parentWorkflowName)
                                 throws WorkflowException
Description copied from interface: WorkflowManager
This will create an draft workflow of the named active workflow. This draft workflow can be used to edit active workflows without overwriting the active workflow immediately.
This method will not allow you to create an draft workflow if the parent workflow is not active, the method will throw an IllegalStateException in this case.

Specified by:
createDraftWorkflow in interface WorkflowManager
Parameters:
username - identifies the user performing the action so that we can keep an audit trail of who has last saved the workflow. Empty string for anonymous user. If null an IllegalArgumentException will be thrown
parentWorkflowName - identifies the parent workflow that should be used as the template for creating the draft workflow.
Returns:
An instance of JiraDraftWorkflow that represents a copy of the parent that can be edited without overwriting the active workflow immediately.
Throws:
WorkflowException

deleteDraftWorkflow

public boolean deleteDraftWorkflow(String parentWorkflowName)
                            throws WorkflowException
Description copied from interface: WorkflowManager
Deletes all draft workflows (there should every be only one) for a given parent workflow.

Specified by:
deleteDraftWorkflow in interface WorkflowManager
Parameters:
parentWorkflowName - The parentworkflow for which the draft workflow needs to be deleted.
Returns:
true if a draft workflow as deleted, false otherwise.
Throws:
WorkflowException

migrateIssueToWorkflow

public void migrateIssueToWorkflow(MutableIssue issue,
                                   JiraWorkflow newWorkflow,
                                   Status status)
                            throws WorkflowException
Migrates given issue to new workflow and sets new status on it.

Specified by:
migrateIssueToWorkflow in interface WorkflowManager
Parameters:
issue - issue to migrate
newWorkflow - new workflow
status - new status
Throws:
WorkflowException - if migration fails

makeWorkflow

public com.opensymphony.workflow.Workflow makeWorkflow(String userName)
Specified by:
makeWorkflow in interface WorkflowManager

workflowExists

public boolean workflowExists(String name)
                       throws WorkflowException
Specified by:
workflowExists in interface WorkflowManager
Throws:
WorkflowException

isEditable

public boolean isEditable(Issue issue)
Specified by:
isEditable in interface WorkflowManager

getConfiguration

protected com.opensymphony.workflow.config.Configuration getConfiguration()

getPostFunctionsForWorkflow

public Map getPostFunctionsForWorkflow(JiraWorkflow workflow)
Retrieve a map: actions -> post functions.

Specified by:
getPostFunctionsForWorkflow in interface WorkflowManager
Parameters:
workflow -
Returns:
Map actions-> post functions

getStepId

public String getStepId(long actionDescriptorId,
                        String workflowName)
Description copied from interface: WorkflowManager
Gets the first stepId for the given action and workflow name.

Specified by:
getStepId in interface WorkflowManager
Parameters:
actionDescriptorId - id of the ActionDescriptor
workflowName - name of the JiraWorkflow

overwriteActiveWorkflow

public void overwriteActiveWorkflow(String username,
                                    String parentWorkflowName)
Description copied from interface: WorkflowManager
Saves the draft workflow into the active workflow.

Specified by:
overwriteActiveWorkflow in interface WorkflowManager
Parameters:
username - User will be added to the workflows Audit trail
parentWorkflowName - The workflow to be overwritten

updateWorkflow

public void updateWorkflow(String username,
                           JiraWorkflow workflow)
Description copied from interface: WorkflowManager
Saves the given JiraWorkflow, which may be either a "live" or "draft" version. This method does not save the changes to the active workflow. Instead, this is meant to be used to make persistent changes to your working edit. Once all changes have been made you can over write the active workflow by calling WorkflowManager.overwriteActiveWorkflow(String, String)

Specified by:
updateWorkflow in interface WorkflowManager
Parameters:
username - User making the request.
workflow - The JiraWorkflow to save.

copyWorkflow

public JiraWorkflow copyWorkflow(String username,
                                 String clonedWorkflowName,
                                 String clonedWorkflowDescription,
                                 JiraWorkflow workflowToClone)
Description copied from interface: WorkflowManager
Clones a workflow by creating a deep copy of the workflow provided.

Specified by:
copyWorkflow in interface WorkflowManager
Parameters:
username - The user performing the operation
clonedWorkflowName - The name to store the new workflow with.
clonedWorkflowDescription - The description to store with the cloned workflow. Can be null.
workflowToClone - The workflow to copy.
Returns:
A cloned copy of the original workflow.

updateWorkflowNameAndDescription

public void updateWorkflowNameAndDescription(String username,
                                             JiraWorkflow currentWorkflow,
                                             String newName,
                                             String newDescription)
Description copied from interface: WorkflowManager
Used to change the name and description of an existing worfklow with the given name.

Specified by:
updateWorkflowNameAndDescription in interface WorkflowManager
Parameters:
username - The user performing the operation
currentWorkflow - The workflow to update.
newName - The new name to save with the workflow
newDescription - The new descriptio to save with the workflow


Copyright © 2002-2009 Atlassian. All Rights Reserved.