Hello,
I am developing a report plugin on JIRA.
Before generating the report, the method 'generateReportHtml(ProjectActionSupport action, Map params)' is called. The parameter 'params' contains information given by users (i.e start date, project id, filter...).
My goal is to add new fields that would permit to gather more informations from users.
I have tried to edit 'atlassian-plugin.xml' (<property> tag) and 'report.properties' files but I didn't manage to add new fields.
Could you, please, give me a hand?
Community moderators have prevented the ability to post new answers.
Ok, we found out how to resolve this issue: restart the server before uploading the new plugin.
We don't know yet if the server is keeping a copy of the 'atlassian-plugin.xml' file or if it's a versioning problem or something like that... If we modify the source code in Java, we don't need to restart the server.
Steps I followed: execute the 3 'atlas-xxx' commands, uninstall current plugin on Jira, upload the new one, refresh the page of the project and test the report.
Thank you for your help! :)
This works, it is an unfortunate workaround though. There seem to be too many little glitches like these with the Atlassian SDK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We did found a solution, which doesn't require to restart JIRA instance
The problem is that on first load of report configuration page JIRA load's configuration from ObjectConfigurationFactory, which keeps all report configs in memory and does not invalidate them on reload of plugin, so I've wrote small code snippet, which manually reloads all of the descriptors. It require some Java Reflections magic to get all the required fields, but it works. Use at your own risk btw
import com.atlassian.configurable.ObjectConfigurationFactory; import com.atlassian.configurable.ObjectDescriptor; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.plugin.AbstractConfigurableModuleDescriptor; import com.atlassian.jira.plugin.report.ReportModuleDescriptor; import com.atlassian.jira.user.ApplicationUser; import com.atlassian.plugin.Plugin; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; void reloadReportParameters() { Collection<Plugin> pluginList = ComponentAccessor.getPluginAccessor().getEnabledPlugins(); ObjectConfigurationFactory objectConfigurationFactory = ComponentAccessor.getComponent(ObjectConfigurationFactory.class); Collection<ReportModuleDescriptor> reportModuleDescriptors = new ArrayList<>(); for (Plugin plugin : pluginList) { reportModuleDescriptors.addAll(getReportDescriptors(plugin)); } List<ReloadedReportParametersInfo> reloadedReportParametersInfoList = new ArrayList<>(); for (ReportModuleDescriptor descriptor : reportModuleDescriptors) { Element element = getFieldValue(AbstractConfigurableModuleDescriptor.class, "element", descriptor); ObjectDescriptor objectDescriptor = getFieldValue(AbstractConfigurableModuleDescriptor.class, "objectDescriptor", descriptor); objectConfigurationFactory.loadObjectConfigurationFromElement(element, objectDescriptor, descriptor.getCompleteKey(), descriptor.getPlugin().getClassLoader()); } } private <T, P> T getFieldValue(Class<? extends P> clazz, String fieldName, P object) throws NoSuchFieldException, IllegalAccessException { Field field = clazz.getDeclaredField(fieldName); boolean accessibility = field.isAccessible(); field.setAccessible(true); T value = ((T) field.get(object)); field.setAccessible(accessibility); return value; } private Collection<ReportModuleDescriptor> getReportDescriptors(Plugin plugin) { return plugin.getModuleDescriptors().stream() .filter(descriptor -> descriptor instanceof ReportModuleDescriptor) .map(descriptor -> ((ReportModuleDescriptor) descriptor)) .collect(Collectors.toList()); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I searched in the whole project folder and found 2 'atlassian-plugin.xml', but the 2nd one is in <project>\target\classes (which is created after doing 'atlas-package', I think). If I delete it, I can't load the plugin on Jira.
After I have modified the code, I execute 'atlas-clean', then 'atlas-compile', then 'atlas-package'. I can't use 'atlas-run' because of maven configuration...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That sounds correct to me, but what I'm trying to get at is that in your running Jira, I'm not sure you are looking at the right report - an older version of it could be obscuring your code.
Atlas-run should work fine, but I'm not going to get into debugging that here. Once you've run atlas-package, then what do you do? There's several more steps needed before you can get to a report, so we're wondering if you're following all of them, or if there's something in one of them going wrong.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. Yes
2. 3. It doesn't change anything :/
There is something weird: if all <property> in <properties> are deleted, there are still the 3 fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The only time I can think I've seen these symptoms was when I was looking at completely the wrong report. I'd copied a report plugin with the intention of expanding it, changed the name slightly and could not work out why my new parameters would not change. Took ages to realise the old plugin was still in place, and it was still taking me to that.
Could this have happened here? Could you describe the steps you take after you've modified the code? (e.g. atlas-clean; atlas-run)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic!
After a full restart, the report configuration screen is still the same:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, so your new property is fully enclosed between the <properties> tags in the xml, same as the other three fields? (That's something I've done before - it compiled and worked, and didn't display my fields because they were correct, but in totally the wrong place, so it ignored them)
I also have a vague memory about errors in one field stopping the rest appearing - could you try moving the missing field definition up, so it falls between endDate and startDate (temporarily of course - this is just to see if it changes the behaviour)
Finally, the field is defined as select, but is missing it's <values> tag - could you add something in there? Even if it's just the same class line you've got for the interval field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would like to add a new to field (a TextField in HTML) so that an user can give information before generating the report. I add these properties in 'atlassian-plugin.xml' file:
<property> <key>test</key> <name>test.label</name> <description>test.description</description> <type>select</type> </property>
I also modified the 'report.properties' file:
test.label = Test label test.description = Test description
But nothing happened. Do you know if there is an other file to modify?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, if you've got that property in atlassian-plugin.xml, then I'd expect them to appear.
Can you tell us exactly what you DO see on the report configuration screen at the moment? (Also, could you be 100% clean - restart your development Jira - sometimes it seems to need a full restart to pick up code changes, despite the fast-dev settings)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd like to add a new field, so that a user can give informations before generating the report, so I put a new tag, but nothing happened:
<property> <key>test</key> <name>test.label</name <description>test.description</description> <type>select</type> </property>
I also add these properties in the 'report.properties' file:
stop.label = End date stop.description = End date for report start.label = Start date start.description = Start date for report interval.label = Interval interval.description = Issue statusses measurements interval test.label = Test label test.description = Test description
Do you know if there is an other file to modify?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Christian, that looks right. What problem are you having? Where are you expecting to see the fields?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert, thanks for answering :)
Here is the report module:
<report key="reportIssuesCumulative" name="Example: group by report extended" class="com.thalesgroup.nl.jira.plugins.reports.cumulativestatusses.CumulativeStatussesChartPlugin"> <description key="report.singlelevelgroupby.description">i18n description</description> <resource type="velocity" name="view" location="templates/chart.vm"/> <resource type="i18n" name="i18n" location="properties/report"/> <label key="report.singlelevelgroupby.label.extended"/> <properties> <property> <key>endDate</key> <name>stop.label</name> <description>stop.description</description> <type>select</type> </property> <property> <key>startDate</key> <name>start.label</name> <description>start.description</description> <type>date</type> </property> <property> <key>interval</key> <name>interval.label</name> <description>intervale.description</description> <type>select</type> <values class="com.thalesgroup.nl.jira.plugins.reports.cumulativestatusses.IntervalTypeValuesGenerator"/> </property> </properties> </report>
I tried to delete these 3 properties but it didn't change anything: the fields are still there!
Also, I have only 1 .vm file: which one permits to 'draw' the result of the report (a chart).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From the sound of it, you're starting out right. Can you post your report module from atlassian-plugin.xml?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.