dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10963
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3028: Proper sorting of web pivot table
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3028 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-03-14 20:34:32 +0100
message:
Proper sorting of web pivot table
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTable.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java
--
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/pivottable/PivotTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTable.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/pivottable/PivotTable.java 2011-03-14 19:34:32 +0000
@@ -32,7 +32,7 @@
import java.util.List;
import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
-import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
@@ -42,7 +42,7 @@
*/
public class PivotTable
{
- private List<Indicator> indicators = new ArrayList<Indicator>();
+ private List<? extends IdentifiableObject> indicators = new ArrayList<IdentifiableObject>();
private List<Period> periods = new ArrayList<Period>();
@@ -62,12 +62,12 @@
// Getters and setters
// -------------------------------------------------------------------------
- public List<Indicator> getIndicators()
+ public List<? extends IdentifiableObject> getIndicators()
{
return indicators;
}
- public void setIndicators( List<Indicator> indicators )
+ public void setIndicators( List<? extends IdentifiableObject> indicators )
{
this.indicators = indicators;
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java 2011-01-06 22:22:18 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/pivottable/impl/DefaultPivotTableService.java 2011-03-14 19:34:32 +0000
@@ -31,17 +31,23 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.period.comparator.AscendingPeriodComparator;
import org.hisp.dhis.pivottable.PivotTable;
import org.hisp.dhis.pivottable.PivotTableService;
import org.hisp.dhis.system.util.ConversionUtils;
@@ -53,6 +59,10 @@
public class DefaultPivotTableService
implements PivotTableService
{
+ private static final Comparator<IdentifiableObject> INDICATOR_COMPARATOR = new IdentifiableObjectNameComparator();
+ private static final Comparator<OrganisationUnit> ORGUNIT_COMPARATOR = new OrganisationUnitNameComparator();
+ private static final Comparator<Period> PERIOD_COMPARATOR = new AscendingPeriodComparator();
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -127,6 +137,10 @@
pivotTable.setOrganisationUnits( organisationUnits );
pivotTable.setIndicatorValues( indicatorValues );
+ Collections.sort( pivotTable.getIndicators(), INDICATOR_COMPARATOR );
+ Collections.sort( pivotTable.getOrganisationUnits(), ORGUNIT_COMPARATOR );
+ Collections.sort( pivotTable.getPeriods(), PERIOD_COMPARATOR );
+
return pivotTable;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java 2011-01-06 22:22:18 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/pivottable/action/GetPivotTableAction.java 2011-03-14 13:23:25 +0000
@@ -27,11 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collections;
-import java.util.Comparator;
-
import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.pivottable.PivotTable;
import org.hisp.dhis.pivottable.PivotTableService;
@@ -63,13 +59,6 @@
this.format = format;
}
- private Comparator<Indicator> indicatorComparator;
-
- public void setIndicatorComparator( Comparator<Indicator> indicatorComparator )
- {
- this.indicatorComparator = indicatorComparator;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -132,9 +121,7 @@
{
period.setName( format.formatPeriod( period ) );
}
-
- Collections.sort( pivotTable.getIndicators(), indicatorComparator );
-
+
return SUCCESS;
}
}