Forums

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

how do i update and index a MutableIssue in Jelly

Justin Taylor June 2, 2013

Hi

I have done the following script to set the component of an issue, which works because i check components at the end of the script and its right, however the script does not seem to persist or store the changed values of my MutableIssue, see below:

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >

<jira:Login username="user.survey" password="$uRv3y">

<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<core:invoke on="${componentManager}" method="getIssueManager" var="issueManager"/>

<!-- Get an instance of IssueObject -->

<core:invoke on="${issueManager}" method="getIssueObject" var="issueKey">

<core:arg type="java.lang.String" value="SUP-27096"/>

</core:invoke>

<core:invoke on="${componentManager}" method="getProjectComponentManager" var="projectComponentManager"/>

<core:invoke on="${projectComponentManager}" method="findByComponentName" var="projectComponent" >

<core:arg type="java.lang.Long" value="${issueKey.project.id}"/>

<core:arg type="java.lang.String" value="OPS"/>

</core:invoke>

<core:invoke on="${projectComponentManager}" method="convertToGenericValue" var="projectComponentGeneric" >

<core:arg type="com.atlassian.jira.bc.project.component.ProjectComponent" value="${projectComponent}"/>

</core:invoke>

<core:invoke on="${issueKey}" method="getComponents" var="components" />

<core:invoke on="${components}" method="add" var="flag">

<core:arg type="org.ofbiz.core.entity.GenericValue" value="${projectComponentGeneric}" />

</core:invoke>

<jira:AddComment comment="components ${components}" issue-key="SUP-27096"/>

<core:invoke on="${issueKey}" method="setComponents">

<core:arg type="java.util.Collection" value="${components}" />

</core:invoke>

</jira:Login>

</JiraJelly>

How do i persist this change?

Thanks in advance

2 answers

1 accepted

2 votes
Answer accepted
David Pinn
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.
June 2, 2013

Try this, Justin. I've run it on my development machine, and it did update the component of my sample issue.

&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"&gt;

&lt;jira:LoadManager var="issueManager" manager="IssueManager"/&gt;
&lt;jira:LoadManager var="projectManager" manager="ProjectManager"/&gt;

&lt;core:invoke on="${issueManager}" method="getIssueObject" var="issue"&gt;
	&lt;core:arg type="java.lang.String" value="ABC-1"/&gt;
&lt;/core:invoke&gt;

&lt;core:invoke on="${projectManager}" method="getComponent" var="projectComponent"&gt;
	&lt;core:arg type="java.lang.Long" value="10000"/&gt;
&lt;/core:invoke&gt;

&lt;core:invoke on="${issue}" method="getComponents" var="components" /&gt;

&lt;core:invoke on="${components}" method="add"&gt;
	&lt;core:arg type="org.ofbiz.core.entity.GenericValue" value="${projectComponent}" /&gt;
&lt;/core:invoke&gt;

&lt;core:invoke on="${issue}" method="setComponents"&gt;
	&lt;core:arg type="java.util.Collection" value="${components}" /&gt;
&lt;/core:invoke&gt;

&lt;core:invoke on="${issue}" method="store" /&gt;

&lt;core:getStatic 
	className="com.atlassian.jira.event.type.EventDispatchOption" 
	field="DO_NOT_DISPATCH"
	var="dispatchOption" /&gt;

&lt;core:invoke on="${issueManager}" method="updateIssue"&gt;
	&lt;core:arg type="com.atlassian.crowd.embedded.api.User" value="${jira.user}" /&gt;
	&lt;core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issue}" /&gt;
	&lt;core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${dispatchOption}" /&gt;
	&lt;core:arg type="boolean" value="false" /&gt;
&lt;/core:invoke&gt;
&lt;/JiraJelly&gt;

Note that I've used the component id as an argument to ProjectManager.getComponent. You can find the id of a component by clicking on the component and looking at the URL; for example: the URL for the OPS component that I defined was http://localhost:2990/jira/browse/ABC/component/10000, so the component id is 10000.

I didn't do the login thing, but you should be able to add that in just fine.

1 vote
David Pinn
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.
June 2, 2013

You need to call the store() method on the MutableIssue (MutableIssue inherits the store method from OfBizValueWrapper).

Note that, as of JIRA 5.0, the store() method is deprecated. The alternative is to use the IssueManager's updateIssue(...) method.

Justin Taylor June 2, 2013

Awesome thanks David, I did try the store method however it didnt work:

<core:invoke on="${issueKey}" method="store"/>

and the updateissue expects a parameter which i am not sure how to get access to: com.atlassian.crowd.embedded.api.User user

Justin Taylor June 2, 2013

Sorry I figured out the User but now I cant seem to figure out the EventDispatchOption eventDispatchOption

Justin Taylor June 2, 2013

Ok I figured out how to get the user, but my problem now is specifing the primitive boolean arg, it needs the primitive and not java.lang.Boolean?

<core:invoke on="${issueManager}" method="updateIssue">

<core:arg type="com.atlassian.crowd.embedded.api.User" value="${user}"/>

<core:arg type="com.atlassian.jira.issue.MutableIssue" value="${issueKey}"/>

<core:arg type="java.lang.Boolean" value="false"/>

</core:invoke>

Justin Taylor June 2, 2013

The only way i can think of doing it is :

<core:arg type="com.atlassian.jira.event.type.EventDispatchOption" value="${EventDispatchOption.DO_NOT_DISPATCH}"/>

but this wont work, keeps giving a null value.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events