/** * Migrate the specified issue to the specified workflow, specified status and target type. * * @param issue - the issue to migrate - should be the issue that will be changed * @param oldIssueType - the old issue type of the issue * @param targetWorkflow - the destination workflow * @param targetStatus - the destination status */ protected void migrateIssueToWorkflow(MutableIssue issue, String oldIssueType, JiraWorkflow targetWorkflow, Status targetStatus) throws GenericEntityException { // Do not move if current worklfow is the same as the target workflow if (!isWorkflowMatch(oldIssueType, issue.getString("type"))) { getWorkflowManager().migrateIssueToWorkflow(issue, targetWorkflow, targetStatus); } }
/** * Migrates the updated issue to a workflow based on its project and issue * type only if it differs from the current issue's workflow. * * @param currentIssue current issue * @param updatedIssue updated issue * @throws com.atlassian.jira.exception.DataAccessException * if migration fails */ private void migrateWorkflowIfNecessary(Issue currentIssue, MutableIssue updatedIssue) { JiraWorkflow currentWorkflow = getWorkflowForIssue(currentIssue); JiraWorkflow targetWorkflow = getWorkflowForIssue(updatedIssue); if (!targetWorkflow.equals(currentWorkflow)) { try { workflowManager.migrateIssueToWorkflow(updatedIssue, targetWorkflow, updatedIssue.getStatusObject()); } catch (WorkflowException e) { String msg = "Could not migrate to sub-task workflow for issue: " + currentIssue.getKey(); log.error(msg, e); throw new DataAccessException(msg, e); } } }
workflowManager.migrateIssueToWorkflow(newIssue, bulkEditBean.getTargetWorkflow(), newStatus);