public class

DefaultWorkflowSchemeManager

extends AbstractSchemeManager
implements Startable WorkflowSchemeManager
java.lang.Object
   ↳ com.atlassian.jira.scheme.AbstractSchemeManager
     ↳ com.atlassian.jira.workflow.DefaultWorkflowSchemeManager

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.scheme.SchemeManager
[Expand]
Inherited Fields
From class com.atlassian.jira.scheme.AbstractSchemeManager
Public Constructors
DefaultWorkflowSchemeManager(ProjectManager projectManager, PermissionTypeManager permissionTypeManager, PermissionContextFactory permissionContextFactory, SchemeFactory schemeFactory, WorkflowManager workflowManager, ConstantsManager constantsManager, OfBizDelegator ofBizDelegator, EventPublisher eventPublisher, NodeAssociationStore nodeAssociationStore, GroupManager groupManager, DraftWorkflowSchemeStore draftWorkflowSchemeStore, JiraAuthenticationContext context, UserManager userManager, I18nHelper.BeanFactory i18nFactory, AssignableWorkflowSchemeStore assignableWorkflowSchemeStore, CacheManager cacheManager, ClusterLockService clusterLockService)
Public Methods
void addWorkflowToScheme(GenericValue scheme, String workflowName, String issueTypeId)
AssignableWorkflowScheme.Builder assignableBuilder()
Return a builder that can be used to create a new AssignableWorkflowScheme.
AssignableWorkflowScheme cleanUpSchemeDraft(Project project, ApplicationUser user)
If the project's workflow scheme is only used by one project and if this scheme has a draft, then the draft is copied to a separate scheme and deleted.
void clearWorkflowCache()
AssignableWorkflowScheme copyDraft(DraftWorkflowScheme draft, ApplicationUser user, String newDescription)
@Nonnull DraftWorkflowScheme createDraft(ApplicationUser creator, DraftWorkflowScheme workflowScheme)
Create the passed draft workflow scheme.
@Nonnull DraftWorkflowScheme createDraftOf(ApplicationUser creator, AssignableWorkflowScheme workflowScheme)
Create a draft for the passed workflow scheme.
@Nonnull AssignableWorkflowScheme createScheme(AssignableWorkflowScheme workflowScheme)
Create a new workflow scheme.
GenericValue createScheme(String name, String description)
Creates a new scheme
GenericValue createSchemeEntity(GenericValue scheme, SchemeEntity schemeEntity)
GenericValue createSchemeEntity(long schemeId, SchemeEntity schemeEntity)
void deleteEntities(Iterable<Long> ids)
Deletes a collection of entities from the database.
void deleteEntity(Long id)
Deletes an entity with the given id from the database.
void deleteScheme(Long id)
Deletes a scheme from the database
boolean deleteWorkflowScheme(WorkflowScheme scheme)
Delete the passed workflow scheme.
DraftWorkflowScheme.Builder draftBuilder(AssignableWorkflowScheme parent)
Return a builder that can be used to create a new DraftWorkflowScheme for the passed workflow scheme.
Collection<String> getActiveWorkflowNames()
@Nonnull Iterable<AssignableWorkflowScheme> getAssignableSchemes()
Return all the assignable workflow schemes.
String getDefaultDescriptionKey()
GenericValue getDefaultEntity(GenericValue scheme)
String getDefaultNameKey()
AssignableWorkflowScheme getDefaultWorkflowScheme()
DraftWorkflowScheme getDraft(long id)
Return the draft workflow scheme with the given id.
DraftWorkflowScheme getDraftForParent(AssignableWorkflowScheme scheme)
Return the draft workflow scheme for the passed workflow scheme.
List<GenericValue> getEntities(GenericValue scheme, String issuetype)
Inherited from SchemeManager.
List<GenericValue> getEntities(GenericValue scheme, Long entityTypeId, String parameter)
Inherited from SchemeManager.
List<GenericValue> getEntities(GenericValue scheme, String type, Long entityTypeId)
Inherited from SchemeManager.
List<GenericValue> getEntities(GenericValue scheme, Long entityTypeId)
Inherited from SchemeManager.
String getEntityName()
List<GenericValue> getNonDefaultEntities(GenericValue scheme)
AssignableWorkflowScheme getParentForDraft(long draftSchemeId)
Return the original workflow scheme for the passed draft workflow scheme.
@Nonnull List<Project> getProjectsUsing(AssignableWorkflowScheme workflowScheme)
Return the list of projects that use the passed workflow scheme.
String getSchemeDesc()
String getSchemeEntityName()
Collection<GenericValue> getSchemesForWorkflow(JiraWorkflow workflow)
Returns all workflow schemes that the passed workflow is assigned to, not including draft schemes.
Iterable<WorkflowScheme> getSchemesForWorkflowIncludingDrafts(JiraWorkflow workflow)
Returns all workflow schemes that the passed workflow is assigned to, including draft schemes.
Map<StringString> getWorkflowMap(Project project)
Returns a map representation of a workflow scheme for a passed project.
String getWorkflowName(GenericValue scheme, String issueType)
Get the name of the workflow from the passed scheme associated with the passed issue type.
String getWorkflowName(Project project, String issueType)
Get the name of the workflow associated with the passed project and issue type.
GenericValue getWorkflowScheme(Project project)
GenericValue getWorkflowScheme(GenericValue project)
@Nonnull AssignableWorkflowScheme getWorkflowSchemeObj(Project project)
Return the workflow scheme associated with the passed project.
@Nullable AssignableWorkflowScheme getWorkflowSchemeObj(long id)
Return the workflow scheme with the passed id.
AssignableWorkflowScheme getWorkflowSchemeObj(String name)
Return the workflow scheme with the passed name.
boolean hasDraft(AssignableWorkflowScheme scheme)
Tells the caller if the passed workflow scheme has a draft.
boolean isActive(WorkflowScheme scheme)
Return true if the passed workflow scheme is being used by a project.
boolean isUsingDefaultScheme(Project project)
Tells the caller if the passed project is using the default workflow scheme.
@EventListener void onClearCache(ClearCacheEvent event)
boolean removeEntities(GenericValue scheme, Long entityTypeId)
Retrieves all the entites for this permission and then removes them.
void replaceSchemeWithDraft(DraftWorkflowScheme draft)
void start()
This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.
DraftWorkflowScheme updateDraftWorkflowScheme(ApplicationUser user, DraftWorkflowScheme scheme)
Save changes to the passed draft workflow scheme.
void updateScheme(Scheme scheme)
Updates any changes to the scheme object.
void updateSchemesForRenamedWorkflow(String oldWorkflowName, String newWorkflowName)
Updates Workflow Schemes's such that schemes associated to the workflow with name oldWorkflowName will be changed to newWorkflowName.
AssignableWorkflowScheme updateWorkflowScheme(AssignableWorkflowScheme workflowScheme)
Save changes to the passed workflow scheme.
<T> T waitForUpdatesToFinishAndExecute(AssignableWorkflowScheme scheme, Callable<T> task)
If the passed workflow scheme is currently being edited, then this method blocks until the editing is finished.
Protected Methods
@Nonnull AbstractSchemeAddedToProjectEvent createSchemeAddedToProjectEvent(Scheme scheme, Project project)
@Nonnull AbstractSchemeCopiedEvent createSchemeCopiedEvent(Scheme oldScheme, Scheme newScheme)
AbstractSchemeEvent createSchemeCreatedEvent(Scheme scheme)
Object createSchemeEntityDeletedEvent(GenericValue entity)
GenericValue createSchemeEntityNoEvent(GenericValue scheme, SchemeEntity schemeEntity)
@Nonnull AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent(Scheme scheme, Project project)
AbstractSchemeUpdatedEvent createSchemeUpdatedEvent(Scheme scheme, Scheme originalScheme)
void flushProjectSchemes()
Collection<IssueType> getAllIssueTypes()
JiraWorkflow getWorkflowFromScheme(GenericValue workflowScheme, String issueTypeId)
SchemeEntity makeSchemeEntity(GenericValue entity)
[Expand]
Inherited Methods
From class com.atlassian.jira.scheme.AbstractSchemeManager
From class java.lang.Object
From interface com.atlassian.jira.extension.Startable
From interface com.atlassian.jira.scheme.SchemeManager
From interface com.atlassian.jira.workflow.WorkflowSchemeManager

