=== 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 dataElementComparator; + + public void setDataElementComparator( Comparator 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 dataElementOfDataSet = new ArrayList(); + private List dataElementOfDataSet = new ArrayList(); public Integer getSectionId() { @@ -104,12 +129,12 @@ this.dataElementsOfSection = dataElementsOfSection; } - public Collection getDataElementOfDataSet() + public List getDataElementOfDataSet() { return dataElementOfDataSet; } - public void setDataElementOfDataSet( Collection dataElementOfDataSet ) + public void setDataElementOfDataSet( List dataElementOfDataSet ) { this.dataElementOfDataSet = dataElementOfDataSet; } @@ -137,7 +162,7 @@ dataSet = dataSetService.getDataSet( section.getDataSet().getId() ); - dataElementOfDataSet = dataSet.getDataElements(); + dataElementOfDataSet = new ArrayList( dataSet.getDataElements() ); Collection
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; } }