← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13531: support viewClass in meta-data export, allows exporting all normal view-classse in /api/metaData ...

 

------------------------------------------------------------
revno: 13531
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-02 12:16:43 +0100
message:
  support viewClass in meta-data export, allows exporting all normal view-classse in /api/metaData endpoint.
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.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/MetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2013-10-30 12:51:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2014-01-02 11:16:43 +0000
@@ -110,7 +110,8 @@
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.NO_CACHE, "metaData.xml", true );
 
-        JacksonUtils.toXmlWithView( response.getOutputStream(), metaData, ExportView.class );
+        Class<?> viewClass = JacksonUtils.getViewClass( options.getViewClass( "export" ) );
+        JacksonUtils.toXmlWithView( response.getOutputStream(), metaData, viewClass );
     }
 
     @RequestMapping( value = MetaDataController.RESOURCE_PATH + ".json", produces = "*/*" )
@@ -122,7 +123,8 @@
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.NO_CACHE, "metaData.json", true );
 
-        JacksonUtils.toJsonWithView( response.getOutputStream(), metaData, ExportView.class );
+        Class<?> viewClass = JacksonUtils.getViewClass( options.getViewClass( "export" ) );
+        JacksonUtils.toJsonWithView( response.getOutputStream(), metaData, viewClass );
     }
 
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".zip" }, produces = "*/*" )
@@ -154,7 +156,8 @@
         ZipOutputStream zip = new ZipOutputStream( response.getOutputStream() );
         zip.putNextEntry( new ZipEntry( "metaData.xml" ) );
 
-        JacksonUtils.toXmlWithView( zip, metaData, ExportView.class );
+        Class<?> viewClass = JacksonUtils.getViewClass( options.getViewClass( "export" ) );
+        JacksonUtils.toXmlWithView( zip, metaData, viewClass );
     }
 
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".json.zip" }, produces = "*/*" )
@@ -170,7 +173,8 @@
         ZipOutputStream zip = new ZipOutputStream( response.getOutputStream() );
         zip.putNextEntry( new ZipEntry( "metaData.json" ) );
 
-        JacksonUtils.toJsonWithView( zip, metaData, ExportView.class );
+        Class<?> viewClass = JacksonUtils.getViewClass( options.getViewClass( "export" ) );
+        JacksonUtils.toJsonWithView( zip, metaData, viewClass );
     }
 
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".gz" }, produces = "*/*" )
@@ -200,7 +204,9 @@
         response.addHeader( ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary" );
 
         GZIPOutputStream gzip = new GZIPOutputStream( response.getOutputStream() );
-        JacksonUtils.toXmlWithView( gzip, metaData, ExportView.class );
+
+        Class<?> viewClass = JacksonUtils.getViewClass( options.getViewClass( "export" ) );
+        JacksonUtils.toXmlWithView( gzip, metaData, viewClass );
     }
 
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".json.gz" }, produces = "*/*" )
@@ -214,7 +220,9 @@
         response.addHeader( ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary" );
 
         GZIPOutputStream gzip = new GZIPOutputStream( response.getOutputStream() );
-        JacksonUtils.toJsonWithView( gzip, metaData, ExportView.class );
+
+        Class<?> viewClass = JacksonUtils.getViewClass( options.getViewClass( "export" ) );
+        JacksonUtils.toJsonWithView( gzip, metaData, viewClass );
     }
 
     //--------------------------------------------------------------------------