Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Version creation

SuhailM July 10, 2013

Hi,

i am using this below API to create a version in the project-

versionService.validateCreateVersion(project.getLead(), project, oldVersion.getName(), oldVersion.getReleaseDate(), oldVersionDescription, oldVersion.getSequence());

If you see the documentation -

Open Declaration CreateVersionValidationResult com.atlassian.jira.bc.project.version.VersionService.validateCreateVersion(User user, Project project, String versionName, Date releaseDate, String description, Long scheduleAfterVersion)
<dl><dt>Parameters:</dt><dd>user The user trying to create a version</dd><dd>project The project object containing requested version</dd><dd>versionName The name of created version</dd><dd>releaseDate The release date for a version (optional)</dd><dd>description The description for a version (optional)</dd><dd>scheduleAfterVersion The version after which created version should be scheduled (optional)</dd><dt>Returns:</dt><dd>CreateVersionValidationResult object</dd><dd></dd><dd></dd><dd></dd><dd></dd><dd>==========================================</dd><dd>My question -</dd><dd></dd><dd>As you see scheduleAfterVersion is optional , i dont have this value now and if try to send it null it throws null pointer exception in com.atlassian.jira.project.version.DefaultVersionManager.moveVersionSequences method</dd><dd>What value do i need send when i dont have scheduleAfterVersion paramer.</dd><dd></dd><dd>I am using JIRA 5.0.3 now.</dd><dd></dd><dd>Could you please tell me what optional value i need to pass here??</dd><dd>
</dd></dl>

9 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
SuhailM July 14, 2013

Hi,

I solved the problem by added new bunch of code.

Thanks a lot.

Regards,

Mir

Dipti Ranjan Behera
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.
July 14, 2013

@Mir,

Can share your solution (logic) :)

0 votes
SuhailM July 14, 2013

Hi,

The logic was the same where i create a project, create the version then move the issues to new project.

While setting the issues with the version i used the following to get version-

public static Object find(Collection collection, Predicate predicate)

Override evaluate method which checks for version name and returns version object.

Once the you have collected the versions then put that list in the parameter-

issue.setFixVersions(newVersionList)

0 votes
SuhailM July 11, 2013

As you see.. the fix version field is filled but when i open edit issue screen then it does nto appear in the pop screen.

ANy idea which code it runs when edit issue pop up screen comes?

Dipti Ranjan Behera
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.
July 11, 2013

@Mir,

Please check this thing carefully :

1. this fix version named 'sprint ' is present which project "LETSTALKFOLLOWUP" or "LETSTALK".

2. When you are setting the fixversion ? after moving the issue or before moving.

3. If above two points are positive , then comment the move issue code in your plugin.

let the code work till version creation then after do the move issue thing manually , see what happens with fixversion.

0 votes
SuhailM July 11, 2013

0 votes
SuhailM July 11, 2013

q1) Null is working fine.Version are created in new project.OK

q2) i did system re indexing but the fix version value value comes empty in edit issue pop up.. even though its there in db as i see it comes in even issue navigator.

Dipti Ranjan Behera
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.
July 11, 2013

@mir,

can post a screen shot of view screen and edit screen , if possible.

0 votes
SuhailM July 11, 2013

q1) i can manage with null as i have no data to find the versions.

q2) Yes, version and issue are of same proejct. in fact i see the FixVersion Value in issue view page but when i click on Edit Issue pop up comes up and the fixVersion field is empty .

Dipti Ranjan Behera
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.
July 11, 2013

@mir,

q1) Null is allowed as JiRA is also sending null in the API call. please re-check again if you are really sending null as param in it.

q2) re-index jira , then see if happens .

if re-indexing does the trick , then write a piece of re-index code in issue creation method.

0 votes
Dipti Ranjan Behera
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.
July 11, 2013

@Mir,

what is ScheduleAfterVersion parameter ?

In create version UI in JIra , you can reorder the versions by dragging to a particular position.

if thru code , you are creating a version and want to put in a particular position among the versions then scheduleafterversion will have versionid for the version after which you want to position your newly created version.

check for more details(read 'reschedule a version') : https://confluence.atlassian.com/display/JIRA/Managing+Versions

Regarding q-2,

see if the version and issue are of same project.

0 votes
SuhailM July 11, 2013

Hi,

OK. i checked i found that -

versionService.validateCreateVersion(project.getLead(), project, oldVersion.getName(), oldVersion.getReleaseDate(), oldVersionDescription, oldVersion.getSequence());

oldVersion.getSequence() was giving not null and it was throwing a exception.

But do u have any idea wat "Long scheduleAfterVersion" param all abt?

What if i dont want to pass "null" and send some proper value , any APi which gives this value for scheduleAfterVersion?

Or is something from GreenHopper as i am still using JIRA 5.0.3?

2. As i sent a null the sprint created in a new project along with the moved issue.But when i edit the issue i dont see the value of fix version say "sprint 1" assigned in the pop editor of the issue where as it is available in the issue view screen but the values are lost in the edit issue pop up and need to be re assigned again.

0 votes
Dipti Ranjan Behera
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.
July 10, 2013

Hi @Mir,

in the javadocs : https://docs.atlassian.com/jira/5.0-rc5/com/atlassian/jira/bc/project/version/VersionService.html

there are two validateCreateVersion() method : difference is in value of release date . one carries String and other carries Date object.

JiRA themselves validate the version creation by calling the method with release date as string.

But still they allow null in scheduleAfterVersion paramer .

But null pointer is coming in moveVersionSequences method , which gets called if the ScheduleAfterVersion paramer is not null.

Please check the parameters values you are sending.

You can see yourself , by debugging class com.atlassian.jira.project.version.DefaultVersionManager in jira source code


Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events