← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16989: Impl JSON data export in import-export ui

 

------------------------------------------------------------
revno: 16989
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-07 23:37:53 +0200
message:
  Impl JSON data export in import-export ui
modified:
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm


--
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-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java	2014-09-12 15:26:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ExportDataValueAction.java	2014-10-07 21:37:53 +0000
@@ -32,6 +32,7 @@
 import static org.hisp.dhis.system.util.DateUtils.getMediumDate;
 import static org.hisp.dhis.util.ContextUtils.CONTENT_TYPE_CSV;
 import static org.hisp.dhis.util.ContextUtils.CONTENT_TYPE_XML;
+import static org.hisp.dhis.util.ContextUtils.CONTENT_TYPE_JSON;
 import static org.hisp.dhis.util.ContextUtils.getZipOut;
 
 import java.io.OutputStreamWriter;
@@ -62,10 +63,13 @@
     private final static String FILE_PREFIX = "Export";
     private final static String FILE_SEPARATOR = "_";
     private final static String EXTENSION_XML_ZIP = ".xml.zip";
+    private final static String EXTENSION_JSON_ZIP = ".json.zip";
     private final static String EXTENSION_CSV_ZIP = ".csv.zip";
     private final static String EXTENSION_XML = ".xml";
+    private final static String EXTENSION_JSON = ".json";
     private final static String EXTENSION_CSV = ".csv";
     private final static String FORMAT_CSV = "csv";
+    private final static String FORMAT_JSON = "json";
 
     @Autowired
     private SelectionTreeManager selectionTreeManager;
@@ -153,6 +157,13 @@
             dataValueSetService.writeDataValueSetCsv( selectedDataSets, getMediumDate( startDate ), 
                 getMediumDate( endDate ), orgUnits, true, writer, exportOptions );
         }
+        else if ( FORMAT_JSON.equals( exportFormat ) )
+        {
+            ContextUtils.configureResponse( response, CONTENT_TYPE_JSON, true, getFileName( EXTENSION_JSON_ZIP ), true );
+            
+            dataValueSetService.writeDataValueSetJson( selectedDataSets, getMediumDate( startDate ), 
+                getMediumDate( endDate ), orgUnits, true, getZipOut( response, getFileName( EXTENSION_JSON ) ), exportOptions );
+        }
         else
         {
             ContextUtils.configureResponse( response, CONTENT_TYPE_XML, true, getFileName( EXTENSION_XML_ZIP ), true );

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2014-09-12 15:26:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2014-10-07 21:37:53 +0000
@@ -300,6 +300,7 @@
 type=Type
 count=Count
 export_as_xml=Export as XML
+export_as_json=Export as JSON
 export_as_csv=Export as CSV
 csv=CSV
 xml=XML

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm	2014-09-12 15:26:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm	2014-10-07 21:37:53 +0000
@@ -126,6 +126,7 @@
 	
 	<tr>		
 		<td><input type="button" value="$i18n.getString( 'export_as_xml' )" style="width:120px" onclick="exportDataValue( 'xml' )">
+		<td><input type="button" value="$i18n.getString( 'export_as_json' )" style="width:120px" onclick="exportDataValue( 'json' )">
 		<input type="button" value="$i18n.getString( 'export_as_csv' )" style="width:120px" onclick="exportDataValue( 'csv' )"></td>
 		<td></td>
 		<td></td>