Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

auto-transition function not working - no idea why, can't find any clue

Mateusz Jedynak
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 13, 2012

Hi,

i,ve got a code fiding a 'parent' issue and transistioning it depending on the some validation.

Infortunetly it's not working, but i have no more idea why.

It's setting up a comment of the issue but it's not changing it's status.

I have observed that after validation program tries to run script from the begiining.

I have no erors in logs.

{code}

import org.apache.log4j.Category;

import org.ofbiz.core.entity.GenericValue;

import org.ofbiz.core.entity.GenericEntityException;

import com.opensymphony.workflow.Condition;

import com.opensymphony.workflow.spi.WorkflowEntry;

import com.opensymphony.module.propertyset.PropertySet;

import com.atlassian.jira.ManagerFactory;

import com.atlassian.jira.ComponentManager;

import com.atlassian.jira.issue.link.IssueLink;

import com.atlassian.jira.issue.link.IssueLinkType;

import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;

import com.atlassian.jira.util.ImportUtils;

import java.util.Map;

import java.util.List;

import java.util.Iterator;

import java.util.Collection;

import com.opensymphony.workflow.WorkflowContext;

import com.atlassian.jira.workflow.WorkflowTransitionUtil;

import com.atlassian.jira.util.JiraUtils;

import com.atlassian.jira.issue.MutableIssue;

import com.atlassian.jira.issue.comments.CommentManager;

//Data

IssueLink innerlink; // Dla globalnego podgladu danej

String linkType = Testy; // Rodzaj lacza - nazwa

String validStateOut = 1; // Status kroku testowego

String validStateIn = 1; // Status błędu

boolean stat = true; // nie ruszać

int actionId = 81; // akcja do wykonania

List outwardLinks = ComponentManager.getInstance().getIssueLinkManager().getOutwardLinks(issue.getLong(id));

for (int i = 0; i < outwardLinks.size(); i++)

{

IssueLink link = (IssueLink) outwardLinks.get(i);

if(linkType.equals(link.getIssueLinkType().getName()))

{

String issueStatus = ((GenericValue ) link.getDestination()).getString(status);

if(issueStatus.equals(validStateOut))

{

List inwardLinks = ComponentManager.getInstance().getIssueLinkManager().getInwardLinks(link.getDestinationId());

for (int j = 0; j < inwardLinks.size(); j++)

{

innerlink = (IssueLink) inwardLinks.get(j);

if(linkType.equals(innerlink.getIssueLinkType().getName()))

{

String issueStatusB = ((GenericValue ) innerlink.getSource()).getString(status);

if(issueStatusB.equals(!validStateIn))

{

stat = false;

break;

}

}

}

if(stat==true)

{

boolean wasIndexing = ImportUtils.isIndexIssues();

ImportUtils.setIndexIssues(true);

MutableIssue parent = link.getDestinationObject() as MutableIssue;

String currentUser = ((WorkflowContext) transientVars.get(context)).getCaller();

WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );

workflowTransitionUtil.setIssue(parent);

workflowTransitionUtil.setUsername(currentUser);

workflowTransitionUtil.setAction (actionId);

// Add a comment so people have a clue why the child has been closed

CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);

String comment = Wykonano przez automat.;

commentManager.create(parent, currentUser, comment, true);

workflowTransitionUtil.validate();

workflowTransitionUtil.progress();

ImportUtils.setIndexIssues(wasIndexing);

}

}

else

{

log.error(validStateout else: + validStateOut);

}

}

}

{code}

1 answer

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2012

Have done something similar here . below is my method which does auto-transition for Jira 4.3.

private void postCreationTasks() {
MutableIssue issue1=getIssueObject();
final String remoteuser=ComponentManager.getInstance().getJiraAuthenticationContext().getUser().getName();
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
workflowTransitionUtil.setIssue(issue1);
workflowTransitionUtil.setUsername(remoteuser);
workflowTransitionUtil.setAction(5);
workflowTransitionUtil.progress();
}

Mateusz Jedynak
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 14, 2012

I've done it the same way, infortunetly in my case, i'm trying to move other issue than i'm operating on, when i'm progressing it, it's changing it's fields values, but the status is still the same... i've got really no idea what it could be...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events