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

How to get Project Version Start Date from GreenHopper?

Matt Becker July 26, 2012

Hello,

I am trying to extract the start date of a project's version from GreenHopper for use in a plugin I am developing using the Java APIs. I have looked through the JIRA and GH APIs and have not found anything that seems to get the start date, only the release date for a specific version (releaseDate = version.getReleaseDate()). Below is a quick screenshot of the date I am referrring to and need to get for my plugin. The screenshot is from the Planning Board in the GreenHopper plugin:

I am not using the SOAP API or any SQL queries but only the JIRA and GreenHopper Java APIs.

Thanks

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
sclowes
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 27, 2012

Firstly, I wouldn't recommend that you use this information. The GreenHopper Rapid Board does not use this hierachical versions with GreenHopper maintained meta-data approach. As we intend the Rapid Board to be the future of GreenHopper using this information will bind your plugin to older versions of GreenHopper.

All that said, this is easily done through the GreenHopper service (i.e. the "GreenHopper Bootstrap Service", class com.pyxis.greenhopper.GreenHopper).

Here's some sample Groovy code (that you can run in the Script Runner plugin if you want to try it) that demonstrates getting the start date for all versions in project TST. Note that I'm manually getting the GreenHopper service because Groovy scripts need to do this, your Java code will use dependency injection

import com.atlassian.jira.ComponentManager
import com.atlassian.plugin.PluginAccessor
import com.atlassian.jira.bc.project.ProjectService

ComponentManager componentManager = ComponentManager.getInstance();
def jiraAuthenticationContext = componentManager.getJiraAuthenticationContext()

PluginAccessor pluginAccessor = componentManager.getPluginAccessor();
Class greenHopperClass = pluginAccessor.getClassLoader().findClass("com.pyxis.greenhopper.GreenHopper");
def greenHopper = componentManager.getOSGiComponentInstanceOfType(greenHopperClass);

ProjectService projectService = ComponentManager.getComponent(ProjectService.class);
def user = jiraAuthenticationContext.getUser()
def projectResult = projectService.getProjectByKey(user, "TST");

if (!projectResult.isValid())
   return;

def ghProjectConfig = greenHopper.getConfiguration(projectResult.getProject())
if (!ghProjectConfig)
   return;

for (def version in projectResult.getProject().getVersions())
{
   def startDate = ghProjectConfig.getVersionStartDate(version);
   println "Version id = " + version.getId() + " name = " + version.getName() +
           " start date = " + (startDate ? startDate : "none");
}

I'd recommend getting the GreenHopper source code to help you develop your plugin. The source code is available to all commercial licensees (i.e not starter licensed) through https://my.atlassian.com

Thanks,
Shaun

Matt Becker July 30, 2012

Hello,

Your code was helpful but I am not sure how to use dependcy injection to get the code to work with Java. I am having trouble figuring out how to get the Project Configuration to load correctly in your code. Here is the code I am using right now, project and version are appropriately determined variables:

        ComponentManager componentManager = ComponentManager.getInstance();
        JiraAuthenticationContext jiraAuthenticationContext = componentManager.getJiraAuthenticationContext();
    	 
    	PluginAccessor pluginAccessor = componentManager.getPluginAccessor();
    	ClassLoader greenHopperClassLoader = pluginAccessor.getClassLoader();
    	Class greenHopperClass = greenHopperClassLoader.loadClass("com.pyxis.greenhopper.GreenHopper");
    	    	 
    	Class<?> greenHopper = componentManager.getOSGiComponentInstanceOfType(greenHopperClass);
    	ProjectService projectService = ComponentManager.getComponent(ProjectService.class);
    	 
    	ProjectConfiguration ghProjectConfig = greenHopper.getConfiguration(project);
  
    	startDate = ghProjectConfig.getVersionStartDate(version);

I am not sure if I am using the right Object types for alot of the functions, and it is saying that ghProjectConfig
does not have a method getConfiguration().

Thanks

TAGS
AUG Leaders

Atlassian Community Events