← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9357: minor fix

 

------------------------------------------------------------
revno: 9357
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-12-18 18:24:57 +0100
message:
  minor fix
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/comparator/OrganisationUnitByLevelComparator.java
  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-api/src/main/java/org/hisp/dhis/organisationunit/comparator/OrganisationUnitByLevelComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/comparator/OrganisationUnitByLevelComparator.java	2012-12-15 17:28:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/comparator/OrganisationUnitByLevelComparator.java	2012-12-18 17:24:57 +0000
@@ -37,9 +37,11 @@
 public class OrganisationUnitByLevelComparator
     implements Comparator<OrganisationUnit>
 {
+    public static final Comparator<OrganisationUnit> INSTANCE = new OrganisationUnitByLevelComparator();
+
     @Override
     public int compare( OrganisationUnit o1, OrganisationUnit o2 )
     {
-        return new Integer( o1.getOrganisationUnitLevel() ).compareTo( o2.getOrganisationUnitLevel() );
+        return ((Integer) o1.getOrganisationUnitLevel()).compareTo( o2.getOrganisationUnitLevel() );
     }
 }

=== 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:55:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2012-12-18 17:24:57 +0000
@@ -48,13 +48,17 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 @Controller
-@RequestMapping( value = OrganisationUnitController.RESOURCE_PATH )
+@RequestMapping(value = OrganisationUnitController.RESOURCE_PATH)
 public class OrganisationUnitController
     extends AbstractCrudController<OrganisationUnit>
 {
@@ -78,13 +82,13 @@
 
             if ( levelSorted )
             {
-                Collections.sort( entityList, new OrganisationUnitByLevelComparator() );
+                Collections.sort( entityList, OrganisationUnitByLevelComparator.INSTANCE );
             }
         }
         else if ( levelSorted )
         {
             entityList = new ArrayList<OrganisationUnit>( manager.getAll( getEntityClass() ) );
-            Collections.sort( entityList, new OrganisationUnitByLevelComparator() );
+            Collections.sort( entityList, OrganisationUnitByLevelComparator.INSTANCE );
         }
         else if ( options.hasPaging() )
         {
@@ -104,8 +108,8 @@
     }
 
     @Override
-    @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
-    public String getObject( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
+    @RequestMapping(value = "/{uid}", method = RequestMethod.GET)
+    public String getObject( @PathVariable("uid") String uid, @RequestParam Map<String, String> parameters,
         Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
     {
         WebOptions options = new WebOptions( parameters );