dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16963
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6604: apache camel based integration service - WIP
Merge authors:
Bob Jolliffe (bobjolliffe)
------------------------------------------------------------
revno: 6604 [merge]
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-16 16:12:08 +0100
message:
apache camel based integration service - WIP
added:
dhis-2/dhis-services/dhis-service-integration/
dhis-2/dhis-services/dhis-service-integration/pom.xml
dhis-2/dhis-services/dhis-service-integration/src/
dhis-2/dhis-services/dhis-service-integration/src/main/
dhis-2/dhis-services/dhis-service-integration/src/main/java/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataEndpoint.java
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/Dxf2MetaDataEndpoint.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataProducer.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/converters/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/converters/XMLConverterWrappers.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/management/
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/management/DHIS2LifecycleStrategy.java
dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/routes/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/dhis/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/component/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/component/dhis2
dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/
dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf.xsl
dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf2.xsl
dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/gml2dxf.xsl
dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/imr2dxf.xsl
dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/transforms.xml
dhis-2/dhis-services/dhis-service-integration/src/test/
dhis-2/dhis-services/dhis-service-integration/src/test/java/
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java
dhis-2/dhis-services/dhis-service-integration/src/test/resources/
dhis-2/dhis-services/dhis-service-integration/src/test/resources/test-context.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/AddRouteAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/ShowAddRouteFormAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/routes.js
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/showAddRouteForm.vm
modified:
dhis-2/dhis-services/pom.xml
dhis-2/dhis-web/dhis-web-importexport/pom.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm
dhis-2/pom.xml
--
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
=== added directory 'dhis-2/dhis-services/dhis-service-integration'
=== added file 'dhis-2/dhis-services/dhis-service-integration/pom.xml'
--- dhis-2/dhis-services/dhis-service-integration/pom.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/pom.xml 2012-04-16 15:12:08 +0000
@@ -0,0 +1,73 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-services</artifactId>
+ <version>2.8-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>dhis-service-integration</artifactId>
+ <packaging>jar</packaging>
+ <name>DHIS Integration Service</name>
+
+ <dependencies>
+
+ <!-- DHIS -->
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-dxf2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-external</artifactId>
+ </dependency>
+
+ <!-- Camel core -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+
+ <!-- Camel components -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mail</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-quartz</artifactId>
+ </dependency>
+
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <version>2.9.1</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+ <properties>
+ <rootDir>../../</rootDir>
+ </properties>
+</project>
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,86 @@
+package org.hisp.dhis.integration.components;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Map;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.dxf2.datavalueset.DefaultDataValueSetService;
+import org.hisp.dhis.dxf2.metadata.ImportService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * A DHIS2 specific camel component for creating dhis2 endpoints
+ *
+ * Two forms of uri are supported for the endpoints:
+ * 1. uri="dhis2:metadata?<options>" creates a metadata endpoint for importing metadata
+ * 2. uri="dhis2:data?<options>" creates a datavalueset endpoint for importing data
+ *
+ * See the respective endpoint classes for details of the options supported on each
+ *
+ * @author bobj
+ */
+public class Dxf2Component extends DefaultComponent
+{
+ public static final String DATA = "data";
+
+ public static final String METADATA = "metadata";
+
+ @Autowired
+ private ImportService importService;
+
+ public void setImportService( ImportService importService )
+ {
+ this.importService = importService;
+ }
+
+ @Autowired
+ private DataValueSetService dataValueSetService;
+
+ public void setDataValueSetService( DataValueSetService dataValueSetService )
+ {
+ this.dataValueSetService = dataValueSetService;
+ }
+
+ @Override
+ protected Endpoint createEndpoint( String uri, String remaining, Map<String, Object> parameters ) throws Exception
+ {
+ System.out.println("Creating endpoint for "+uri+" , "+remaining);
+ if ( !remaining.equals( DATA ) && !remaining.equals( METADATA ) )
+ {
+ throw new UnsupportedOperationException( "Invalid dhis2 uri part " + remaining);
+ }
+
+ Endpoint endpoint = remaining.equals( DATA ) ?
+ new Dxf2DataEndpoint( uri, this, dataValueSetService ) : new Dxf2MetaDataEndpoint( uri, this, importService );
+
+ setProperties( endpoint, parameters );
+ return endpoint;
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataEndpoint.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataEndpoint.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataEndpoint.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,104 @@
+package org.hisp.dhis.integration.components;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.importexport.ImportStrategy;
+;
+
+/**
+ *
+ * dataendpoint is created using a uri of the form:
+ * dhis2:metadata?dryRun=true|false&importStrategy=NEW|NEW_AND_UPDATES|UPDATES
+ *
+ * @author bobj
+ */
+public class Dxf2DataEndpoint extends DefaultEndpoint
+{
+
+ protected DataValueSetService dataValueSetService;
+
+ public DataValueSetService getDataValueSetService()
+ {
+ return dataValueSetService;
+ }
+
+ // -------------------------------------------------------------------------------
+ // parameters supported by this endpoint
+ // -------------------------------------------------------------------------------
+
+ protected ImportOptions importOptions;
+
+ public ImportOptions getImportOptions()
+ {
+ return importOptions;
+ }
+
+ public void setImportStrategy( ImportStrategy importStrategy )
+ {
+ importOptions.setImportStrategy(importStrategy.toString());
+ }
+
+ public void setDryRun( Boolean dryRun )
+ {
+ importOptions.setDryRun( dryRun );
+ }
+
+ // -------------------------------------------------------------------------------
+
+ public Dxf2DataEndpoint( String uri, Dxf2Component component, DataValueSetService dataValueSetService )
+ {
+ super( uri, component );
+ importOptions = new ImportOptions();
+ this.dataValueSetService = dataValueSetService;
+ }
+
+ @Override
+ public Producer createProducer() throws Exception
+ {
+ return new Dxf2DataProducer( this );
+ }
+
+ @Override
+ public Consumer createConsumer( Processor prcsr ) throws Exception
+ {
+ throw new UnsupportedOperationException(
+ "You can't consume messages from this endpoint: " + getEndpointUri() );
+ }
+
+ @Override
+ public boolean isSingleton()
+ {
+ return true;
+ }
+}
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2DataProducer.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.integration.components;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.InputStream;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+
+/**
+ *
+ * @author bobj
+ */
+public class Dxf2DataProducer extends DefaultProducer
+{
+
+ public Dxf2DataProducer( Dxf2DataEndpoint endpoint )
+ {
+ super( endpoint );
+ }
+
+ @Override
+ public void process( Exchange exchange ) throws Exception
+ {
+ log.info( this.getEndpoint().getEndpointUri() + " : " + exchange.getIn().getBody() );
+
+ Dxf2DataEndpoint endpoint = (Dxf2DataEndpoint) this.getEndpoint();
+
+ ImportSummary summary = endpoint.getDataValueSetService().saveDataValueSet( (InputStream)exchange.getIn().getBody(),
+ endpoint.getImportOptions() );
+
+ exchange.getOut().setBody(JacksonUtils.toXmlAsString( summary ) );
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataEndpoint.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataEndpoint.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataEndpoint.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,101 @@
+package org.hisp.dhis.integration.components;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.dxf2.metadata.ImportService;
+
+/**
+ * metadataendpoint is created using a uri of the form:
+ * dhis2:metadata?dryRun=true|false
+ *
+ * @author bobj
+ */
+public class Dxf2MetaDataEndpoint extends DefaultEndpoint
+{
+ protected ImportService importService;
+
+ public ImportService getImportService()
+ {
+ return importService;
+ }
+
+ protected ImportOptions options;
+
+ public ImportOptions getImportOptions()
+ {
+ return this.options;
+ }
+
+ // -------------------------------------------------------------------------------
+ // parameters supported by this endpoint
+ // -------------------------------------------------------------------------------
+
+ public void setDryRun( Boolean dryRun )
+ {
+ options.setDryRun( dryRun );
+ }
+
+
+ // -------------------------------------------------------------------------------
+
+ public Dxf2MetaDataEndpoint( String uri, Dxf2Component component, ImportService importService )
+ {
+ super( uri, component );
+ this.importService = importService;
+ options= new ImportOptions();
+ }
+
+// public Dxf2MetaDataEndpoint( String endpointUri )
+// {
+// super( endpointUri );
+// }
+
+ @Override
+ public Producer createProducer() throws Exception
+ {
+ return new Dxf2MetaDataProducer( this );
+ }
+
+ @Override
+ public Consumer createConsumer( Processor prcsr ) throws Exception
+ {
+ throw new UnsupportedOperationException(
+ "You can't consume messages from this endpoint: " + getEndpointUri() );
+ }
+
+ @Override
+ public boolean isSingleton()
+ {
+ return true;
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataProducer.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataProducer.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2MetaDataProducer.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,66 @@
+package org.hisp.dhis.integration.components;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.InputStream;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.dxf2.metadata.ImportService;
+import org.hisp.dhis.dxf2.metadata.MetaData;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ *
+ * @author bobj
+ */
+public class Dxf2MetaDataProducer extends DefaultProducer
+{
+
+ private static final transient Log log = LogFactory.getLog( Dxf2MetaDataProducer.class );
+
+ public Dxf2MetaDataProducer( Dxf2MetaDataEndpoint endpoint)
+ {
+ super( endpoint );
+ }
+
+ @Override
+ public void process( Exchange exchange ) throws Exception
+ {
+ log.info( this.getEndpoint().getEndpointUri() + " : " + exchange.getIn().getBody() );
+ Dxf2MetaDataEndpoint endpoint = (Dxf2MetaDataEndpoint) this.getEndpoint();
+ MetaData metadata = JacksonUtils.fromXml( (InputStream) exchange.getIn().getBody(), MetaData.class );
+
+ ImportSummary summary = endpoint.getImportService().importMetaData(metadata, endpoint.getImportOptions());
+ exchange.getOut().setBody(JacksonUtils.toXmlAsString( summary ) );
+ }
+}
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/converters'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/converters/XMLConverterWrappers.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/converters/XMLConverterWrappers.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/converters/XMLConverterWrappers.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.integration.converters;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.camel.Converter;
+import org.hisp.dhis.dxf2.metadata.MetaData;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+
+/**
+ * This class contains annotated static methods to allow various conversions between
+ * dhis api objects and dxf2 representatation within integration routes
+ *
+ * @author bobj
+ */
+@Converter
+public class XMLConverterWrappers
+{
+ @Converter
+ public static MetaData toMetaData(InputStream inputStream) throws IOException
+ {
+ return JacksonUtils.fromXml( inputStream, MetaData.class );
+ }
+}
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/management'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/management/DHIS2LifecycleStrategy.java'
--- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/management/DHIS2LifecycleStrategy.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/management/DHIS2LifecycleStrategy.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,107 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.hisp.dhis.integration.management;
+
+
+import java.util.Collection;
+import java.util.concurrent.ThreadPoolExecutor;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Component;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ErrorHandlerFactory;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.Service;
+import org.apache.camel.VetoCamelContextStartException;
+import org.apache.camel.spi.LifecycleStrategy;
+import org.apache.camel.spi.RouteContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author bobj
+ */
+public class DHIS2LifecycleStrategy implements LifecycleStrategy
+{
+ private final Log log = LogFactory.getLog( DHIS2LifecycleStrategy.class );
+
+ @Override
+ public void onContextStart(CamelContext context) throws VetoCamelContextStartException
+ {
+ log.info( "Camel context started");
+ // todo: pickup routes from dhis2_home
+ }
+
+ @Override
+ public void onContextStop( CamelContext cc )
+ {
+ log.info( "Camel context stopped");
+ }
+
+ @Override
+ public void onComponentAdd( String name, Component cmpnt )
+ {
+ log.info( "Camel component added: " + name);
+ }
+
+ @Override
+ public void onComponentRemove( String name, Component cmpnt )
+ {
+ log.info( "Camel component removed: " + name);
+ }
+
+ @Override
+ public void onEndpointAdd( Endpoint endpnt )
+ {
+ log.info( "Camel endpoint added: " + endpnt.getEndpointUri());
+ }
+
+ @Override
+ public void onEndpointRemove( Endpoint endpnt )
+ {
+ log.info( "Camel endpoint removed: " + endpnt.getEndpointUri());
+ }
+
+ @Override
+ public void onServiceAdd( CamelContext cc, Service srvc, Route route )
+ {
+ }
+
+ @Override
+ public void onServiceRemove( CamelContext cc, Service srvc, Route route )
+ {
+ }
+
+ @Override
+ public void onRoutesAdd( Collection<Route> clctn )
+ {
+ log.debug( "Camel routes added");
+ }
+
+ @Override
+ public void onRoutesRemove( Collection<Route> clctn )
+ {
+ log.debug( "Camel routes removed");
+ }
+
+ @Override
+ public void onRouteContextCreate( RouteContext rc )
+ {
+ log.debug( "Camel route context created");
+ }
+
+ @Override
+ public void onErrorHandlerAdd( RouteContext rc, Processor prcsr, ErrorHandlerFactory ehf )
+ {
+ log.info( "Camel error handler added: " + ehf.toString());
+ }
+
+ @Override
+ public void onThreadPoolAdd( CamelContext cc, ThreadPoolExecutor tpe, String string, String string1, String string2, String string3 )
+ {
+ log.debug( "Camel threadpool added");
+ }
+}
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/routes'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/dhis'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/dhis/beans.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/dhis/beans.xml 2012-04-16 15:12:08 +0000
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"
+ xmlns:d="http://dhis2.org/schema/dxf/2.0"
+ >
+
+ <bean id="importService" class="org.hisp.dhis.dxf2.metadata.DefaultImportService" />
+
+ <!-- custom lifecycle strategy -->
+ <bean id="lifecyclestrategy" class="org.hisp.dhis.integration.management.DHIS2LifecycleStrategy" />
+
+ <camel:camelContext id="camel-builtin">
+
+ <camel:packageScan>
+ <camel:package>org.hisp.dhis.integration.routes</camel:package>
+ <camel:excludes>**.*Excluded*</camel:excludes>
+ <camel:includes>**.*</camel:includes>
+ </camel:packageScan>
+
+ </camel:camelContext>
+
+</beans>
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/component'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/component/dhis2'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/component/dhis2 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/META-INF/services/org/apache/camel/component/dhis2 2012-04-16 15:12:08 +0000
@@ -0,0 +1,27 @@
+# Copyright (c) 2004-2012, University of Oslo
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+## Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+## Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+## Neither the name of the HISP project nor the names of its contributors may
+# be used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+class=org.hisp.dhis.integration.components.Dxf2Component
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf.xsl'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf.xsl 2012-04-08 11:39:56 +0000
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:msg="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"
+ exclude-result-prefixes="msg">
+
+ <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet">
+ <xd:desc>
+ <xd:p><xd:b>Created on:</xd:b> Jun 8, 2010</xd:p>
+ <xd:p><xd:b>Author:</xd:b> bobj</xd:p>
+ <xd:p>SDMX Cross-Sectional Data to DXF</xd:p>
+ </xd:desc>
+ </xd:doc>
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <!-- This parameter should contain the relative file path to the zip package -->
+ <xsl:param name="zip_url"/>
+ <!-- This parameter should contain the relative file path to the dxf metadata directory -->
+ <xsl:param name="metadata_url_base"/>
+ <!-- This parameter should contain the dxf minor version attribute -->
+ <xsl:param name="dxf_minor_version">1.1</xsl:param>
+ <!-- This parameter should contain the current date -->
+ <xsl:param name="timestamp"/>
+
+ <!-- Construct a "jar" protocol base-uri for finding streams in the zip file-->
+ <xsl:variable name="base-uri" select="concat('jar:file:',$zip_url,'!')"/>
+ <!-- Open the dxf metadata stream-->
+ <xsl:variable name="dxf_meta" select="document(concat($metadata_url_base,'Export.xml'))/dxf"/>
+ <!-- Get comment from header -->
+ <xsl:variable name="comment">
+ <xsl:value-of select="//msg:Header/msg:Sender/msg:Name"/>
+ </xsl:variable>
+
+ <xsl:template match="/">
+ <xsl:element name="dxf" namespace="http://dhis2.org/schema/dxf/1.0">
+ <xsl:attribute name="minor_version"><xsl:value-of select="$dxf_minor_version"/></xsl:attribute>
+
+ <xsl:call-template name="dxf-metadata">
+ <xsl:with-param name="dxf_meta" select="$dxf_meta"/>
+ </xsl:call-template>
+ <!-- Create period metadata for datavalues-->
+ <xsl:element name="periods">
+ <xsl:apply-templates select="//*[local-name()='Group']" mode="create-period"/>
+ </xsl:element>
+ <!-- Process the dataset-->
+ <xsl:element name="dataValues">
+ <xsl:apply-templates select="child::node()/child::node()[local-name()='DataSet']"/>
+ </xsl:element>
+ </xsl:element>
+ </xsl:template>
+
+<!-- This template selects only the required referenced dxf metadata from the dxf metadata stream-->
+ <xsl:template name="dxf-metadata">
+ <!-- McDonalds ... just include them all for now -->
+ <xsl:copy-of select="$dxf_meta/categoryOptions"/>
+ <xsl:copy-of select="$dxf_meta/categories"/>
+ <xsl:copy-of select="$dxf_meta/categoryCombos"/>
+ <xsl:copy-of select="$dxf_meta/categoryOptionCombos"/>
+ <xsl:copy-of select="$dxf_meta/categoryCategoryOptionAssociations"/>
+ <xsl:copy-of select="$dxf_meta/categoryComboCategoryAssociations"/>
+
+ <!--select the unique dataelements referenced by OBS_VALUES with DATAELEMENT attributes-->
+ <xsl:element name="dataElements">
+ <xsl:variable name="dataelements"
+ select="//*[(local-name()='OBS_VALUE') and
+ not(preceding-sibling::*/@DATAELEMENT = @DATAELEMENT)]"/>
+ <xsl:for-each select="$dataelements">
+ <xsl:variable name="dataelementid" select="@DATAELEMENT"/>
+ <xsl:copy-of select="$dxf_meta/dataElements/dataElement[id = $dataelementid]"/>
+ </xsl:for-each>
+ </xsl:element>
+
+ <!--select the unique orgunits referenced by OBS_VALUES with FACILITY attributes-->
+ <xsl:element name="organisationUnits">
+ <xsl:variable name="orgunits"
+ select="//*[(local-name()='OBS_VALUE') and
+ not(preceding-sibling::*/@FACILITY = @FACILITY)]"/>
+ <xsl:for-each select="$orgunits">
+ <xsl:variable name="orgunitid" select="@FACILITY"/>
+ <xsl:copy-of select="$dxf_meta/organisationUnits/organisationUnit[id = $orgunitid]"/>
+ </xsl:for-each>
+ </xsl:element>
+
+ </xsl:template>
+
+ <xsl:template match="*[local-name()='DataSet']">
+ <!-- The namespace uri was formed from the category combo -->
+ <!-- ... payback time ... find the categoryOptionCombo node in dxf metadata -->
+ <xsl:variable name="catcombo"
+ select="substring-before(substring-after(namespace-uri(),'KF_'),':')"/>
+ <!-- catoptcombos is the nodeset containing all categoryOptionCombos for the categorycombo-->
+ <xsl:variable name="catoptcombos"
+ select="$dxf_meta/categoryOptionCombos/categoryOptionCombo[categoryCombo/id=$catcombo]"/>
+<!-- <xsl:message>Dataset catoptcombos = <xsl:value-of select="count($catoptcombos)"/></xsl:message>-->
+ <xsl:apply-templates select="child::node()[local-name()='Group']" mode="data">
+ <xsl:with-param name="catoptcombos" select="$catoptcombos"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="*[local-name()='Group']" mode="data">
+ <xsl:param name="catoptcombos"/>
+ <xsl:variable name="period" select="position()"/>
+ <xsl:apply-templates select="child::node()[local-name()='Section']">
+ <xsl:with-param name="period" select="$period"/>
+ <xsl:with-param name="catoptcombos" select="$catoptcombos"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="*[local-name()='Section']">
+ <xsl:param name="period"></xsl:param>
+ <xsl:param name="catoptcombos"/>
+<!-- <xsl:message>Period: <xsl:value-of select="$period"/></xsl:message>-->
+ <xsl:apply-templates select="child::node()[local-name()='OBS_VALUE']" mode="data">
+ <xsl:with-param name="period" select="$period"/>
+ <xsl:with-param name="catoptcombos" select="$catoptcombos"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="*[local-name()='OBS_VALUE']" mode="data">
+ <xsl:param name="period"/>
+ <xsl:param name="catoptcombos"/>
+
+ <xsl:element name="dataValue">
+ <xsl:attribute name="dataElement"><xsl:value-of select="@DATAELEMENT"/></xsl:attribute>
+ <xsl:attribute name="period"><xsl:value-of select="$period"/></xsl:attribute>
+ <xsl:attribute name="source"><xsl:value-of select="@FACILITY"/></xsl:attribute>
+ <xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
+ <xsl:attribute name="timeStamp">2010-01-01</xsl:attribute>
+ <xsl:attribute name="comment"><xsl:value-of select="$comment"/></xsl:attribute>
+
+ <!-- Find all categoryoption attributes-->
+ <xsl:variable name="keys"
+ select="@*[not(local-name()='DATAELEMENT' or local-name()='FACILITY' or local-name()='value' or local-name()='VALUE_TYPE')]"/>
+ <!--<xsl:for-each select="$keys">
+ <xsl:message><xsl:value-of select="local-name()"/>: <xsl:value-of select="."/></xsl:message>
+ </xsl:for-each>-->
+ <xsl:attribute name="categoryOptionCombo"><xsl:call-template name="find-catoptcombo">
+ <xsl:with-param name="keys" select="$keys"/>
+ <xsl:with-param name = "last-key" select="count($keys)"/>
+ <xsl:with-param name="catoptcombos" select="$catoptcombos"></xsl:with-param>
+ </xsl:call-template></xsl:attribute>
+
+
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template name="find-catoptcombo">
+ <xsl:param name="keys"/>
+ <xsl:param name="last-key"/>
+ <xsl:param name="catoptcombos"/>
+
+<!-- <xsl:message>key: <xsl:value-of select="$keys[$last-key]"/></xsl:message>
+ <xsl:message>number of last key: <xsl:value-of select="$last-key"/></xsl:message>-->
+<!-- <xsl:message><xsl:value-of select="count($catoptcombos)"/></xsl:message>-->
+
+ <xsl:variable name="sub-catoptcombos"
+ select="$catoptcombos[categoryOptions/categoryOption/id=$keys[$last-key]]"></xsl:variable>
+
+ <xsl:if test="$last-key=0">
+ <xsl:value-of select="$catoptcombos/id"/>
+ </xsl:if>
+
+ <xsl:if test="$last-key>0">
+ <xsl:call-template name="find-catoptcombo">
+ <xsl:with-param name="keys" select="$keys"/>
+ <xsl:with-param name="last-key" select="$last-key - 1"></xsl:with-param>
+ <xsl:with-param name="catoptcombos" select="$sub-catoptcombos"></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="*[local-name()='Group']" mode="create-period">
+<!-- Create period id based on the position() of the Group-->
+ <xsl:variable name="period" select="@TIME_PERIOD"/>
+ <xsl:variable name="start"><xsl:value-of select="$period"/>-01</xsl:variable>
+ <xsl:variable name="end"><xsl:value-of select="$period"/>-<xsl:call-template name="last-day-of-month">
+ <xsl:with-param name="period" select="$period"/>
+ </xsl:call-template></xsl:variable>
+ <period>
+ <id><xsl:value-of select="position()"/></id>
+ <!-- TODO: This periodType needs to be made correct-->
+ <periodType>Monthly</periodType>
+ <startDate><xsl:value-of select="$start"/></startDate>
+ <endDate><xsl:value-of select="$end"/></endDate>
+ </period>
+ <xsl:message>Created period: <xsl:value-of select="$start"/>, <xsl:value-of select="$end"/></xsl:message>
+ </xsl:template>
+
+ <!-- Find last day of month
+ (Algorithm from 'XSLT CookBook, 2nd Edition')-->
+ <xsl:template name="last-day-of-month">
+ <xsl:param name="period"/>
+ <xsl:variable name="month" select="substring-after($period,'-')"/>
+ <xsl:variable name="year" select="substring-before($period,'-')"/>
+ <xsl:message>Month: <xsl:value-of select="$month"/></xsl:message>
+ <xsl:message>Year: <xsl:value-of select="$year"/></xsl:message>
+
+ <xsl:choose>
+ <xsl:when
+ test="$month = 2 and
+ not($year mod 4) and
+ ($year mod 100 or not($year mod 400) ) ">
+ <xsl:value-of select="29"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
+ select="substring('312831303130313130313031' ,
+ 2 * $month - 1, 2) "
+ />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+</xsl:stylesheet>
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf2.xsl'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf2.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/cross2dxf2.xsl 2012-04-08 11:39:56 +0000
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:d="http://dhis2.org/schema/dxf/2.0"
+ version="1.0">
+
+ <xsl:output method="xml" indent="yes" />
+
+ <xsl:template match="/">
+ <d:dxf>
+ <d:dataValueSets>
+ <xsl:for-each select="//*[local-name()='Group']">
+ <xsl:variable name="dataset"
+ select="substring-before(substring-after(substring-after(namespace-uri(),'='),':'),':')"/>
+ <xsl:variable name="period" select="@*[local-name()='TIME_PERIOD']"/>
+ <d:dataValueSet period='{$period}' idScheme='CODE' dataset='{$dataset}'>
+
+ <xsl:for-each select="*[local-name()='Section']">
+ <xsl:for-each select="*[local-name()='OBS_VALUE']">
+ <xsl:variable name="orgunit" select="@*[local-name()='FACILITY']"/>
+ <xsl:variable name="dataElement" select="@*[local-name()='DATAELEMENT']"/>
+ <xsl:variable name="value" select="@*[local-name()='value']"/>
+ <d:dataValue dataElement='{$dataElement}' orgunit='{$orgunit}' value='{$value}' />
+ </xsl:for-each>
+ </xsl:for-each>
+ </d:dataValueSet>
+ </xsl:for-each>
+ </d:dataValueSets>
+ </d:dxf>
+ </xsl:template>
+
+</xsl:stylesheet>
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/gml2dxf.xsl'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/gml2dxf.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/gml2dxf.xsl 2012-04-08 11:39:56 +0000
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gml="http://www.opengis.net/gml"
+>
+
+<xsl:param name="decimalPlaces">4</xsl:param>
+
+<xsl:template match="gml:coordinates">
+ <coordinatesTuple>
+ <xsl:value-of select="dhis:gmlToCoords(normalize-space(.),$decimalPlaces)"
+ disable-output-escaping="yes"
+ xmlns:dhis="org.hisp.dhis.importexport.xml.Util" />
+ </coordinatesTuple>
+</xsl:template>
+
+<xsl:template match="gml:Polygon">
+ <feature type="Polygon">
+ <xsl:apply-templates select=".//gml:coordinates"/>
+ </feature>
+</xsl:template>
+
+<xsl:template match="gml:MultiPolygon">
+ <feature type="MultiPolygon">
+ <xsl:apply-templates select=".//gml:coordinates"/>
+ </feature>
+</xsl:template>
+
+<xsl:template match="gml:Point">
+ <feature type="Point">
+ <xsl:apply-templates select=".//gml:coordinates"/>
+ </feature>
+</xsl:template>
+
+<xsl:template match="gml:featureMember">
+ <xsl:variable name="name" select=".//*[local-name()='Name' or local-name()='NAME' or local-name()='name']"/>
+ <organisationUnit>
+ <id>0</id>
+ <uuid/>
+ <name><xsl:value-of select="$name"/></name>
+ <shortName><xsl:value-of select="$name"/></shortName>
+ <code/>
+ <openingDate/>
+ <closedDate/>
+ <active>true</active>
+ <comment/>
+ <geoCode/>
+ <xsl:apply-templates select="./child::node()/child::node()/gml:Polygon|./child::node()/child::node()/gml:MultiPolygon|./child::node()/child::node()/gml:Point"/>
+ <lastUpdated/>
+ </organisationUnit>
+</xsl:template>
+
+<xsl:template match="/">
+<dxf xmlns="http://dhis2.org/schema/dxf/1.0" minorVersion="1.1">
+<organisationUnits>
+ <xsl:apply-templates select=".//gml:featureMember"/>
+</organisationUnits>
+</dxf>
+</xsl:template>
+
+
+</xsl:stylesheet>
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/imr2dxf.xsl'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/imr2dxf.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/imr2dxf.xsl 2012-04-08 11:39:56 +0000
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:gm="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/genericmetadata"
+ version="1.0">
+
+ <xsl:output indent="yes" method="xml"/>
+
+ <xsl:key name="indicator-types"
+ match="/Indicators/Indicator[not (DataType = preceding::Indicator/DataType)]" use="DataType"/>
+
+ <!--Construct tree of unique indicator types -->
+ <xsl:template name="indicator-types">
+ <xsl:element name="indicatorTypes">
+ <xsl:for-each
+ select="/Indicators/Indicator[not (DataType = preceding::Indicator/DataType)]">
+ <xsl:element name="indicatorType">
+ <xsl:element name="name">
+ <xsl:value-of select="DataType"/>
+ </xsl:element>
+ <xsl:element name="id">
+ <xsl:value-of select="IndicatorId"/>
+ </xsl:element>
+ <!-- This will have to be edited manually -->
+ <xsl:element name="factor">1</xsl:element>
+ </xsl:element>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template name="indicators">
+ <xsl:element name="indicators">
+ <xsl:for-each select="//gm:AttributeValueSet">
+ <xsl:message>New indicator</xsl:message>
+ <indicator>
+ <id>
+ <xsl:value-of select="position()"/>
+ </id>
+ <uuid/>
+ <name>
+ <xsl:value-of select="gm:ReportedAttribute[@conceptID='SHORT_NAME']/gm:Value"/>
+ </name>
+ <alternativeName/>
+ <!--ShortName is a pain ... imr has a few of value "short name" ... dhis requires uniquess :-( -->
+ <shortName>
+ <!-- <xsl:if test="contains(Shortname,'short name')">
+ <xsl:value-of select="substring(Name,1,25)"/>
+ </xsl:if>
+ <xsl:if test="not(contains(Shortname,'short name'))">
+ <xsl:value-of select="substring(ShortName,1,25)"/>
+ </xsl:if>-->
+
+ <!-- Bugger it - random strings ...-->
+ <xsl:value-of select="gm:ReportedAttribute[@conceptID='SHORT_NAME']/gm:Value"/>
+ </shortName>
+ <code/>
+ <description>
+ <xsl:value-of select="gm:ReportedAttribute[@conceptID='_DESCRIPTION']/gm:Value"/>
+ <!-- Rationale: <xsl:value-of select="Rationale"/>
+ Preferred Data sources: <xsl:value-of select="PreferredDataSources"/>-->
+ </description>
+ <xsl:variable name="DataType" select="DataType"/>
+ <annualized/>
+ <indicatorType>1
+<!-- <xsl:value-of select="key('indicator-types',$DataType)/IndicatorId"/>-->
+ </indicatorType>
+ </indicator>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="/">
+ <xsl:element name="dxf">
+ <xsl:call-template name="indicator-types"/>
+ <xsl:call-template name="indicators"/>
+ </xsl:element>
+ </xsl:template>
+
+</xsl:stylesheet>
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/transforms.xml'
--- dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/transforms.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/main/resources/transform/transforms.xml 2012-04-08 11:39:56 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<transforms>
+ <transform tag="{http://ogr.maptools.org/}FeatureCollection">
+ <xslt>gml2dxf.xsl</xslt>
+ <description>GML to DXF orgunits</description>
+ </transform>
+ <transform tag="{http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message}CrossSectionalData">
+ <xslt>cross2dxf2.xsl</xslt>
+ <description>SDMX-HD Cross Sectional Data Import</description>
+ </transform>
+ <transform tag="{http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message}GenericMetadata">
+ <xslt>imr2dxf.xsl</xslt>
+ <description>SDMX-HD Cross Sectional Data Import</description>
+ </transform>
+</transforms>
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/java'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration'
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java'
--- dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.integration.dxf2;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.InputStream;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Dxf2ComponentTest extends CamelSpringTestSupport {
+
+ // just send some strings to the route and check they arrived
+ // note we can't send to the actual endpoints yet till we wire in dhis2 services to the test context.
+ // So for now this is only testing component endpoint creation :-(
+ @Test
+ public void testDxf2() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(3);
+ //template.sendBody("direct:test","<dxf2 xmlns='http://dhis2.org/schema/dxf/2.0'/>");
+ //template.sendBody("direct:test","<dxf2 xmlns='http://dhis2.org/schema/dxf/2.0'/>");
+ //template.sendBody("direct:test","<dxf2 xmlns='http://dhis2.org/schema/dxf/2.0'/>");
+ //assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:test")
+ .convertBodyTo( InputStream.class)
+ .to("dhis2:data?dryRun=true&importStrategy=NEW_AND_UPDATES")
+ .to("mock:result");
+ }
+ };
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext()
+ {
+ AbstractApplicationContext springContext = new ClassPathXmlApplicationContext("test-context.xml");
+
+ return springContext;
+ }
+}
=== added directory 'dhis-2/dhis-services/dhis-service-integration/src/test/resources'
=== added file 'dhis-2/dhis-services/dhis-service-integration/src/test/resources/test-context.xml'
--- dhis-2/dhis-services/dhis-service-integration/src/test/resources/test-context.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/test/resources/test-context.xml 2012-04-16 15:12:08 +0000
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"
+ xmlns:d="http://dhis2.org/schema/dxf/2.0"
+ >
+
+ <!-- custom lifecycle strategy -->
+ <bean id="lifecyclestrategy" class="org.hisp.dhis.integration.management.DHIS2LifecycleStrategy" />
+
+ <camel:camelContext id="camel-builtin">
+
+ <camel:packageScan>
+ <camel:package>org.hisp.dhis.integration.routes</camel:package>
+ <camel:excludes>**.*Excluded*</camel:excludes>
+ <camel:includes>**.*</camel:includes>
+ </camel:packageScan>
+
+ </camel:camelContext>
+
+</beans>
=== modified file 'dhis-2/dhis-services/pom.xml'
--- dhis-2/dhis-services/pom.xml 2012-02-20 12:01:56 +0000
+++ dhis-2/dhis-services/pom.xml 2012-04-08 11:39:56 +0000
@@ -26,6 +26,7 @@
<module>dhis-service-patient</module>
<module>dhis-service-mobile</module>
<module>dhis-service-sms</module>
+ <module>dhis-service-integration</module>
</modules>
<dependencies>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/pom.xml'
--- dhis-2/dhis-web/dhis-web-importexport/pom.xml 2012-04-13 22:28:40 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/pom.xml 2012-04-16 15:12:08 +0000
@@ -35,6 +35,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-integration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-administration</artifactId>
</dependency>
<dependency>
=== added directory 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration'
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/AddRouteAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/AddRouteAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/AddRouteAction.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,99 @@
+package org.hisp.dhis.importexport.action.integration;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+import com.opensymphony.xwork2.Action;
+import java.io.File;
+import java.io.FileInputStream;
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.RoutesDefinition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Bob Jolliffe
+ * @version $Id$
+ */
+public class AddRouteAction
+ implements Action
+{
+ private static final Log log = LogFactory.getLog( AddRouteAction.class );
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ CamelContext builtinCamelContext;
+
+ public void setBuiltinCamelContext(CamelContext camelContext) {
+ this.builtinCamelContext = camelContext;
+ }
+
+ private File file;
+
+ public void setUpload( File file )
+ {
+ this.file = file;
+ }
+
+ private String fileName;
+
+ public void setUploadFileName( String fileName )
+ {
+ this.fileName = fileName;
+ }
+
+ private String contentType;
+
+ public void setUploadContentType( String contentType )
+ {
+ this.contentType = contentType;
+ }
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ log.info("Uploaded " + fileName);
+ if (file!=null) {
+ FileInputStream is = new FileInputStream(file);
+ try {
+ RoutesDefinition routes = builtinCamelContext.loadRoutesDefinition(is);
+ builtinCamelContext.addRouteDefinitions(routes.getRoutes());
+ }
+ catch (Exception e )
+ {
+ log.info("Unable to load route: " + e.getMessage());
+ return ERROR;
+ }
+ }
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java 2012-04-08 11:41:33 +0000
@@ -0,0 +1,71 @@
+package org.hisp.dhis.importexport.action.integration;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+import com.opensymphony.xwork2.Action;
+import java.util.List;
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.RouteDefinition;
+
+/**
+ * @author Bob Jolliffe
+ * @version $Id$
+ */
+public class DisplayRoutesAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ CamelContext builtinCamelContext;
+
+ public void setBuiltinCamelContext(CamelContext camelContext) {
+ this.builtinCamelContext = camelContext;
+ }
+
+ List<RouteDefinition> routeDefinitions;
+
+ public List<RouteDefinition> getRouteDefinitions() {
+ return routeDefinitions;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ routeDefinitions = builtinCamelContext.getRouteDefinitions();
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/ShowAddRouteFormAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/ShowAddRouteFormAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/ShowAddRouteFormAction.java 2012-04-16 15:12:08 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.importexport.action.integration;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+import com.opensymphony.xwork2.Action;
+import java.io.File;
+import java.io.FileInputStream;
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.RoutesDefinition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Bob Jolliffe
+ * @version $Id$
+ */
+public class ShowAddRouteFormAction
+ implements Action
+{
+ private static final Log log = LogFactory.getLog( ShowAddRouteFormAction.class );
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-04-13 22:28:40 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-04-16 15:12:08 +0000
@@ -159,4 +159,11 @@
<property name="configurationManager" ref="org.hisp.dhis.importexport.IbatisConfigurationManager" />
</bean>
+ <bean id="org.hisp.dhis.importexport.action.integration.DisplayRoutesAction" class="org.hisp.dhis.importexport.action.integration.DisplayRoutesAction">
+ <property name="builtinCamelContext" ref="camel-builtin"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.importexport.action.integration.AddRouteAction" class="org.hisp.dhis.importexport.action.integration.AddRouteAction">
+ <property name="builtinCamelContext" ref="camel-builtin"/>
+ </bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-04-15 19:45:25 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-04-16 15:12:08 +0000
@@ -20,17 +20,17 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-importexport/importDataValue.vm</param>
<param name="menu">/dhis-web-importexport/mainMenu.vm</param>
- <param name="javascripts">javascript/importDataValue.js</param>
+ <param name="javascripts">javascript/importDataValue.js</param>
</action>
- <action name="importDataValue" class="org.hisp.dhis.importexport.action.datavalue.ImportDataValueAction">
- <result name="success" type="redirect">displayImportDataValueForm.action?running=true&importFormat=${importFormat}</result>
- <interceptor-ref name="fileUploadStack" />
- </action>
+ <action name="importDataValue" class="org.hisp.dhis.importexport.action.datavalue.ImportDataValueAction">
+ <result name="success" type="redirect">displayImportDataValueForm.action?running=true&importFormat=${importFormat}</result>
+ <interceptor-ref name="fileUploadStack" />
+ </action>
<action name="getDataValueImportSummary" class="org.hisp.dhis.importexport.action.GetImportSummaryAction">
<result name="success" type="velocity">/dhis-web-importexport/importSummary.vm</result>
- <param name="onExceptionReturn">plainTextError</param>
+ <param name="onExceptionReturn">plainTextError</param>
</action>
<!-- Data value export -->
@@ -43,7 +43,7 @@
</action>
<action name="exportDataValue" class="org.hisp.dhis.importexport.action.datavalue.ExportDataValueAction">
- <result name="success" type="outputStreamResult" />
+ <result name="success" type="outputStreamResult" />
</action>
<!-- Menu -->
@@ -221,6 +221,28 @@
<result name="success" type="velocity-xml">/dhis-web-importexport/responseSuccess.vm</result>
<result name="input" type="velocity-xml">/dhis-web-importexport/responseInput.vm</result>
</action>
+
+ <action name="displayRoutes" class="org.hisp.dhis.importexport.action.integration.DisplayRoutesAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-importexport/displayRoutes.vm</param>
+ <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+ <param name="javascripts" />
+ </action>
+
+ <action name="showAddRouteForm" class="org.hisp.dhis.importexport.action.integration.ShowAddRouteFormAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-importexport/showAddRouteForm.vm</param>
+ <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+ <param name="javascripts" />
+ </action>
+
+ <action name="addRoute" class="org.hisp.dhis.importexport.action.integration.AddRouteAction">
+ <result name="success" type="redirect">displayRoutes.action</result>
+ <result name="error" type="redirect">showAddRouteForm.action</result>
+ <interceptor-ref name="fileUploadStack" />
+ <param name="javascripts" />
+ </action>
+
</package>
</struts>
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm 2012-04-16 15:12:08 +0000
@@ -0,0 +1,33 @@
+## Velocity Template.
+
+<h3>$i18n.getString( "integration_routes" )</h3>
+
+<div>
+ <input type="button" value="$i18n.getString( 'add_route' )" onclick="window.location.href='showAddRouteForm.action'"/>
+</div>
+
+<table class="listTable" id="routesList" width='100%'>
+ <col/>
+ <col/>
+ <thead>
+ <tr>
+ <th>$i18n.getString( "route" )</th>
+ <th>$i18n.getString( "description" )</th>
+ <th class="{sorter: false}" style="width:80px;">$i18n.getString( "operations" )</th>
+ </tr>
+ </thead>
+ <tbody id="list">
+ #set( $mark = false )
+ #foreach( $routeDefinition in $routeDefinitions )
+ <!--<td>$routeDefinition.toString()<td>-->
+ <tr #alternate( $mark )>
+ <td>$encoder.htmlEncode( $routeDefinition.id )</td>
+ <td>$encoder.htmlEncode( $routeDefinition.description.text )</td>
+ <td style="text-align:right">
+ <a href="javascript:notImplemented( $routeDefinition.id )" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
+ <a href="javascript:notImplemented( $routeDefinition.id )" title="$i18n.getString( 'enable' )"><img src="../images/check.png" alt="$i18n.getString( 'enable' )"/></a>
+ <a href="javascript:notImplemented( $routeDefinition.id )" title="$i18n.getString( 'disable' )"><img src="../images/cross.png" alt="$i18n.getString( 'disable' )"/></a>
+ </td>
+ </tr>
+ #end
+</table>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm 2012-04-15 19:45:25 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/index.vm 2012-04-16 15:12:08 +0000
@@ -8,15 +8,17 @@
<h3>$i18n.getString( "dhis-web-maintenance-datadictionary" )</h3>
<ul class="introList">
- #introListImgItem( "setImportFormat.action?importFormat=DXF" "import" "import" )
- #introListImgItem( "displayImportDataValueForm.action?importFormat=xml" "xml_data_import" "import" )
- #introListImgItem( "displayImportDataValueForm.action?importFormat=csv" "csv_data_import" "import" )
- #introListImgItem( "displayExternalImportMenu.action" "dhis14_import" "import" )
+ #introListImgItem( "setImportFormat.action?importFormat=DXF" "import" "import" )
+ #introListImgItem( "displayImportDataValueForm.action?importFormat=xml" "xml_data_import" "import" )
+ #introListImgItem( "displayImportDataValueForm.action?importFormat=csv" "csv_data_import" "import" )
+ #introListImgItem( "displayExternalImportMenu.action" "dhis14_import" "import" )
#introListImgItem( "displayDataValueExportForm.action?exportFormat=DXF" "data_export" "export" )
#introListImgItem( "displayMetaDataExportForm.action?exportFormat=DXF" "metadata_export" "export" )
#introListImgItem( "displayDetailedMetaDataExportForm.action?exportFormat=DXF" "detailed_metadata_export" "export" )
#introListImgItem( "displayExternalExportMenu.action" "export_to_other_systems" "export" )
- #introListImgItem( "displayConfigDhis14Form.action" "dhis14_file_configuration" "configuration" )
-</ul>
\ No newline at end of file
+ #introListImgItem( "displayConfigDhis14Form.action" "dhis14_file_configuration" "configuration" )
+
+ #introListImgItem( "displayRoutes.action" "list_integration_routes" "configuration" )
+</ul>
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/routes.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/routes.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/routes.js 2012-04-09 22:15:46 +0000
@@ -0,0 +1,7 @@
+// -------------------------------------------------------------------------
+// routes.js
+// -------------------------------------------------------------------------
+
+function notImplemented () {
+}
+
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm 2012-04-15 19:45:25 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/mainMenu.vm 2012-04-16 15:12:08 +0000
@@ -23,3 +23,9 @@
<li><a href="displayConfigDhis14Form.action">$i18n.getString( "dhis14_file_configuration" ) </a></li>
</ul>
+<h2>$i18n.getString( "integration" ) </h2>
+
+<ul>
+ <li><a href="displayRoutes.action">$i18n.getString( "integration_configuration" ) </a></li>
+</ul>
+
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/showAddRouteForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/showAddRouteForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/showAddRouteForm.vm 2012-04-16 15:12:08 +0000
@@ -0,0 +1,23 @@
+<h3>$i18n.getString( "create_new_route" )</h3>
+<form id="addRouteForm" action="addRoute.action" method="post" enctype="multipart/form-data">
+
+<table>
+ <col style="width: 200px"/>
+ <col style="width: 350px"/>
+ <col/>
+ <col style="width: 350px"/>
+
+ <tr>
+ <th colspan="4">$i18n.getString( "details" )</th>
+ </tr>
+
+ <tr>
+ <td colspan="2"><input type="file" id="upload" name="upload" size="45"></td>
+ </tr>
+</table>
+<p>
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:10em" />
+ <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em" />
+</p>
+
+</form>
=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml 2012-04-14 18:32:00 +0000
+++ dhis-2/pom.xml 2012-04-16 15:12:08 +0000
@@ -213,6 +213,11 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-integration</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-mapping</artifactId>
<version>${project.version}</version>
</dependency>
@@ -458,11 +463,6 @@
<version>1.3</version>
</dependency>
<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
- <version>2.8.0</version>
- </dependency>
- <dependency>
<groupId>jep</groupId>
<artifactId>jep</artifactId>
<version>2.24</version>
@@ -820,6 +820,32 @@
</exclusions>
</dependency>
+ <!-- Apache Camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mail</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-http</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-quartz</artifactId>
+ <version>2.9.1</version>
+ </dependency>
</dependencies>
</dependencyManagement>