Public Constructors

public DefaultWorkflowSchemeManager (ProjectManager projectManager, PermissionTypeManager permissionTypeManager, PermissionContextFactory permissionContextFactory, SchemeFactory schemeFactory, WorkflowManager workflowManager, ConstantsManager constantsManager, OfBizDelegator ofBizDelegator, EventPublisher eventPublisher, NodeAssociationStore nodeAssociationStore, GroupManager groupManager, DraftWorkflowSchemeStore draftWorkflowSchemeStore, JiraAuthenticationContext context, UserManager userManager, I18nHelper.BeanFactory i18nFactory, AssignableWorkflowSchemeStore assignableWorkflowSchemeStore, CacheManager cacheManager, ClusterLockService clusterLockService)

Public Methods

public void addWorkflowToScheme (GenericValue scheme, String workflowName, String issueTypeId)

Throws
GenericEntityException

public AssignableWorkflowScheme.Builder assignableBuilder ()

Return a builder that can be used to create a new AssignableWorkflowScheme.

Returns
  • the builder that can be used to create the new workflow scheme.

public AssignableWorkflowScheme cleanUpSchemeDraft (Project project, ApplicationUser user)

If the project's workflow scheme is only used by one project and if this scheme has a draft, then the draft is copied to a separate scheme and deleted.

