← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14400: use plural schema name as root json property instead of 'objects'

 

------------------------------------------------------------
revno: 14400
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-03-25 12:40:32 +0100
message:
  use plural schema name as root json property instead of 'objects'
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.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/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2014-03-25 11:29:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2014-03-25 11:40:32 +0000
@@ -39,6 +39,8 @@
 import org.hisp.dhis.dxf2.filter.FilterService;
 import org.hisp.dhis.dxf2.metadata.ExchangeClasses;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.schema.SchemaService;
 import org.hisp.dhis.sharing.Access;
 import org.hisp.dhis.sharing.SharingService;
 import org.hisp.dhis.system.util.ReflectionUtils;
@@ -85,6 +87,9 @@
     @Autowired
     protected SharingService sharingService;
 
+    @Autowired
+    protected SchemaService schemaService;
+
     //--------------------------------------------------------------------------
     // GET
     //--------------------------------------------------------------------------
@@ -99,6 +104,8 @@
         WebOptions options = new WebOptions( parameters );
         WebMetaData metaData = new WebMetaData();
 
+        Schema schema = schemaService.getSchema( getEntityClass() );
+
         boolean hasPaging = options.hasPaging();
 
         // get full list if we are using filters
@@ -151,7 +158,15 @@
                 output.put( "pager", metaData.getPager() );
             }
 
-            output.put( "objects", objects );
+            if ( schema != null )
+            {
+                output.put( schema.getPlural(), objects );
+            }
+            else
+            {
+                output.put( "objects", objects );
+            }
+
             JacksonUtils.toJson( response.getOutputStream(), output );
         }
         else