dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29283
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14759: ER, limit option for aggregated values, e.g. show top 10, work in progress.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14759 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-04-09 13:47:40 +0200
message:
ER, limit option for aggregated values, e.g. show top 10, work in progress.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml
dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties
dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json
dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2014-04-04 14:06:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2014-04-09 11:45:21 +0000
@@ -105,6 +105,10 @@
public static final String NUMBER_FORMATTING_SPACE = "space";
public static final String NUMBER_FORMATTING_NONE = "none";
+ public static final int ASC = -1;
+ public static final int DESC = 1;
+ public static final int NONE = 0;
+
// -------------------------------------------------------------------------
// Persisted properties
// -------------------------------------------------------------------------
@@ -162,6 +166,10 @@
protected boolean rewindRelativePeriods;
protected String digitGroupSeparator;
+
+ protected int sortOrder;
+
+ protected int topLimit;
// -------------------------------------------------------------------------
// Analytical properties
@@ -765,6 +773,8 @@
itemOrganisationUnitGroups.clear();
rewindRelativePeriods = false;
digitGroupSeparator = NUMBER_FORMATTING_SPACE;
+ sortOrder = 0;
+ topLimit = 0;
}
@Override
@@ -798,6 +808,8 @@
itemOrganisationUnitGroups = object.getItemOrganisationUnitGroups();
rewindRelativePeriods = object.isRewindRelativePeriods();
digitGroupSeparator = object.getDigitGroupSeparator();
+ sortOrder = object.getSortOrder();
+ topLimit = object.getTopLimit();
}
}
@@ -1071,6 +1083,32 @@
this.digitGroupSeparator = digitGroupSeparator;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public int getSortOrder()
+ {
+ return sortOrder;
+ }
+
+ public void setSortOrder( int sortOrder )
+ {
+ this.sortOrder = sortOrder;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public int getTopLimit()
+ {
+ return topLimit;
+ }
+
+ public void setTopLimit( int topLimit )
+ {
+ this.topLimit = topLimit;
+ }
+
// -------------------------------------------------------------------------
// Transient properties
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java 2014-04-03 16:34:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java 2014-04-09 11:45:21 +0000
@@ -52,19 +52,20 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
/**
-* @author Lars Helge Overland
-*/
+ * @author Lars Helge Overland
+ */
public class EventReport
extends BaseAnalyticalObject
{
public static final String DATA_TYPE_AGGREGATED_VALUES = "aggregated_values";
+
public static final String DATA_TYPE_INDIVIDUAL_CASES = "individual_cases";
-
+
/**
* Program. Required.
*/
private Program program;
-
+
/**
* Program stage.
*/
@@ -74,27 +75,27 @@
* Start date.
*/
private Date startDate;
-
+
/**
* End date.
*/
private Date endDate;
-
+
/**
* Type of data, can be aggregated values and individual cases.
*/
private String dataType;
-
+
/**
* Dimensions to crosstabulate / use as columns.
*/
private List<String> columnDimensions = new ArrayList<String>();
-
+
/**
* Dimensions to use as rows.
*/
private List<String> rowDimensions = new ArrayList<String>();
-
+
/**
* Dimensions to use as filter.
*/
@@ -114,12 +115,12 @@
* Indicates rendering of empty rows for the table.
*/
private boolean hideEmptyRows;
-
+
/**
* The display density of the text in the table.
*/
private String displayDensity;
-
+
/**
* The font size of the text in the table.
*/
@@ -132,7 +133,7 @@
public EventReport()
{
}
-
+
public EventReport( String name )
{
this.name = name;
@@ -143,9 +144,10 @@
// -------------------------------------------------------------------------
@Override
- public void init( User user, Date date, OrganisationUnit organisationUnit, List<OrganisationUnit> organisationUnitsAtLevel,
- List<OrganisationUnit> organisationUnitsInGroups, I18nFormat format )
- {
+ public void init( User user, Date date, OrganisationUnit organisationUnit,
+ List<OrganisationUnit> organisationUnitsAtLevel, List<OrganisationUnit> organisationUnitsInGroups,
+ I18nFormat format )
+ {
}
@Override
@@ -155,18 +157,18 @@
{
columns.addAll( getDimensionalObjectList( column ) );
}
-
+
for ( String row : rowDimensions )
{
rows.addAll( getDimensionalObjectList( row ) );
}
-
+
for ( String filter : filterDimensions )
{
filters.addAll( getDimensionalObjectList( filter ) );
}
}
-
+
@Override
public void mergeWith( IdentifiableObject other )
{
@@ -175,7 +177,7 @@
if ( other.getClass().isInstance( this ) )
{
EventReport report = (EventReport) other;
-
+
program = report.getProgram();
programStage = report.getProgramStage();
startDate = report.getStartDate();
@@ -187,15 +189,15 @@
fontSize = report.getFontSize();
}
}
-
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Program getProgram()
{
return program;
@@ -208,8 +210,8 @@
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public ProgramStage getProgramStage()
{
return programStage;
@@ -221,8 +223,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Date getStartDate()
{
return startDate;
@@ -234,8 +236,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Date getEndDate()
{
return endDate;
@@ -247,8 +249,8 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getDataType()
{
return dataType;
@@ -260,9 +262,9 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlElementWrapper( localName = "columnDimensions", namespace = DxfNamespaces.DXF_2_0)
- @JacksonXmlProperty( localName = "column", namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "columnDimensions", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "column", namespace = DxfNamespaces.DXF_2_0 )
public List<String> getColumnDimensions()
{
return columnDimensions;
@@ -274,9 +276,9 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlElementWrapper( localName = "rowDimensions", namespace = DxfNamespaces.DXF_2_0)
- @JacksonXmlProperty( localName = "row", namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "rowDimensions", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "row", namespace = DxfNamespaces.DXF_2_0 )
public List<String> getRowDimensions()
{
return rowDimensions;
@@ -288,9 +290,9 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
- @JacksonXmlElementWrapper( localName = "filterDimensions", namespace = DxfNamespaces.DXF_2_0)
- @JacksonXmlProperty( localName = "filter", namespace = DxfNamespaces.DXF_2_0)
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "filterDimensions", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "filter", namespace = DxfNamespaces.DXF_2_0 )
public List<String> getFilterDimensions()
{
return filterDimensions;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2014-03-31 17:44:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2014-04-09 11:45:21 +0000
@@ -101,10 +101,6 @@
public static final String FONT_SIZE_LARGE = "large";
public static final String FONT_SIZE_NORMAL = "normal";
public static final String FONT_SIZE_SMALL = "small";
-
- public static final int ASC = -1;
- public static final int DESC = 1;
- public static final int NONE = 0;
public static final NameableObject[] IRT = new NameableObject[0];
public static final NameableObject[][] IRT2D = new NameableObject[0][];
@@ -155,16 +151,6 @@
private ReportParams reportParams;
/**
- * The sort order based on the last column of the table, 0 if none.
- */
- private int sortOrder;
-
- /**
- * Indicates whether the table should be limited from top, 0 if none.
- */
- private int topLimit;
-
- /**
* Indicates rendering of sub-totals for the table.
*/
private boolean totals;
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml 2014-03-31 17:44:03 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml 2014-04-09 11:45:21 +0000
@@ -114,7 +114,11 @@
<property name="displayDensity" />
- <property name="fontSize" />
+ <property name="fontSize" />
+
+ <property name="sortOrder" />
+
+ <property name="topLimit" />
<!-- Access properties -->
<property name="externalAccess" />
=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties 2014-03-26 15:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties 2014-04-09 11:45:21 +0000
@@ -152,4 +152,7 @@
sum=Sum
by_data_element=By data element
relative_periods=Relative periods
-start_end_dates=Start-end dates
\ No newline at end of file
+start_end_dates=Start-end dates
+top=Top
+bottom=Bottom
+limit=Limit
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json 2014-03-26 15:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json 2014-04-09 11:45:21 +0000
@@ -152,5 +152,8 @@
"sum",
"by_data_element",
"relative_periods",
-"start_end_dates"
+"start_end_dates",
+"top",
+"bottom",
+"limit"
]
=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js 2014-04-08 15:07:02 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js 2014-04-09 11:45:21 +0000
@@ -753,6 +753,98 @@
});
}());
+ // sort, limit
+ (function() {
+ Ext.define('Ext.ux.container.LimitContainer', {
+ extend: 'Ext.container.Container',
+ alias: 'widget.limitcontainer',
+ layout: 'hbox',
+ onCheckboxChange: function(value) {
+ this.sortOrderCmp.setDisabled(!value);
+ this.topLimitCmp.setDisabled(!value);
+ },
+ getSortOrder: function() {
+ return this.activateCmp.getValue() ? this.sortOrderCmp.getValue() : 0;
+ },
+ getTopLimit: function() {
+ return this.activateCmp.getValue() ? this.topLimitCmp.getValue() : 0;
+ },
+ setValues: function(sortOrder, topLimit) {
+ sortOrder = parseInt(sortOrder);
+ topLimit = parseInt(topLimit);
+
+ if (Ext.isNumber(sortOrder)) {
+ this.sortOrderCmp.setValue(sortOrder);
+ }
+ else {
+ this.sortOrderCmp.reset();
+ }
+
+ if (Ext.isNumber(topLimit)) {
+ this.topLimitCmp.setValue(topLimit);
+ }
+ else {
+ this.topLimitCmp.reset();
+ }
+
+ this.activateCmp.setValue(!!(sortOrder > 0 && topLimit > 0));
+ },
+ initComponent: function() {
+ var container = this;
+
+ this.activateCmp = Ext.create('Ext.form.field.Checkbox', {
+ boxLabel: container.boxLabel,
+ width: 135,
+ style: 'margin-bottom:4px',
+ listeners: {
+ change: function(cmp, newValue) {
+ container.onCheckboxChange(newValue);
+ }
+ }
+ });
+
+ this.sortOrderCmp = Ext.create('Ext.form.field.ComboBox', {
+ cls: 'ns-combo',
+ style: 'margin-bottom:3px',
+ width: 70,
+ queryMode: 'local',
+ valueField: 'id',
+ editable: false,
+ value: container.sortOrder,
+ store: Ext.create('Ext.data.Store', {
+ fields: ['id', 'text'],
+ data: [
+ {id: '-1', text: NS.i18n.bottom},
+ {id: '1', text: NS.i18n.top}
+ ]
+ })
+ });
+
+ this.topLimitCmp = Ext.create('Ext.form.field.Number', {
+ width: 56,
+ style: 'margin-left:1px',
+ minValue: 1,
+ maxValue: 10000,
+ value: container.topLimit,
+ allowBlank: false
+ });
+
+ this.items = [
+ this.activateCmp,
+ this.sortOrderCmp,
+ this.topLimitCmp
+ ];
+
+ this.callParent();
+ },
+ listeners: {
+ render: function() {
+ this.onCheckboxChange(false);
+ }
+ }
+ });
+ }());
+
// constructors
AggregateLayoutWindow = function() {
@@ -1462,6 +1554,12 @@
checked: true
});
+ limit = Ext.create('Ext.ux.container.LimitContainer', {
+ boxLabel: NS.i18n.limit,
+ sortOrder: 1,
+ topLimit: 10
+ });
+
showHierarchy = Ext.create('Ext.form.field.Checkbox', {
boxLabel: NS.i18n.show_hierarchy,
style: 'margin-bottom:4px'
@@ -1549,7 +1647,8 @@
items: [
showTotals,
showSubTotals,
- hideEmptyRows
+ hideEmptyRows,
+ limit
//aggregationType
]
};
@@ -1586,6 +1685,8 @@
showTotals: showTotals.getValue(),
showSubTotals: showSubTotals.getValue(),
hideEmptyRows: hideEmptyRows.getValue(),
+ sortOrder: limit.getSortOrder(),
+ topLimit: limit.getTopLimit(),
showHierarchy: showHierarchy.getValue(),
displayDensity: displayDensity.getValue(),
fontSize: fontSize.getValue(),
@@ -1597,6 +1698,7 @@
showTotals.setValue(Ext.isBoolean(layout.showTotals) ? layout.showTotals : true);
showSubTotals.setValue(Ext.isBoolean(layout.showSubTotals) ? layout.showSubTotals : true);
hideEmptyRows.setValue(Ext.isBoolean(layout.hideEmptyRows) ? layout.hideEmptyRows : false);
+ limit.setValues(layout.sortOrder, layout.topLimit);
//aggregationType.setValue(Ext.isString(layout.aggregationType) ? layout.aggregationType : 'default');
showHierarchy.setValue(Ext.isBoolean(layout.showHierarchy) ? layout.showHierarchy : false);
displayDensity.setValue(Ext.isString(layout.displayDensity) ? layout.displayDensity : 'normal');
@@ -1679,6 +1781,7 @@
w.showTotals = showTotals;
w.showSubTotals = showSubTotals;
w.hideEmptyRows = hideEmptyRows;
+ w.limit = limit;
w.showHierarchy = showHierarchy;
w.displayDensity = displayDensity;
w.fontSize = fontSize;
@@ -4523,7 +4626,7 @@
rows = [],
filters = [];
- view.dataType = layoutWindow.dataType;
+ view.dataType = dataType;
view.program = program.getRecord();
view.programStage = stage.getRecord();
@@ -4608,12 +4711,6 @@
view.filters = filters;
}
- // paging
- view.paging = {
- page: ns.app.statusBar.getCurrentPage(),
- pageSize: 100
- };
-
return view;
};
@@ -5120,57 +5217,31 @@
web.report = web.report || {};
web.report.getLayoutConfig = function() {
- var map = {},
- type = ns.app.typeToolbar.getType(),
- view = ns.app.widget.getView(),
+ var view = ns.app.widget.getView(),
options = ns.app.optionsWindow.getOptions();
- map.aggregate = function() {
- var columnDimNames = ns.app.aggregateLayoutWindow.colStore.getDimensionNames(),
- rowDimNames = ns.app.aggregateLayoutWindow.rowStore.getDimensionNames(),
- filterDimNames = ns.app.aggregateLayoutWindow.filterStore.getDimensionNames();
-
- view.columns = [];
- view.rows = [];
- view.filters = [];
-
- for (var i = 0, dimNameArrays = [columnDimNames, rowDimNames, filterDimNames], axes = [view.columns, view.rows, view.filters], dimNameArray; i < dimNameArrays.length; i++) {
- dimNameArray = dimNameArrays[i];
-
- for (var j = 0, dimName; j < dimNameArray.length; j++) {
- dimName = dimNameArray[j];
-
- axes[i].push({
- dimension: dimName
- });
- }
- }
-
- return view;
- };
-
- map.query = function() {
- var columnDimNames = ns.app.queryLayoutWindow.colStore.getDimensionNames();
-
- view.columns = [];
-
- for (var i = 0; i < columnDimNames.length; i++) {
- view.columns.push({
- dimension: columnDimNames[i]
- });
- }
-
- return view;
- };
-
if (!view) {
return;
}
Ext.applyIf(view, options);
- view.type = type;
-
- //return map[type]();
+
+ if (view.dataType === 'aggregated_values') {
+ if (view.sortOrder && view.topLimit) {
+ view.sorting = {
+ id: 1,
+ direction: view.sortOrder > 0 ? 'DESC' : 'ASC'
+ };
+ }
+ }
+
+ if (view.dataType === 'individual_cases') {
+ view.paging = {
+ page: ns.app.statusBar.getCurrentPage(),
+ pageSize: 100
+ };
+ }
+
return view;
};
=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js 2014-04-08 13:19:05 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js 2014-04-09 11:45:21 +0000
@@ -1738,6 +1738,11 @@
// hierarchy
paramString += view.showHierarchy ? '&hierarchyMeta=true' : '';
+ // limit
+ if (view.dataType === 'aggregated_values' && (view.sortOrder && view.topLimit)) {
+ paramString += '&limit=' + view.topLimit + '&sortOrder=' + (view.sortOrder < 0 ? 'ASC' : 'DESC');
+ }
+
// sorting
if (view.dataType === 'individual_cases' && view.sorting) {
if (view.sorting.id && view.sorting.direction) {