Parameters
project project who's workflow scheme draft is to be copied to a separate scheme.
user the user making the changes.
Returns
  • copied scheme or null if it was not created.

public void clearWorkflowCache ()

public AssignableWorkflowScheme copyDraft (DraftWorkflowScheme draft, ApplicationUser user, String newDescription)

@Nonnull public DraftWorkflowScheme createDraft (ApplicationUser creator, DraftWorkflowScheme workflowScheme)

Create the passed draft workflow scheme. A draft can be created using the draftBuilder(AssignableWorkflowScheme) method.

  • A scheme that already has a draft.
  • A scheme that is not currently in the database.
  • The default workflow scheme
  • A draft workflow scheme.

Parameters
creator the user that is going to create the draft. This user is recorded as the person who last modified the new draftscheme.
workflowScheme the workflow scheme to create.
Returns
  • the new draft scheme.

@Nonnull public DraftWorkflowScheme createDraftOf (ApplicationUser creator, AssignableWorkflowScheme workflowScheme)

Create a draft for the passed workflow scheme. It is illegal to pass:

  • A scheme that already has a draft.
  • A scheme that is not currently in the database.
  • The default workflow scheme
  • A draft workflow scheme.

Parameters
creator the user that is going to create the draft. This user is recorded as the person who last modified the new draftscheme.
workflowScheme the workflow scheme to create a draft of. It cannot be a draft, the default scheme, a scheme that already has a draft or a scheme that is not already in the database (i.e. does not have an ID).
Returns
  • the new draft scheme.

@Nonnull public AssignableWorkflowScheme createScheme (AssignableWorkflowScheme workflowScheme)

Create a new workflow scheme.

Parameters
workflowScheme the workflow scheme to create a draft of. It cannot be a draft, the default scheme, a scheme that already has a draft or a scheme that is not already in the database (i.e. does not have an ID).
Returns
  • the new draft scheme.

public GenericValue createScheme (String name, String description)

Creates a new scheme

Parameters
name The name of the new scheme
description The description of the new scheme
Returns
  • The new scheme object
Throws
GenericEntityException

public GenericValue createSchemeEntity (GenericValue scheme, SchemeEntity schemeEntity)

Throws
GenericEntityException

public GenericValue createSchemeEntity (long schemeId, SchemeEntity schemeEntity)

Throws
GenericEntityException

public void deleteEntities (Iterable<Long> ids)

Deletes a collection of entities from the database.

Parameters
ids a collection entity ids to be deleted.

public void deleteEntity (Long id)

Deletes an entity with the given id from the database.

Parameters
id The id of the entity to be deleted

public void deleteScheme (Long id)

Deletes a scheme from the database

Parameters
id Id of the scheme to be deleted

public boolean deleteWorkflowScheme (WorkflowScheme scheme)

Delete the passed workflow scheme. It is illegal to delete an active scheme, the default scheme or a scheme that is not already in the database.

Parameters
scheme the scheme to delete. Cannot be the default scheme, active scheme or a scheme that is not already in the database.
Returns
  • true if the scheme was deleted; false otherwise.

public DraftWorkflowScheme.Builder draftBuilder (AssignableWorkflowScheme parent)

Return a builder that can be used to create a new DraftWorkflowScheme for the passed workflow scheme.

Returns
  • the builder that can be used to create the new workflow scheme.

