[TIME-119] Timesheet report does not work with CustomFields implementing CustomFieldStattable

Issue #119 resolved
Andriy Zhdanov created an issue

First of all thanks for the amazing plugin.

I am using a customField in the group by for the timesheet report. The customField is from another plugin ( Jira Database Values Plugin).

The JDVP plugin code can be checked out here:
svn co https://studio.plugins.atlassian.com/svn/JDVP/tags/database-values-plugin-1.1.1/

The Jira Database Values Plugin (JDVP) stores the primary key of a field directly into the custom field, though what is displayed in reports is defined by rendering patterns supplied to the JDVP via a properties. It looks like there is an interface (CustomFieldStattable) created by Atlassian for rendering the values of CustomFields in reports ( Atlassian uses this in their Two Dimensional Filter Statistics Gadget).

The Time Sheet report is pulling the raw value directly out of the custom field. In the case where the CustomField type has implemented CustomFieldStattable, we don't end up with the values we want , we end up with the raw value.

Here's an example of the interface being implemented in the JDVP plugin:

./src/main/java/org/deblauwe/jira/plugin/databasevalues/DatabaseValuesSearcher.java:94

It looks like the Time Sheet Report is pulling the values from the CustomField on line 138 of TextUtil.java

./src/main/java/com/fdu/jira/util/TextUtil.java:138

There is a check to see if our groupBy field is a CustomField. It think there needs to be a check to see if the CustomField implements Stattable so we can invoke getStatisticsMapper() and return the text based on the raw value.

Thanks

Michael

By michael.kinsley/Michael Kinsley on Wed, 17 Nov 2010 15:25:35 -0800

Comments (4)

  1. Andriy Zhdanov reporter

    Sorry, I can't get what is to be displayed/grouped-by with StatisticsMapper, it does not have value. Please elaborate.

    By azhdanov on Thu, 25 Nov 2010 04:38:46 -0800

  2. Andriy Zhdanov reporter

    The value stored directly in the customField may not be directly what should be displayed or reported on. Atlassian provided an interface to handle this case "CustomFieldStattable" .

    I'm not a Java programmer (sorry I can't be more helpful here), so please take this with a grain of salt, but it looks like you would want to do that following:

    1. check if customField implements the CutomFieldStattable interfaces.
    2. If yes, then invoke customFieldObj.getStatisticsMapper() to get a StatisticsMapper object
    3. Then invoke statisticsMapperObj.getValueFromLuceneField() to get the value that should be used in reporting or calculations.

    Here's a link to the StatisticsMapper docs.

    http://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/statistics/StatisticsMapper.html

    By michael.kinsley on Mon, 29 Nov 2010 11:28:03 -0800

  3. Andriy Zhdanov reporter

    Thank you for bringing light, even not being java programmer you've helped

    So I've just added it, however I can't verify how it works, so I'd appreciate your feedback.

    You need to re-install plugin version 2.0

    And sorry for delay.

    // Committed revision 156817

    By azhdanov on Fri, 17 Dec 2010 14:20:20 -0800

  4. Log in to comment