← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14431: Sorting of attributes in add/edit program

 

------------------------------------------------------------
revno: 14431
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-26 13:59:13 +0100
message:
  Sorting of attributes in add/edit program
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.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-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowAddProgramFormAction.java	2014-03-26 12:59:13 +0000
@@ -29,7 +29,6 @@
  */
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -94,9 +93,9 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private Collection<TrackedEntityAttribute> availableAttributes;
+    private List<TrackedEntityAttribute> availableAttributes;
 
-    public Collection<TrackedEntityAttribute> getAvailableAttributes()
+    public List<TrackedEntityAttribute> getAvailableAttributes()
     {
         return availableAttributes;
     }
@@ -139,9 +138,11 @@
         programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
         Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE );
 
-        availableAttributes = attributeService.getAllTrackedEntityAttributes();
+        availableAttributes = new ArrayList<TrackedEntityAttribute>( attributeService.getAllTrackedEntityAttributes() );
+        Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE );
 
         userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
+        Collections.sort( userGroups, IdentifiableObjectNameComparator.INSTANCE );
 
         relationshipTypes = new ArrayList<RelationshipType>( relationshipTypeService.getAllRelationshipTypes() );
         Collections.sort( relationshipTypes, IdentifiableObjectNameComparator.INSTANCE );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/ShowUpdateProgramFormAction.java	2014-03-26 12:59:13 +0000
@@ -29,7 +29,6 @@
  */
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -154,9 +153,9 @@
         this.organisationUnitGroupId = organisationUnitGroupId;
     }
 
-    private Collection<TrackedEntityAttribute> availableAttributes;
+    private List<TrackedEntityAttribute> availableAttributes;
 
-    public Collection<TrackedEntityAttribute> getAvailableAttributes()
+    public List<TrackedEntityAttribute> getAvailableAttributes()
     {
         return availableAttributes;
     }
@@ -198,11 +197,14 @@
     {
         program = programService.getProgram( id );
 
-        availableAttributes = attributeService.getAllTrackedEntityAttributes();
+        availableAttributes = new ArrayList<TrackedEntityAttribute>( attributeService.getAllTrackedEntityAttributes() );
+        
         for ( ProgramTrackedEntityAttribute programAttribue : program.getAttributes() )
         {
             availableAttributes.remove( programAttribue.getAttribute() );
         }
+        
+        Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE );
 
         programs = new ArrayList<Program>( programService.getAllPrograms() );
         programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );