Class SimplifiedWorkflowServiceImpl
java.lang.Object
com.atlassian.greenhopper.service.workflow.SimplifiedWorkflowServiceImpl
- All Implemented Interfaces:
SimplifiedWorkflowService
@Service
public class SimplifiedWorkflowServiceImpl
extends Object
implements SimplifiedWorkflowService
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimplifiedWorkflowServiceImpl
(com.atlassian.jira.util.BuildUtilsInfo buildUtilsInfo, com.atlassian.jira.bc.issue.search.SearchService jiraSearchService, com.atlassian.jira.config.StatusManager statusManager, com.atlassian.jira.project.ProjectManager projectManager, com.atlassian.plugin.PluginAccessor pluginAccessor, com.atlassian.jira.workflow.WorkflowManager workflowManager, com.atlassian.jira.workflow.WorkflowSchemeManager workflowSchemeManager, WorkflowService workflowService, I18nFactoryService i18nFactoryService, WorkflowConstantsService workflowConstantsService, BuildProperties buildProperties, SimplifiedWorkflowStringsFactory simplifiedWorkflowStringsFactory, com.atlassian.plugin.ModuleDescriptorFactory moduleDescriptorFactory) -
Method Summary
Modifier and TypeMethodDescriptionaddStatusToGreenHopperSimplifiedWorkflow
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status status) Modifies the GreenHopper Simplified Workflow to include the specifiedStatus
as a step with its associated global transitions.ServiceOutcome<com.atlassian.jira.issue.status.Status>
canStatusBeRemovedFromGreenHopperSimplifiedWorkflow
(com.atlassian.jira.workflow.JiraWorkflow workflow, String statusId) Checks to see if the specified status can be removed from the specifiedJiraWorkflow
.checkForSimplifiedWorkflowNamedAfterProject
(String projectKey) Look for the existence of workflows or workflow schemes with the reserved name for "GreenHopper Simplified Workflow" for the given project.ServiceOutcome<com.atlassian.jira.workflow.JiraWorkflow>
convertTransitionsToSimplified
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow mutable, List<com.atlassian.jira.issue.status.Status> resolutionDoneStatuses) Converts a workflow so that it will have only global transitions to all steps.ServiceOutcome<com.atlassian.jira.scheme.Scheme>
createSimplifiedWorkflowForExistingProject
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.project.Project project, List<com.atlassian.jira.issue.status.Status> resolutionDoneStatuses) Take the workflow of the existing project, and create a copy which is a GreenHopper Simplified Workflow.createSimplifiedWorkflowForNewProject
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.project.Project project, SimplifiedWorkflowPresets preset) Create a "GreenHopper Simplified Workflow" workflow scheme and workflow for the newly created project and associate it with the provided projectServiceOutcome<com.atlassian.jira.util.lang.Pair<com.atlassian.jira.workflow.JiraWorkflow,
com.atlassian.jira.scheme.Scheme>> createSimplifiedWorkflowForNewProject
(com.atlassian.jira.user.ApplicationUser user, String projectKey, SimplifiedWorkflowPresets preset) Create a "GreenHopper Simplified Workflow" workflow scheme and workflow for a project with key projectKey.ServiceOutcome<com.atlassian.jira.util.lang.Pair<com.atlassian.jira.workflow.JiraWorkflow,
com.atlassian.jira.project.Project>> getGreenHopperSimplifiedWorkflow
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.query.Query query) Attempts to retrieve the GreenHopper Simplified Workflow that is backing theQuery
.ServiceOutcome<com.atlassian.jira.util.lang.Pair<com.atlassian.jira.workflow.JiraWorkflow,
com.atlassian.jira.project.Project>> getPotentialWorkflowForConversion
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.query.Query query) Attempts to retrieve a potential GreenHopper Simplified Workflow that is backing theQuery
.get the map from WorkflowPreset enum to the bean encapsulating preset databoolean
isStatusResolutionDone
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status status) Check if this status is marked as done in simplified workflowremoveStatusFromGreenHopperSimplifiedWorkflow
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status status) Removes the specifiedStatus
associated step and global transition from the GreenHopper Simplified Workflow.ServiceOutcome<com.atlassian.jira.workflow.JiraWorkflow>
replaceInitialStatusInGreenHopperSimplifiedWorkflow
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status oldInitialStatus, com.atlassian.jira.issue.status.Status newInitialStatus) Replaces the initial status specified in the workflow with a new one.setStatusResolutionDone
(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status status, boolean done) Switches on/off the resolution to done for a certain workflow status
-
Field Details
-
JIRA_5_0_4_BUILD_NUMBER
public static final int JIRA_5_0_4_BUILD_NUMBER- See Also:
-
log
-
-
Constructor Details
-
SimplifiedWorkflowServiceImpl
@Autowired public SimplifiedWorkflowServiceImpl(com.atlassian.jira.util.BuildUtilsInfo buildUtilsInfo, com.atlassian.jira.bc.issue.search.SearchService jiraSearchService, com.atlassian.jira.config.StatusManager statusManager, com.atlassian.jira.project.ProjectManager projectManager, com.atlassian.plugin.PluginAccessor pluginAccessor, com.atlassian.jira.workflow.WorkflowManager workflowManager, com.atlassian.jira.workflow.WorkflowSchemeManager workflowSchemeManager, WorkflowService workflowService, I18nFactoryService i18nFactoryService, WorkflowConstantsService workflowConstantsService, BuildProperties buildProperties, SimplifiedWorkflowStringsFactory simplifiedWorkflowStringsFactory, @Qualifier("moduleDescriptorFactory") com.atlassian.plugin.ModuleDescriptorFactory moduleDescriptorFactory)
-
-
Method Details
-
isFeatureEnabled
public boolean isFeatureEnabled()- Specified by:
isFeatureEnabled
in interfaceSimplifiedWorkflowService
- Returns:
- if the feature is able to be used based on the JIRA version.
-
getGreenHopperSimplifiedWorkflow
public ServiceOutcome<com.atlassian.jira.util.lang.Pair<com.atlassian.jira.workflow.JiraWorkflow,com.atlassian.jira.project.Project>> getGreenHopperSimplifiedWorkflow(com.atlassian.jira.user.ApplicationUser user, com.atlassian.query.Query query) Description copied from interface:SimplifiedWorkflowService
Attempts to retrieve the GreenHopper Simplified Workflow that is backing theQuery
. This will fail if the query does not meet the criteria for a Simplified Workflow. The criteria is as follows:- There is only one project in this query
- That one project only uses one workflow
- That one workflow is not JIRA's Default Workflow
- That one workflow is not used by any other projects
- That one workflow has a global transition for each step (may have non-global transitions too)
- That one workflow's name starts with our simplified workflow prefix
SimplifiedWorkflowServiceImpl#SIMPLIFIED_WORKFLOW_NAME_FMT
- Specified by:
getGreenHopperSimplifiedWorkflow
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the user trying to retrieve the workflowquery
- the query to look at- Returns:
- the result
-
getPotentialWorkflowForConversion
public ServiceOutcome<com.atlassian.jira.util.lang.Pair<com.atlassian.jira.workflow.JiraWorkflow,com.atlassian.jira.project.Project>> getPotentialWorkflowForConversion(com.atlassian.jira.user.ApplicationUser user, com.atlassian.query.Query query) Description copied from interface:SimplifiedWorkflowService
Attempts to retrieve a potential GreenHopper Simplified Workflow that is backing theQuery
. It is necessary that a Simplified Workflow is a potential Simplified Workflow, but not the other way around. This will just determine if the user may be allowed to kick off a conversion. The criteria here is less stringent:- There is only one project in this query
- That one project only uses one workflow
- Specified by:
getPotentialWorkflowForConversion
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the user retrieving the workflowquery
- the query to look at- Returns:
- the result
-
canStatusBeRemovedFromGreenHopperSimplifiedWorkflow
public ServiceOutcome<com.atlassian.jira.issue.status.Status> canStatusBeRemovedFromGreenHopperSimplifiedWorkflow(com.atlassian.jira.workflow.JiraWorkflow workflow, String statusId) Description copied from interface:SimplifiedWorkflowService
Checks to see if the specified status can be removed from the specifiedJiraWorkflow
. It assumes that the workflow is a GreenHopper Simplified Workflow. The status can only be removed if:- The status has an associated step in the workflow
- The step only has global transition(s) going into it
- Specified by:
canStatusBeRemovedFromGreenHopperSimplifiedWorkflow
in interfaceSimplifiedWorkflowService
- Parameters:
workflow
- the workflowstatusId
- the ID of the status to look for- Returns:
- the outcome
-
replaceInitialStatusInGreenHopperSimplifiedWorkflow
public ServiceOutcome<com.atlassian.jira.workflow.JiraWorkflow> replaceInitialStatusInGreenHopperSimplifiedWorkflow(com.atlassian.jira.user.ApplicationUser user, @Nonnull com.atlassian.jira.workflow.JiraWorkflow workflow, @Nonnull com.atlassian.jira.issue.status.Status oldInitialStatus, @Nonnull com.atlassian.jira.issue.status.Status newInitialStatus) Description copied from interface:SimplifiedWorkflowService
Replaces the initial status specified in the workflow with a new one. Assumes that the workflow is a GreenHopper Simplified Workflow.- Specified by:
replaceInitialStatusInGreenHopperSimplifiedWorkflow
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the userworkflow
- the workflowoldInitialStatus
- the status to removenewInitialStatus
- the status to replace it with- Returns:
- the result
-
addStatusToGreenHopperSimplifiedWorkflow
public ServiceResult addStatusToGreenHopperSimplifiedWorkflow(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status status) Description copied from interface:SimplifiedWorkflowService
Modifies the GreenHopper Simplified Workflow to include the specifiedStatus
as a step with its associated global transitions. If the status already exists in the specified workflow, nothing will be changed.- Specified by:
addStatusToGreenHopperSimplifiedWorkflow
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the userworkflow
- the workflow to modify - must be a GreenHopper Simplified Workflowstatus
- the status- Returns:
- the result
-
removeStatusFromGreenHopperSimplifiedWorkflow
public ServiceResult removeStatusFromGreenHopperSimplifiedWorkflow(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow workflow, com.atlassian.jira.issue.status.Status status) Description copied from interface:SimplifiedWorkflowService
Removes the specifiedStatus
associated step and global transition from the GreenHopper Simplified Workflow. Assumes that the workflow is a GreenHopper Simplified Workflow. If the status is no longer in use by any workflow, it will be removed from the system entirely.- Specified by:
removeStatusFromGreenHopperSimplifiedWorkflow
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the userworkflow
- the workflowstatus
- the status to remove- Returns:
- the result
-
convertTransitionsToSimplified
public ServiceOutcome<com.atlassian.jira.workflow.JiraWorkflow> convertTransitionsToSimplified(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.workflow.JiraWorkflow mutable, List<com.atlassian.jira.issue.status.Status> resolutionDoneStatuses) Description copied from interface:SimplifiedWorkflowService
Converts a workflow so that it will have only global transitions to all steps. These transitions will not have any conditions, validators or screens, and will have the default post functions applied.- Specified by:
convertTransitionsToSimplified
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the usermutable
- the original workflowresolutionDoneStatuses
- optional status which will be marked as done- Returns:
- the new workflow
-
getPresetDefinitions
Description copied from interface:SimplifiedWorkflowService
get the map from WorkflowPreset enum to the bean encapsulating preset data- Specified by:
getPresetDefinitions
in interfaceSimplifiedWorkflowService
-
checkForSimplifiedWorkflowNamedAfterProject
public ServiceOutcome<CheckWorkflowEntitiesByNameResult> checkForSimplifiedWorkflowNamedAfterProject(String projectKey) Description copied from interface:SimplifiedWorkflowService
Look for the existence of workflows or workflow schemes with the reserved name for "GreenHopper Simplified Workflow" for the given project. This is used when attempting to convert an existing project's workflow into the GreenHopper Simplified Workflow.- Specified by:
checkForSimplifiedWorkflowNamedAfterProject
in interfaceSimplifiedWorkflowService
- Returns:
- the result
- See Also:
-
createSimplifiedWorkflowForNewProject
public ServiceOutcome<com.atlassian.jira.util.lang.Pair<com.atlassian.jira.workflow.JiraWorkflow,com.atlassian.jira.scheme.Scheme>> createSimplifiedWorkflowForNewProject(com.atlassian.jira.user.ApplicationUser user, String projectKey, SimplifiedWorkflowPresets preset) Description copied from interface:SimplifiedWorkflowService
Create a "GreenHopper Simplified Workflow" workflow scheme and workflow for a project with key projectKey. Does not associate scheme with project. -
createSimplifiedWorkflowForNewProject
public ServiceResult createSimplifiedWorkflowForNewProject(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.project.Project project, SimplifiedWorkflowPresets preset) Description copied from interface:SimplifiedWorkflowService
Create a "GreenHopper Simplified Workflow" workflow scheme and workflow for the newly created project and associate it with the provided project- Specified by:
createSimplifiedWorkflowForNewProject
in interfaceSimplifiedWorkflowService
-
createSimplifiedWorkflowForExistingProject
public ServiceOutcome<com.atlassian.jira.scheme.Scheme> createSimplifiedWorkflowForExistingProject(com.atlassian.jira.user.ApplicationUser user, com.atlassian.jira.project.Project project, List<com.atlassian.jira.issue.status.Status> resolutionDoneStatuses) Description copied from interface:SimplifiedWorkflowService
Take the workflow of the existing project, and create a copy which is a GreenHopper Simplified Workflow. Does not associate the project to the workflow scheme.- Specified by:
createSimplifiedWorkflowForExistingProject
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the userproject
- the existing project- Returns:
- the new scheme which the project could be associated to
-
isStatusResolutionDone
public ServiceOutcome<Boolean> isStatusResolutionDone(com.atlassian.jira.user.ApplicationUser user, @Nonnull com.atlassian.jira.workflow.JiraWorkflow workflow, @Nonnull com.atlassian.jira.issue.status.Status status) Description copied from interface:SimplifiedWorkflowService
Check if this status is marked as done in simplified workflow- Specified by:
isStatusResolutionDone
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the userworkflow
- the workflowstatus
- the status- Returns:
-
setStatusResolutionDone
public ServiceResult setStatusResolutionDone(com.atlassian.jira.user.ApplicationUser user, @Nonnull com.atlassian.jira.workflow.JiraWorkflow workflow, @Nonnull com.atlassian.jira.issue.status.Status status, boolean done) Description copied from interface:SimplifiedWorkflowService
Switches on/off the resolution to done for a certain workflow status- Specified by:
setStatusResolutionDone
in interfaceSimplifiedWorkflowService
- Parameters:
user
- the userworkflow
- the workflowstatus
- the statusdone
- whether to clear or set as done the resolution field- Returns:
-