Hi,
I am trying to change status of an issue programmatically. since there are no direct transition for some statuses, i have to transition through all available transitions from the initial status. This is bit tricky(similar to travelling sales person algorithm). Trying to find some optimal solution for this.
I could see that below code is been used in Jira CSV importer plugin. I tried it but doesn't help if there is no direct transition available to my desired target status.
JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issueResult.getIssue());
StepDescriptor linkedStep = workflow.getLinkedStep(status);
Collection wfCurrentStepCollection = CoreFactory.getGenericDelegator().findByAnd("OSCurrentStep",
EasyMap.build("entryId", issueResult.getIssue().getLong("workflowId")));
if ((wfCurrentStepCollection != null) && (!wfCurrentStepCollection.isEmpty())) {
GenericValue wfCurrentStep = (GenericValue) wfCurrentStepCollection.iterator().next();
if (linkedStep != null) {
wfCurrentStep.set("stepId", Integer.valueOf(linkedStep.getId()));
wfCurrentStep.store();
}
}
issueResult.getIssue().setStatusId(request.getStatusId());
issueResult.getIssue().store();
besides, some of the functions are deprecated here.
eg: CoreFactory.getGenericDelegator() and issueResult.getIssue().store()
Any help would be much appreciated!
Thanks.