dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05511
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1794: Added sorting for edit dataset section
------------------------------------------------------------
revno: 1794
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-04-21 12:21:28 +0200
message:
Added sorting for edit dataset section
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.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-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java 2010-04-20 22:58:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java 2010-04-21 10:21:28 +0000
@@ -29,6 +29,8 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
@@ -36,6 +38,7 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.dataset.Section;
import org.hisp.dhis.dataset.SectionService;
+import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
import com.opensymphony.xwork2.Action;
@@ -59,7 +62,29 @@
{
this.dataSetService = dataSetService;
}
-
+
+ // -------------------------------------------------------------------------
+ // Comparator
+ // -------------------------------------------------------------------------
+
+ private Comparator<DataElement> dataElementComparator;
+
+ public void setDataElementComparator( Comparator<DataElement> dataElementComparator )
+ {
+ this.dataElementComparator = dataElementComparator;
+ }
+
+ // -------------------------------------------------------------------------
+ // DisplayPropertyHandler
+ // -------------------------------------------------------------------------
+
+ private DisplayPropertyHandler displayPropertyHandler;
+
+ public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
+ {
+ this.displayPropertyHandler = displayPropertyHandler;
+ }
+
// -------------------------------------------------------------------------
// Input & output
// -------------------------------------------------------------------------
@@ -72,7 +97,7 @@
private DataSet dataSet;
- private Collection<DataElement> dataElementOfDataSet = new ArrayList<DataElement>();
+ private List<DataElement> dataElementOfDataSet = new ArrayList<DataElement>();
public Integer getSectionId()
{
@@ -104,12 +129,12 @@
this.dataElementsOfSection = dataElementsOfSection;
}
- public Collection<DataElement> getDataElementOfDataSet()
+ public List<DataElement> getDataElementOfDataSet()
{
return dataElementOfDataSet;
}
- public void setDataElementOfDataSet( Collection<DataElement> dataElementOfDataSet )
+ public void setDataElementOfDataSet( List<DataElement> dataElementOfDataSet )
{
this.dataElementOfDataSet = dataElementOfDataSet;
}
@@ -137,7 +162,7 @@
dataSet = dataSetService.getDataSet( section.getDataSet().getId() );
- dataElementOfDataSet = dataSet.getDataElements();
+ dataElementOfDataSet = new ArrayList<DataElement>( dataSet.getDataElements() );
Collection<Section> sections = sectionService.getSectionByDataSet( dataSet );
@@ -146,6 +171,12 @@
dataElementOfDataSet.removeAll( s.getDataElements() );
}
+ Collections.sort( dataElementsOfSection, dataElementComparator );
+ Collections.sort( dataElementOfDataSet, dataElementComparator );
+
+ displayPropertyHandler.handle( dataElementsOfSection );
+ displayPropertyHandler.handle( dataElementOfDataSet );
+
return SUCCESS;
}
}