public Collection<String> getActiveWorkflowNames ()

Throws
GenericEntityException
WorkflowException

@Nonnull public Iterable<AssignableWorkflowScheme> getAssignableSchemes ()

Return all the assignable workflow schemes.

Returns
  • a list of all the assignable workflow schemes.

public String getDefaultDescriptionKey ()

public GenericValue getDefaultEntity (GenericValue scheme)

Throws
GenericEntityException

public String getDefaultNameKey ()

public AssignableWorkflowScheme getDefaultWorkflowScheme ()

public DraftWorkflowScheme getDraft (long id)

Return the draft workflow scheme with the given id.

Parameters
id the id of the draft workflow scheme to be returned
Returns
  • the draft with the given id or null if it does not exist.

public DraftWorkflowScheme getDraftForParent (AssignableWorkflowScheme scheme)

Return the draft workflow scheme for the passed workflow scheme.

Parameters
scheme the workflow scheme whose draft is being sought.
Returns
  • the draft of the passed workflow scheme or null if it does not exist.

public List<GenericValue> getEntities (GenericValue scheme, String issuetype)

Inherited from SchemeManager.

Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, Long entityTypeId, String parameter)

Inherited from SchemeManager.

Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, String type, Long entityTypeId)

Inherited from SchemeManager.

Throws
GenericEntityException

public List<GenericValue> getEntities (GenericValue scheme, Long entityTypeId)

Inherited from SchemeManager.

Throws
GenericEntityException

public String getEntityName ()

public List<GenericValue> getNonDefaultEntities (GenericValue scheme)

Throws
GenericEntityException

public AssignableWorkflowScheme getParentForDraft (long draftSchemeId)

Return the original workflow scheme for the passed draft workflow scheme.

Parameters
draftSchemeId the id of the draft workflow scheme whose parent is being sought.
Returns
  • the parent of the passed draft workflow scheme.

@Nonnull public List<Project> getProjectsUsing (AssignableWorkflowScheme workflowScheme)

Return the list of projects that use the passed workflow scheme.

Parameters
workflowScheme the workflow scheme to check.
Returns
  • the list of projects that use the passed workflow scheme.

public String getSchemeDesc ()

public String getSchemeEntityName ()

public Collection<GenericValue> getSchemesForWorkflow (JiraWorkflow workflow)

Returns all workflow schemes that the passed workflow is assigned to, not including draft schemes.

Parameters
workflow the workflow whose schemes must be returned
Returns
  • workflow schemes that the passed workflow is assigned to, not including draft schemes.

public Iterable<WorkflowScheme> getSchemesForWorkflowIncludingDrafts (JiraWorkflow workflow)

Returns all workflow schemes that the passed workflow is assigned to, including draft schemes.

Parameters
workflow the workflow whose schemes must be returned
Returns
  • workflow schemes that the passed workflow is assigned to, including draft schemes.

public Map<StringString> getWorkflowMap (Project project)

Returns a map representation of a workflow scheme for a passed project. The returned map stores {issuetype -> workflowName}. A null issuetype points out the default workflow for the scheme.

Parameters
project the project whose scheme should be returned.
Returns
  • the map representation of a workflow scheme. Each key represents an issuetype which its associated value the name of the workflow assigned to that issue type. A null issuetype points out the default workflow for that scheme.

public String getWorkflowName (GenericValue scheme, String issueType)

Get the name of the workflow from the passed scheme associated with the passed issue type.

Parameters
scheme the scheme to search.
issueType the issue type used in the search.
Returns
  • the name of the workflow associated with the scheme and issue type.

public String getWorkflowName (Project project, String issueType)

Get the name of the workflow associated with the passed project and issue type.

Parameters
project the project used in the search.
issueType the issue type used in the search.
Returns
  • the name of the workflow associated with the passed project and issue type.

public GenericValue getWorkflowScheme (Project project)

Throws
GenericEntityException

public GenericValue getWorkflowScheme (GenericValue project)

Throws
GenericEntityException

@Nonnull public AssignableWorkflowScheme getWorkflowSchemeObj (Project project)

Return the workflow scheme associated with the passed project.

Parameters
project the project whose scheme is to be returned.
Returns
  • the scheme the passed project is using. Never null.

@Nullable public AssignableWorkflowScheme getWorkflowSchemeObj (long id)

Return the workflow scheme with the passed id.

