Skip to content

JIRA-71: Pie chart macro should allow custom fields #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.contrib.jira.charts;

public class JiraFieldParameterDisplayer
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
package org.xwiki.contrib.jira.charts.bidimensionalgrid;

import org.xwiki.contrib.jira.charts.AbstractChartMacroParameters;
import org.xwiki.contrib.jira.charts.JiraFieldParameterDisplayer;
import org.xwiki.properties.annotation.PropertyDescription;
import org.xwiki.properties.annotation.PropertyDisplayType;
import org.xwiki.properties.annotation.PropertyMandatory;
import org.xwiki.stability.Unstable;

Expand All @@ -33,8 +35,8 @@
@Unstable
public class JIRABiDimensionalGridChartMacroParameter extends AbstractChartMacroParameters
{
private JIRAField xAxisField;
private JIRAField yAxisField;
private String xAxisField;
private String yAxisField;
private int numberOfResults;
private boolean isSortAscending;
private boolean isSortNatural;
Expand All @@ -52,7 +54,7 @@ public JIRABiDimensionalGridChartMacroParameter()
/**
* @return represents the field information to be displayed in each column.
*/
public JIRAField getxAxisField()
public String getxAxisField()
{
return xAxisField;
}
Expand All @@ -62,15 +64,16 @@ public JIRAField getxAxisField()
*/
@PropertyDescription("The field information to be displayed in each column.")
@PropertyMandatory
public void setxAxisField(JIRAField xAxisField)
@PropertyDisplayType(JiraFieldParameterDisplayer.class)
public void setxAxisField(String xAxisField)
{
this.xAxisField = xAxisField;
}

/**
* @return represents the field information to be displayed in each row.
*/
public JIRAField getyAxisField()
public String getyAxisField()
{
return yAxisField;
}
Expand All @@ -80,7 +83,7 @@ public JIRAField getyAxisField()
*/
@PropertyDescription("The field information to be displayed in each row.")
@PropertyMandatory
public void setyAxisField(JIRAField yAxisField)
public void setyAxisField(String yAxisField)
{
this.yAxisField = yAxisField;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public JIRAURLHelper.GadgetType getGadgetType()
public List<NameValuePair> getCustomQueryParameters(JIRABiDimensionalGridChartMacroParameter parameters)
{
List<NameValuePair> result = new ArrayList<>();
result.add(new BasicNameValuePair("xstattype", parameters.getxAxisField().getQueryName()));
result.add(new BasicNameValuePair("ystattype", parameters.getyAxisField().getQueryName()));
result.add(new BasicNameValuePair("xstattype", parameters.getxAxisField()));
result.add(new BasicNameValuePair("ystattype", parameters.getyAxisField()));
String sortDirection = (parameters.isSortAscending()) ? "asc" : "desc";
result.add(new BasicNameValuePair("sortDirection", sortDirection));
String sortBy = (parameters.isSortNatural()) ? "natural" : "total";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.http.message.BasicNameValuePair;
import org.xwiki.component.annotation.Component;
import org.xwiki.contrib.jira.charts.internal.AbstractJIRAChartDataFetcher;
import org.xwiki.contrib.jira.charts.piechart.StatisticType;
import org.xwiki.contrib.jira.charts.internal.piechart.source.JIRAPieChartDataSource;
import org.xwiki.contrib.jira.charts.piechart.JIRAPieChartMacroParameters;
import org.xwiki.contrib.jira.macro.internal.JIRAURLHelper;
Expand All @@ -46,9 +45,7 @@ public class JIRAPieChartDataFetcher
@Override
public List<NameValuePair> getCustomQueryParameters(JIRAPieChartMacroParameters parameters)
{
StatisticType type = parameters.getType();
String statType = type.getQueryName();
return List.of(new BasicNameValuePair("statType", statType));
return List.of(new BasicNameValuePair("statType", parameters.getType()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
package org.xwiki.contrib.jira.charts.piechart;

import org.xwiki.contrib.jira.charts.AbstractChartMacroParameters;
import org.xwiki.contrib.jira.charts.JiraFieldParameterDisplayer;
import org.xwiki.properties.annotation.PropertyAdvanced;
import org.xwiki.properties.annotation.PropertyDescription;
import org.xwiki.properties.annotation.PropertyDisplayType;
import org.xwiki.properties.annotation.PropertyMandatory;
import org.xwiki.stability.Unstable;

Expand All @@ -34,7 +36,7 @@
@Unstable
public class JIRAPieChartMacroParameters extends AbstractChartMacroParameters
{
private StatisticType type;
private String type;
private int maxData;

/**
Expand All @@ -48,7 +50,7 @@ public JIRAPieChartMacroParameters()
/**
* @return the type of statistics to display in the pie chart.
*/
public StatisticType getType()
public String getType()
{
return type;
}
Expand All @@ -58,7 +60,8 @@ public StatisticType getType()
*/
@PropertyDescription("The type of statistics to display in the pie chart.")
@PropertyMandatory
public void setType(StatisticType type)
@PropertyDisplayType(JiraFieldParameterDisplayer.class)
public void setType(String type)
{
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@ rendering.macro.jiraPieChart.parameter.type.description=The type of statistics t
rendering.macro.jiraPieChart.parameter.maxData.name=Data size
rendering.macro.jiraPieChart.parameter.maxData.description=The maximum number of data to display in the pie chart: if there's more data they will be displayed aggregated.

rendering.macro.jiraPieChart.labels.otherData=Other data
rendering.macro.jiraPieChart.labels.otherData=Other data

rendering.macro.charts.JiraFieldDisplayer.placeholder=Chose a JIRA field
rendering.macro.charts.JiraFieldDisplayer.field.assignee=Assignee
rendering.macro.charts.JiraFieldDisplayer.field.reporter=Reporter
rendering.macro.charts.JiraFieldDisplayer.field.status=Status
rendering.macro.charts.JiraFieldDisplayer.field.fixversion=Fix Version
rendering.macro.charts.JiraFieldDisplayer.field.component=Component
rendering.macro.charts.JiraFieldDisplayer.field.priority=Priority
rendering.macro.charts.JiraFieldDisplayer.field.type=Type
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## ---------------------------------------------------------------------------
## See the NOTICE file distributed with this work for additional
## information regarding copyright ownership.
##
## This is free software; you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as
## published by the Free Software Foundation; either version 2.1 of
## the License, or (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this software; if not, write to the Free
## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
## 02110-1301 USA, or see the FSF site: http://www.fsf.org.
## ---------------------------------------------------------------------------
#set ($knownJiraFields = [
{'name': 'assignee', 'value': 'assignees'},
{'name': 'reporter', 'value': 'reporter'},
{'name': 'status', 'value': 'statuses'},
{'name': 'fixversion', 'value': 'allFixfor'},
{'name': 'component', 'value': 'components'},
{'name': 'priority', 'value': 'priorities'},
{'name': 'type', 'value': 'issuetype'}
])

#macro (jiraFieldPicker_displayOptions $selectedValues)
#foreach ($field in $knownJiraFields)
<option value="$!escapetool.xml($field.value)"#if ($selectedValues.contains($field.value)) selected="selected"#end>
$!escapetool.xml($services.localization.render("rendering.macro.charts.JiraFieldDisplayer.field.$field.name"))
</option>
#end
#end

#set ($discard = $xwiki.jsfx.use('uicomponents/suggest/xwiki.selectize.js', true))
## See https://github.com/selectize/selectize.js/blob/master/docs/usage.md#configuration
#set ($selectizeSettings = {})
#set ($suggestInputAttributes = {
'name': 'jiraField',
'class': 'xwiki-selectize',
'data-xwiki-selectize': $selectizeSettings,
'value': 'issuetype',
'placeholder': $services.localization.render('rendering.macro.charts.JiraFieldDisplayer.placeholder'),
'create': true
})
#picker_import
#suggestInput($suggestInputAttributes 'jiraFieldPicker_displayOptions')
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ void fetch() throws Exception
JIRABiDimensionalGridChartMacroParameter parameters = new JIRABiDimensionalGridChartMacroParameter();
parameters.setId("myjira");
parameters.setFilterId("43434");
parameters.setxAxisField(JIRAField.STATUS);
parameters.setyAxisField(JIRAField.ASSIGNEE);
parameters.setxAxisField("statuses");
parameters.setyAxisField("assignees");
parameters.setSortNatural(true);
parameters.setNumberOfResults(21);
parameters.setSortAscending(false);
Expand Down