dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17700
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7147: WIP More flexible datavalueset import - content based routing determined by Content-Type:
------------------------------------------------------------
revno: 7147
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-06-01 23:00:36 +0100
message:
WIP More flexible datavalueset import - content based routing determined by Content-Type:
application/dxf2+xml - explicit dxf2 import. Most efficient. Recommended for dxf2 datavalueset clients
application/sdmx+xml - explicit sdmx CrossSectionalData import
application/xml - general xml: we try to import it depending on whether we understand the format.
modified:
dhis-2/dhis-web/dhis-web-api/pom.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/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-web/dhis-web-api/pom.xml'
--- dhis-2/dhis-web/dhis-web-api/pom.xml 2012-05-10 09:57:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/pom.xml 2012-06-01 22:00:36 +0000
@@ -25,6 +25,10 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-dxf2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-integration</artifactId>
+ </dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-core</artifactId>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-04-29 08:52:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-06-01 22:00:36 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.integration.IntegrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
@@ -59,9 +60,12 @@
public static final String RESOURCE_PATH = "/dataValueSets";
private static final Log log = LogFactory.getLog( DataValueSetController.class );
-
+
@Autowired
private DataValueSetService dataValueSetService;
+
+ @Autowired
+ private IntegrationService integrationService;
@RequestMapping( method = RequestMethod.GET, headers = {"Accept=text/html"} )
public String getDataValueSets( Model model ) throws Exception
@@ -74,7 +78,6 @@
return "dataValueSets";
}
- @RequestMapping( method = RequestMethod.GET, headers = {"Accept=application/xml"} )
public void getDataValueSet( @RequestParam String dataSet,
@RequestParam String period,
@RequestParam String orgUnit,
@@ -86,6 +89,36 @@
dataValueSetService.writeDataValueSet( dataSet, period, orgUnit, response.getOutputStream() );
}
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/dxf2+xml"} )
+ @PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
+ public void postDxf2DataValueSet( ImportOptions importOptions,
+ HttpServletResponse response,
+ InputStream in,
+ Model model ) throws IOException
+ {
+ ImportSummary summary = dataValueSetService.saveDataValueSet( in, importOptions );
+
+ log.info( "Data values set saved " + importOptions );
+
+ response.setContentType( CONTENT_TYPE_XML );
+ JacksonUtils.toXml( response.getOutputStream(), summary );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/sdmx+xml"} )
+ @PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
+ public void postSDMXDataValueSet( ImportOptions importOptions,
+ HttpServletResponse response,
+ InputStream in,
+ Model model ) throws IOException
+ {
+ ImportSummary summary = integrationService.importSDMXDataValueSet( in, importOptions );
+
+ log.info( "Data values set saved " + importOptions );
+
+ response.setContentType( CONTENT_TYPE_XML );
+ JacksonUtils.toXml( response.getOutputStream(), summary );
+ }
+
@RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml"} )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
public void postDataValueSet( ImportOptions importOptions,
@@ -93,14 +126,14 @@
InputStream in,
Model model ) throws IOException
{
- ImportSummary summary = dataValueSetService.saveDataValueSet( in, importOptions );
+ ImportSummary summary = integrationService.importXMLDataValueSet( in, importOptions );
log.info( "Data values set saved " + importOptions );
response.setContentType( CONTENT_TYPE_XML );
JacksonUtils.toXml( response.getOutputStream(), summary );
}
-
+
@ExceptionHandler(IllegalArgumentException.class)
public void handleError( IllegalArgumentException ex, HttpServletResponse response )
throws IOException
@@ -108,3 +141,4 @@
ContextUtils.conflictResponse( response, ex.getMessage() );
}
}
+
\ No newline at end of file