← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4065: Fixed bug: Available data element list in program stage should be alphabet order.

 

------------------------------------------------------------
revno: 4065
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-07-05 10:06:11 +0700
message:
  Fixed bug: Available data element list in program stage should be alphabet order.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageFormAction.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-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.java	2011-03-20 18:15:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageAction.java	2011-07-05 03:06:11 +0000
@@ -29,9 +29,13 @@
 
 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;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageService;
@@ -65,6 +69,28 @@
     }
 
     // -------------------------------------------------------------------------
+    // 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
     // -------------------------------------------------------------------------
 
@@ -94,9 +120,9 @@
         return programStageDataElements;
     }
 
-    private Collection<DataElement> dataElements;
+    private List<DataElement> dataElements;
 
-    public Collection<DataElement> getDataElements()
+    public List<DataElement> getDataElements()
     {
         return dataElements;
     }
@@ -120,6 +146,14 @@
             dataElements.remove( psde.getDataElement() );
         }
 
+        // ---------------------------------------------------------------------
+        // Sorted available dataelements
+        // ---------------------------------------------------------------------
+        
+        Collections.sort( dataElements, dataElementComparator );
+
+        displayPropertyHandler.handle( dataElements );
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageFormAction.java	2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowAddProgramStageFormAction.java	2011-07-05 03:06:11 +0000
@@ -28,10 +28,13 @@
  */
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 
@@ -64,6 +67,28 @@
     }
 
     // -------------------------------------------------------------------------
+    // 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
     // -------------------------------------------------------------------------
 
@@ -109,6 +134,10 @@
         dataElements = new ArrayList<DataElement>( dataElementService
             .getDataElementsByDomainType( DataElement.DOMAIN_TYPE_PATIENT ) );
 
+        Collections.sort( dataElements, dataElementComparator );
+
+        displayPropertyHandler.handle( dataElements );
+
         return SUCCESS;
     }
 }