← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17566: add option to geojson exporter, allows for turning of additional properties, used if you want a s...

 

------------------------------------------------------------
revno: 17566
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-24 13:33:13 +0700
message:
  add option to geojson exporter, allows for turning of additional properties, used if you want a smaller payload
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/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/webapi/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2014-11-17 14:35:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2014-11-24 06:33:13 +0000
@@ -240,6 +240,7 @@
     public void getGeoJson(
         @RequestParam( value = "level", required = false ) List<Integer> rpLevels,
         @RequestParam( value = "parent", required = false ) List<String> rpParents,
+        @RequestParam( value = "properties", required = false, defaultValue = "true" ) boolean rpProperties,
         HttpServletResponse response ) throws IOException
     {
         rpLevels = rpLevels != null ? rpLevels : new ArrayList<Integer>();
@@ -270,7 +271,7 @@
 
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
-            writeFeature( generator, organisationUnit );
+            writeFeature( generator, organisationUnit, rpProperties );
         }
 
         generator.writeEndArray();
@@ -279,7 +280,7 @@
         generator.close();
     }
 
-    public void writeFeature( JsonGenerator generator, OrganisationUnit organisationUnit ) throws IOException
+    public void writeFeature( JsonGenerator generator, OrganisationUnit organisationUnit, boolean includeProperties ) throws IOException
     {
         if ( organisationUnit.getFeatureType() == null || organisationUnit.getCoordinates() == null )
         {
@@ -308,11 +309,16 @@
         generator.writeEndObject();
 
         generator.writeObjectFieldStart( "properties" );
-        generator.writeStringField( "code", organisationUnit.getCode() );
-        generator.writeStringField( "name", organisationUnit.getName() );
-        generator.writeStringField( "level", String.valueOf( organisationUnit.getLevel() ) );
-        generator.writeStringField( "parent", organisationUnit.getParent().getUid() );
-        generator.writeStringField( "parentGraph", organisationUnit.getParentGraph() );
+
+        if ( includeProperties )
+        {
+            generator.writeStringField( "code", organisationUnit.getCode() );
+            generator.writeStringField( "name", organisationUnit.getName() );
+            generator.writeStringField( "level", String.valueOf( organisationUnit.getLevel() ) );
+            generator.writeStringField( "parent", organisationUnit.getParent().getUid() );
+            generator.writeStringField( "parentGraph", organisationUnit.getParentGraph() );
+        }
+
         generator.writeEndObject();
 
         generator.writeEndObject();