← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17398: Web API, data value sets, added support for CSV data import

 

------------------------------------------------------------
revno: 17398
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-10 14:38:22 +0100
message:
  Web API, data value sets, added support for CSV data import
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java	2014-09-12 15:26:18 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java	2014-11-10 13:38:22 +0000
@@ -70,6 +70,8 @@
     ImportSummary saveDataValueSet( InputStream in, ImportOptions importOptions );
 
     ImportSummary saveDataValueSetJson( InputStream in, ImportOptions importOptions );
+    
+    ImportSummary saveDataValueSetCsv( InputStream in, ImportOptions importOptions );
 
     ImportSummary saveDataValueSet( InputStream in, ImportOptions importOptions, TaskId taskId );
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-11-10 13:38:22 +0000
@@ -448,6 +448,12 @@
     }
 
     @Override
+    public ImportSummary saveDataValueSetCsv( InputStream in, ImportOptions importOptions )
+    {
+        return saveDataValueSetCsv( in, importOptions, null );
+    }
+
+    @Override
     public ImportSummary saveDataValueSet( InputStream in, ImportOptions importOptions, TaskId id )
     {
         try
@@ -590,7 +596,7 @@
         Date now = new Date();
         
         notifier.notify( id, "Importing data values" );
-        log.info( "importing data values" );
+        log.info( "Importing data values" );
 
         while ( dataValueSet.hasNextDataValue() )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java	2014-11-10 13:03:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java	2014-11-10 13:38:22 +0000
@@ -188,6 +188,19 @@
         JacksonUtils.toJson( response.getOutputStream(), summary );
     }
 
+    @RequestMapping( method = RequestMethod.POST, consumes = "application/csv" )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
+    public void postCsvDataValueSet( ImportOptions importOptions,
+        HttpServletResponse response, InputStream in, Model model ) throws IOException
+    {
+        ImportSummary summary = dataValueSetService.saveDataValueSetCsv( in, importOptions );
+
+        log.info( "Data values set saved " + importOptions );
+
+        response.setContentType( CONTENT_TYPE_XML );
+        JacksonUtils.toXml( response.getOutputStream(), summary );
+    }
+
     // -------------------------------------------------------------------------
     // Supportive
     // -------------------------------------------------------------------------