dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24246
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11848: support viewClass in /api/currentUser/assignedOrganisationUnits
------------------------------------------------------------
revno: 11848
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-08-30 17:36:39 +0200
message:
support viewClass in /api/currentUser/assignedOrganisationUnits
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.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/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-08-30 14:03:13 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/CurrentUserController.java 2013-08-30 15:36:39 +0000
@@ -294,14 +294,22 @@
}
}
-
- JacksonUtils.toJson( response.getOutputStream(), userOrganisationUnits );
+ String viewName = parameters.get( "viewClass" );
+
+ if ( viewName == null )
+ {
+ viewName = "detailed";
+ }
+
+ Class<?> viewClass = JacksonUtils.getViewClass( viewName );
+
+ JacksonUtils.toJsonWithView( response.getOutputStream(), userOrganisationUnits, viewClass );
}
- @SuppressWarnings("unchecked")
- @RequestMapping(value = { "/assignedPrograms" }, produces = { "application/json", "text/*" })
+ @SuppressWarnings( "unchecked" )
+ @RequestMapping( value = { "/assignedPrograms" }, produces = { "application/json", "text/*" } )
public void getPrograms( HttpServletResponse response, @RequestParam Map<String, String> parameters,
- @RequestParam(defaultValue = "1") Integer type )
+ @RequestParam( defaultValue = "1" ) Integer type )
throws IOException, NotAuthenticatedException
{
User currentUser = currentUserService.getCurrentUser();
@@ -389,8 +397,8 @@
JacksonUtils.toJson( response.getOutputStream(), forms );
}
- @SuppressWarnings("unchecked")
- @RequestMapping(value = "/assignedDataSets", produces = { "application/json", "text/*" })
+ @SuppressWarnings( "unchecked" )
+ @RequestMapping( value = "/assignedDataSets", produces = { "application/json", "text/*" } )
public void getDataSets( HttpServletResponse response, @RequestParam Map<String, String> parameters ) throws IOException, NotAuthenticatedException
{
User currentUser = currentUserService.getCurrentUser();