← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17276: Web API. Made data approval levels for current user available at /api/me/dataApprovalLevels.

 

------------------------------------------------------------
revno: 17276
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-10-25 12:52:33 +0200
message:
  Web API. Made data approval levels for current user available at /api/me/dataApprovalLevels.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/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-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java	2014-10-23 19:09:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevel.java	2014-10-25 10:52:33 +0000
@@ -30,7 +30,6 @@
 
 import java.util.Date;
 
-import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.view.DetailedView;
@@ -190,7 +189,7 @@
     }
 
     @JsonProperty
-    @JsonSerialize( as = BaseDimensionalObject.class )
+    @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public CategoryOptionGroupSet getCategoryOptionGroupSet()

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java	2014-10-22 08:58:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java	2014-10-25 10:52:33 +0000
@@ -51,6 +51,8 @@
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.dashboard.DashboardItem;
+import org.hisp.dhis.dataapproval.DataApprovalLevel;
+import org.hisp.dhis.dataapproval.DataApprovalLevelService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
@@ -144,6 +146,9 @@
 
     @Autowired
     protected AclService aclService;
+    
+    @Autowired
+    private DataApprovalLevelService approvalLevelService;
 
     @RequestMapping( produces = { "application/json", "text/*" } )
     public void getCurrentUser( HttpServletResponse response ) throws Exception
@@ -402,7 +407,7 @@
         response.setContentType( MediaType.APPLICATION_JSON_VALUE );
         JacksonUtils.toJson( response.getOutputStream(), recipients );
     }
-
+    
     @RequestMapping( value = { "/assignedOrganisationUnits", "/organisationUnits" }, produces = { "application/json", "text/*" } )
     public void getAssignedOrganisationUnits( HttpServletResponse response, @RequestParam Map<String, String> parameters ) throws IOException, NotAuthenticatedException
     {
@@ -693,4 +698,12 @@
         response.setContentType( MediaType.APPLICATION_JSON_VALUE );
         JacksonUtils.toJson( response.getOutputStream(), forms );
     }
+
+    @RequestMapping( value = "/dataApprovalLevels", produces = { "application/json", "text/*" } )
+    public void getApprovalLevels( HttpServletResponse response ) throws IOException
+    {
+        List<DataApprovalLevel> approvalLevels = approvalLevelService.getUserDataApprovalLevels();
+        response.setContentType( MediaType.APPLICATION_JSON_VALUE );
+        JacksonUtils.toJson( response.getOutputStream(), approvalLevels );        
+    }
 }