← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9243: WEB-API: support level sorting when using lastUpdated

 

------------------------------------------------------------
revno: 9243
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-12-09 17:55:25 +0300
message:
  WEB-API: support level sorting when using lastUpdated
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.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-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2012-12-09 14:31:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2012-12-09 14:55:25 +0000
@@ -70,15 +70,22 @@
 
         Date lastUpdated = options.getLastUpdated();
 
-        if ( options.getOptions().containsKey( "levelSorted" ) && Boolean.parseBoolean( options.getOptions().get( "levelSorted" ) ) )
+        boolean levelSorted = options.getOptions().containsKey( "levelSorted" ) && Boolean.parseBoolean( options.getOptions().get( "levelSorted" ) );
+
+        if ( lastUpdated != null )
+        {
+            entityList = new ArrayList<OrganisationUnit>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );
+
+            if ( levelSorted )
+            {
+                Collections.sort( entityList, new OrganisationUnitByLevelComparator() );
+            }
+        }
+        else if ( levelSorted )
         {
             entityList = new ArrayList<OrganisationUnit>( manager.getAll( getEntityClass() ) );
             Collections.sort( entityList, new OrganisationUnitByLevelComparator() );
         }
-        else if ( lastUpdated != null )
-        {
-            entityList = new ArrayList<OrganisationUnit>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );
-        }
         else if ( options.hasPaging() )
         {
             int count = manager.getCount( getEntityClass() );