com.atlassian.jira.bc.workflow
Interface WorkflowService

All Known Implementing Classes:
DefaultWorkflowService

@PublicApi
public interface WorkflowService

This class is responsible for validation before passing the actual call to the underlying WorkflowManager.

Since:
v3.13

Method Summary
 JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone)
          Clones and persists a new workflow with the name given.
 JiraWorkflow createDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
          Creates a copy of an active workflow for editing.
 boolean deleteDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
          Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.
 ServiceOutcome<Void> deleteWorkflow(ApplicationUser deletingUser, String workflowName)
          Deletes the workflow which has the passed name.
 JiraWorkflow getDraftWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
          Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.
 JiraWorkflow getWorkflow(JiraServiceContext jiraServiceContext, String name)
          Returns the workflow with the given name.
 boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow, int stepId)
          Given a draft workflow and a step Id, this method returns true, if the step does not have any transitions on the original workflow.
 void overwriteActiveWorkflow(JiraServiceContext jiraServiceContext, String parentWorkflowName)
          This method will overwrite the parentWorkflow with a draft Workflow if it exists.
 void updateWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow)
          Updates the workflow descriptor provided in the persistance mechanism implemented.
 void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newName, String newDescription)
          Used to change the name and description of an existing worfklow with the given name.
 void validateAddWorkflowTransitionToDraft(JiraServiceContext jiraServiceContext, JiraWorkflow newJiraworkflow, int stepId)
          Validates if a workflow transition can be added to a draft.
 void validateCopyWorkflow(JiraServiceContext jiraServiceContext, String newWorkflowName)
          Validates if a workflow can be cloned and saved with the provided name.
 void validateOverwriteWorkflow(JiraServiceContext jiraServiceContext, String workflowName)
          Validates that the draft workflow with the given name is allowed to be saved into the corresponding active workflow.
 void validateUpdateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newWorkflowName)
          Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.
 

Method Detail

getDraftWorkflow

JiraWorkflow getDraftWorkflow(JiraServiceContext jiraServiceContext,
                              String parentWorkflowName)
Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.
If the parentWorkflow doesn't exist, this method returns null and will log an error in the servicecontext errorcollection. If no DraftWorkflow exists, then this method will simply return null.

Parameters:
jiraServiceContext - service context with user and error collection
parentWorkflowName - The parent workflow name to create an draft copy of.
Returns:
A draft workflow or null if no draft workflow is found

createDraftWorkflow

JiraWorkflow createDraftWorkflow(JiraServiceContext jiraServiceContext,
                                 String parentWorkflowName)
Creates a copy of an active workflow for editing. This will not overwrite the current active workflow

Parameters:
jiraServiceContext - service context with user and error collection
parentWorkflowName - The parent workflow name to create an draft copy of.
Returns:
A copy of the active workflow

deleteDraftWorkflow

boolean deleteDraftWorkflow(JiraServiceContext jiraServiceContext,
                            String parentWorkflowName)
Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.

Parameters:
jiraServiceContext - service context with user and error collection
parentWorkflowName - The parent workflow name that the draft workflow to be deleted is associated with
Returns:
true if an draft workflow was deleted, false otherwise

deleteWorkflow

ServiceOutcome<Void> deleteWorkflow(ApplicationUser deletingUser,
                                    String workflowName)
Deletes the workflow which has the passed name.

Parameters:
deletingUser - user who performs the deletion
workflowName - name of the workflow to be deleted
Returns:
the result of the operation.

overwriteActiveWorkflow

void overwriteActiveWorkflow(JiraServiceContext jiraServiceContext,
                             String parentWorkflowName)
This method will overwrite the parentWorkflow with a draft Workflow if it exists. If it doesn't exist, this method will add an error to the errorcollection in the service context. The method will also check for the existance of the parent, and call validateOverwriteWorkflow(com.atlassian.jira.bc.JiraServiceContext, String) to ensure the active workflow isn't being overwritten with an invalid draft workflow.

Parameters:
jiraServiceContext - service context with user and error collection
parentWorkflowName - The parent workflow name that will be overwritten with its draft workflow

