dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23382
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11378: get orgunits by level
------------------------------------------------------------
revno: 11378
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-07-10 16:50:45 +0700
message:
get orgunits by level
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-18 17:24:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java 2013-07-10 09:50:45 +0000
@@ -76,6 +76,13 @@
boolean levelSorted = options.getOptions().containsKey( "levelSorted" ) && Boolean.parseBoolean( options.getOptions().get( "levelSorted" ) );
+ Integer level = null;
+
+ if ( options.getOptions().containsKey( "level" ) )
+ {
+ level = Integer.parseInt( options.getOptions().get( "level" ) );
+ }
+
if ( lastUpdated != null )
{
entityList = new ArrayList<OrganisationUnit>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );
@@ -85,6 +92,10 @@
Collections.sort( entityList, OrganisationUnitByLevelComparator.INSTANCE );
}
}
+ else if ( level != null )
+ {
+ entityList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( level ) );
+ }
else if ( levelSorted )
{
entityList = new ArrayList<OrganisationUnit>( manager.getAll( getEntityClass() ) );
@@ -108,8 +119,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 );