Parameters
id the id to search.
Returns
  • the workflow scheme with the given id or null if no such scheme exists.

public AssignableWorkflowScheme getWorkflowSchemeObj (String name)

Return the workflow scheme with the passed name.

Parameters
name the name to search.
Returns
  • the workflow scheme with the given name or null if no such scheme exists.

public boolean hasDraft (AssignableWorkflowScheme scheme)

Tells the caller if the passed workflow scheme has a draft.

Parameters
scheme the workflow scheme to check. It is illegal to pass a draft workflow scheme to this method.
Returns
  • true if the passed workflow has a draft false otherwise.

public boolean isActive (WorkflowScheme scheme)

Return true if the passed workflow scheme is being used by a project.

Parameters
scheme the workflow scheme to test.
Returns
  • true if the passed workflow scheme us being used by a project; false otherwise.

public boolean isUsingDefaultScheme (Project project)

Tells the caller if the passed project is using the default workflow scheme.

Parameters
project the project to check.
Returns
  • true if the passed project is using the default scheme, false otherwise.

@EventListener public void onClearCache (ClearCacheEvent event)

public boolean removeEntities (GenericValue scheme, Long entityTypeId)

Retrieves all the entites for this permission and then removes them.

Parameters
scheme to remove entites from must NOT be null
entityTypeId to remove
Returns
  • True all the time (legacy)

public void replaceSchemeWithDraft (DraftWorkflowScheme draft)

public void start ()

This method will be called after the plugin system is fully initialised and all components added to the dependency injection framework.

public DraftWorkflowScheme updateDraftWorkflowScheme (ApplicationUser user, DraftWorkflowScheme scheme)

Save changes to the passed draft workflow scheme.

Parameters
user the user making the changes.
scheme the draft scheme to change.
Returns
  • the draft scheme as now stored in the database.

public void updateScheme (Scheme scheme)

Updates any changes to the scheme object. This does not include changes to the scheme entities.

Parameters
scheme The modified scheme object

public void updateSchemesForRenamedWorkflow (String oldWorkflowName, String newWorkflowName)

Updates Workflow Schemes's such that schemes associated to the workflow with name oldWorkflowName will be changed to newWorkflowName.

Note: There is no validation performed by this method to determine if the provided oldWorkflowName or newWorkflowName are valid workflow names or if the workflow is active/inactive. These validations must be done by the caller.

Parameters
oldWorkflowName name of the workflow to re-assign all its associated schemes from
newWorkflowName name of the workflow to assign all the schemes associated to targetWorkflow

public AssignableWorkflowScheme updateWorkflowScheme (AssignableWorkflowScheme workflowScheme)

Save changes to the passed workflow scheme.

Parameters
workflowScheme the scheme to change.
Returns
  • the scheme that is now stored in the database.

public T waitForUpdatesToFinishAndExecute (AssignableWorkflowScheme scheme, Callable<T> task)

If the passed workflow scheme is currently being edited, then this method blocks until the editing is finished. Executes the passed Callable task in the end and returns its result. Workflow scheme editing will be blocked until the task execution finishes.

Parameters
scheme the workflow scheme.
task task to execute.
Returns
  • the value returned by the passed task.
Throws
Exception

Protected Methods

@Nonnull protected AbstractSchemeAddedToProjectEvent createSchemeAddedToProjectEvent (Scheme scheme, Project project)

@Nonnull protected AbstractSchemeCopiedEvent createSchemeCopiedEvent (Scheme oldScheme, Scheme newScheme)

protected AbstractSchemeEvent createSchemeCreatedEvent (Scheme scheme)

protected Object createSchemeEntityDeletedEvent (GenericValue entity)

protected GenericValue createSchemeEntityNoEvent (GenericValue scheme, SchemeEntity schemeEntity)

Throws
GenericEntityException

@Nonnull protected AbstractSchemeRemovedFromProjectEvent createSchemeRemovedFromProjectEvent (Scheme scheme, Project project)

protected AbstractSchemeUpdatedEvent createSchemeUpdatedEvent (Scheme scheme, Scheme originalScheme)

protected void flushProjectSchemes ()

protected Collection<IssueType> getAllIssueTypes ()

protected JiraWorkflow getWorkflowFromScheme (GenericValue workflowScheme, String issueTypeId)

protected SchemeEntity makeSchemeEntity (GenericValue entity)