dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18029
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7436: Provided for the possibility of TaskId in the header of a camel datavalue import
------------------------------------------------------------
revno: 7436
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-27 16:16:51 +0100
message:
Provided for the possibility of TaskId in the header of a camel datavalue import
modified:
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/DefaultIntegrationService.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/IntegrationService.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataProducer.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-integration/src/main/java/org/hisp/dhis/integration/DefaultIntegrationService.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/DefaultIntegrationService.java 2012-06-22 16:46:42 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/DefaultIntegrationService.java 2012-06-27 15:16:51 +0000
@@ -28,12 +28,15 @@
*/
import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.camel.EndpointInject;
import org.apache.camel.ProducerTemplate;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
import org.hisp.dhis.integration.routes.SDMXDataIn;
import org.hisp.dhis.integration.routes.XMLDataIn;
+import org.hisp.dhis.scheduling.TaskId;
/**
* @author bobj
@@ -57,5 +60,25 @@
public ImportSummary importSDMXDataValueSet( InputStream in, ImportOptions importOptions )
{
return (ImportSummary) sdmxIn.requestBodyAndHeader( in, IMPORT_OPTIONS_HDR, importOptions);
- }
+ }
+
+ @Override
+ public ImportSummary importXMLDataValueSet( InputStream in, ImportOptions options, TaskId taskId )
+ {
+ Map<String,Object> headers = new HashMap<String,Object>();
+ headers.put( TASK_ID_HDR, taskId );
+ headers.put( IMPORT_OPTIONS_HDR, options);
+
+ return (ImportSummary) xmlIn.requestBodyAndHeaders( in, headers);
+ }
+
+ @Override
+ public ImportSummary importSDMXDataValueSet( InputStream in, ImportOptions options, TaskId taskId )
+ {
+ Map<String,Object> headers = new HashMap<String,Object>();
+ headers.put( TASK_ID_HDR, taskId );
+ headers.put( IMPORT_OPTIONS_HDR, options);
+
+ return (ImportSummary) sdmxIn.requestBodyAndHeaders( in, headers);
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/IntegrationService.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/IntegrationService.java 2012-06-02 15:42:02 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/IntegrationService.java 2012-06-27 15:16:51 +0000
@@ -30,6 +30,7 @@
import java.io.InputStream;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.scheduling.TaskId;
/**
*
@@ -38,8 +39,16 @@
public interface IntegrationService
{
public static final String IMPORT_OPTIONS_HDR = "ImportOptions";
+
+ public static final String TASK_ID_HDR = "TASK_ID";
+
ImportSummary importXMLDataValueSet(InputStream in, ImportOptions options);
ImportSummary importSDMXDataValueSet(InputStream in, ImportOptions options);
+
+ ImportSummary importXMLDataValueSet(InputStream in, ImportOptions options, TaskId taskId);
+
+ ImportSummary importSDMXDataValueSet(InputStream in, ImportOptions options, TaskId taskId);
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataProducer.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataProducer.java 2012-06-02 15:42:02 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataProducer.java 2012-06-27 15:16:51 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.dxf2.metadata.ImportOptions;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.integration.IntegrationService;
+import org.hisp.dhis.scheduling.TaskId;
/**
* @author bobj
@@ -58,8 +59,11 @@
ImportOptions options = (ImportOptions) exchange.getIn().
getHeader( IntegrationService.IMPORT_OPTIONS_HDR, endpoint.getImportOptions() );
+ TaskId taskId = (TaskId) exchange.getIn().
+ getHeader( IntegrationService.TASK_ID_HDR, null );
+
ImportSummary summary = endpoint.getDataValueSetService().saveDataValueSet( (InputStream)exchange.getIn().getBody(),
- options );
+ options, taskId );
exchange.getOut().setBody( summary );
log.debug( this.getEndpoint().getEndpointUri() + " : " + JacksonUtils.toXmlAsString(exchange.getOut().getBody()) );