validateOverwriteWorkflow

void validateOverwriteWorkflow(JiraServiceContext jiraServiceContext,
                               String workflowName)
Validates that the draft workflow with the given name is allowed to be saved into the corresponding active workflow. Basically you are allowed to add new Steps and change the transitions, but you are not allowed to remove any steps/statuses, or change an existing association between a step ID and an Issue status.

Parameters:
jiraServiceContext - JiraServiceContext
workflowName - Name of the workflow to be validated.

updateWorkflow

void updateWorkflow(JiraServiceContext jiraServiceContext,
                    JiraWorkflow workflow)
Updates the workflow descriptor provided in the persistance mechanism implemented. This method can be used for draft workflows, as well as for copies of active workflows. 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 overwriteActiveWorkflow(com.atlassian.jira.bc.JiraServiceContext, String) }

Parameters:
jiraServiceContext - service context with user and error collection
workflow - contains the descriptor that the workflow will be updated to.
Throws:
IllegalArgumentException - if theworkflow or its descriptor is null. Also thrown if there is no draft workflow associated with the provided parentWorkflowName.

validateUpdateWorkflowNameAndDescription

void validateUpdateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext,
                                              JiraWorkflow currentWorkflow,
                                              String newWorkflowName)
Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.

Parameters:
jiraServiceContext - service context with user and error collection
currentWorkflow - The current workflow to be updated.
newWorkflowName - The new name to save with the workflow

updateWorkflowNameAndDescription

void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext,
                                      JiraWorkflow currentWorkflow,
                                      String newName,
                                      String newDescription)
Used to change the name and description of an existing worfklow with the given name.

Parameters:
jiraServiceContext - service context with user and error collection
currentWorkflow - The current workflow to be updated.
newName - The new name to save with the workflow
newDescription - The new descriptio to save with the workflow

getWorkflow

JiraWorkflow getWorkflow(JiraServiceContext jiraServiceContext,
                         String name)
Returns the workflow with the given name.

Parameters:
jiraServiceContext - service context with user and error collection
name - the name of the workflow
Returns:
the workflow with the given name.

validateCopyWorkflow

void validateCopyWorkflow(JiraServiceContext jiraServiceContext,
                          String newWorkflowName)
Validates if a workflow can be cloned and saved with the provided name. This means checking if the name is set, if it contains invalid characters, and if the workflow already exists.

Parameters:
jiraServiceContext - service context with user and error collection
newWorkflowName - The name of the cloned workflow.

copyWorkflow

JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext,
                          String clonedWorkflowName,
                          String clonedWorkflowDescription,
                          JiraWorkflow workflowToClone)
Clones and persists a new workflow with the name given. This will create a complete deep copy of the worfklow provided.

Parameters:
jiraServiceContext - service context with user and error collection
clonedWorkflowName - The name to store the cloned workflow with.
clonedWorkflowDescription - The description of the new copy. May be null.
workflowToClone - The workflow to clone.
Returns:
A clone of the workflow provided.

isStepOnDraftWithNoTransitionsOnParentWorkflow

boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(JiraServiceContext jiraServiceContext,
                                                       JiraWorkflow workflow,
                                                       int stepId)
Given a draft workflow and a step Id, this method returns true, if the step does not have any transitions on the original workflow.

Parameters:
jiraServiceContext - service context with user and error collection
workflow - The draft workflow with the new step
stepId - The stepId of the step to check
Returns:
true if the step does not have any transitions on the original workflow.

validateAddWorkflowTransitionToDraft

void validateAddWorkflowTransitionToDraft(JiraServiceContext jiraServiceContext,
                                          JiraWorkflow newJiraworkflow,
                                          int stepId)
Validates if a workflow transition can be added to a draft. If the original workflow for the draft does not have any outgoing transitions, then this method will add an error to the error collection.

Parameters:
jiraServiceContext - service context with user and error collection
newJiraworkflow - The draft workflow to which the transition is being added
stepId - The step to which the transition is being added.


Copyright © 2002-2013 Atlassian. All Rights Reserved.