dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04404
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1459: Sort excel item and group in order of alphabet letters - Excel Reporting
------------------------------------------------------------
revno: 1459
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-02-22 13:15:52 +0700
message:
Sort excel item and group in order of alphabet letters - Excel Reporting
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/excelitem/comparator/ExcelItemGroupComparator.java
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/ListExcelItemAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitemgroup/action/ListAllExcelItemGroupAction.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.
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/excelitem/comparator/ExcelItemGroupComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/excelitem/comparator/ExcelItemGroupComparator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/excelitem/comparator/ExcelItemGroupComparator.java 2010-02-22 06:15:52 +0000
@@ -0,0 +1,45 @@
+package org.hisp.dhis.reportexcel.excelitem.comparator;
+
+/*
+ * Copyright (c) 2004-2007, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Comparator;
+
+import org.hisp.dhis.reportexcel.excelitem.ExcelItemGroup;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id$
+ */
+public class ExcelItemGroupComparator
+ implements Comparator<ExcelItemGroup>
+{
+ public int compare( ExcelItemGroup o1, ExcelItemGroup o2 )
+ {
+ return o1.getName().compareToIgnoreCase( o2.getName() );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/ListExcelItemAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/ListExcelItemAction.java 2009-12-04 05:00:32 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/ListExcelItemAction.java 2010-02-22 06:15:52 +0000
@@ -28,7 +28,6 @@
*/
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -38,6 +37,7 @@
import org.hisp.dhis.reportexcel.excelitem.ExcelItem;
import org.hisp.dhis.reportexcel.excelitem.ExcelItemGroup;
import org.hisp.dhis.reportexcel.excelitem.ExcelItemService;
+import org.hisp.dhis.reportexcel.excelitem.comparator.ExcelItemComparator;
import com.opensymphony.xwork2.Action;
@@ -62,10 +62,10 @@
// -------------------------------------------------------------
private int excelItemGroupId;
-
+
private ExcelItemGroup excelItemGroup;
-
- private Collection<ExcelItem> excelItems;
+
+ private List<ExcelItem> excelItems;
private List<DataElementGroup> dataElementGroups;
@@ -73,7 +73,7 @@
// Getters and Setters
// -------------------------------------------------------------
- public Collection<ExcelItem> getExcelItems()
+ public List<ExcelItem> getExcelItems()
{
return excelItems;
}
@@ -112,7 +112,9 @@
{
excelItemGroup = excelItemService.getExcelItemGroup( excelItemGroupId );
- excelItems = excelItemService.getExcelItemGroup( excelItemGroupId ).getExcelItems();
+ excelItems = new ArrayList<ExcelItem>( excelItemService.getExcelItemGroup( excelItemGroupId ).getExcelItems() );
+
+ Collections.sort( excelItems, new ExcelItemComparator() );
dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitemgroup/action/ListAllExcelItemGroupAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitemgroup/action/ListAllExcelItemGroupAction.java 2009-10-30 09:59:20 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitemgroup/action/ListAllExcelItemGroupAction.java 2010-02-22 06:15:52 +0000
@@ -27,13 +27,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reportexcel.excelitem.ExcelItemGroup;
import org.hisp.dhis.reportexcel.excelitem.ExcelItemService;
+import org.hisp.dhis.reportexcel.excelitem.comparator.ExcelItemGroupComparator;
import com.opensymphony.xwork2.Action;
@@ -51,7 +54,7 @@
// Input && Output
// -------------------------------------------------------------
- private Collection<ExcelItemGroup> excelItemGroups;
+ private List<ExcelItemGroup> excelItemGroups;
private List<PeriodType> periodTypes;
@@ -63,7 +66,7 @@
this.excelItemService = excelItemService;
}
- public Collection<ExcelItemGroup> getExcelItemGroups() {
+ public List<ExcelItemGroup> getExcelItemGroups() {
return excelItemGroups;
}
@@ -81,8 +84,10 @@
public String execute() throws Exception {
- excelItemGroups = excelItemService.getAllExcelItemGroup();
+ excelItemGroups = new ArrayList<ExcelItemGroup>( excelItemService.getAllExcelItemGroup());
+ Collections.sort( excelItemGroups, new ExcelItemGroupComparator());
+
periodTypes = periodService.getAllPeriodTypes();
return SUCCESS;