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
Community moderators have prevented the ability to post new answers.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.