dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33409
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17043: Removed xml package from import-export service
------------------------------------------------------------
revno: 17043
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-10 18:00:19 +0200
message:
Removed xml package from import-export service
removed:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/analysis/
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/analysis/ImportAnalyserTest.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFOrganisationUnitsTest.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/GML2DXFTest.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/xml/
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/xml/UtilTest.java
modified:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.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
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2014-07-18 11:39:47 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2014-10-10 16:00:19 +0000
@@ -31,25 +31,18 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipFile;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
import org.amplecode.staxwax.factory.XMLFactory;
import org.amplecode.staxwax.reader.XMLReader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.ProcessState;
import org.hisp.dhis.importexport.dxf.converter.DXFConverter;
-import org.hisp.dhis.importexport.xml.XMLPreConverter;
import org.hisp.dhis.importexport.zip.ZipAnalyzer;
import org.hisp.dhis.system.process.OutputHolderState;
import org.hisp.dhis.system.util.StreamUtils;
@@ -69,13 +62,6 @@
// Dependencies
// -------------------------------------------------------------------------
- private XMLPreConverter preConverter;
-
- public void setPreConverter( XMLPreConverter preConverter )
- {
- this.preConverter = preConverter;
- }
-
private DXFConverter converter;
public void setConverter( DXFConverter converter )
@@ -145,47 +131,15 @@
throw new ImportException( "Error processing input stream", ex );
}
- QName documentRootName = preConverter.getDocumentRoot( xmlDataStream );
-
XMLReader dxfReader = null;
- File transformOutput = null;
- BufferedInputStream dxfInStream = null;
try
{
- String rootLocalName = documentRootName.getLocalPart();
- String rootNameSpace = documentRootName.getNamespaceURI();
-
- if ( rootLocalName.equals( DXFConverter.DXFROOT ) )
- {
- log.info( "Importing DXF native stream" ); // Native DXF stream, no transform required
- dxfReader = XMLFactory.getXMLReader( xmlDataStream );
- }
- else
- {
- log.info( "Transforming stream" );
- transformOutput = File.createTempFile( "TRANSFORM_", ".xml" );
- Source source = new StreamSource( xmlDataStream );
- FileOutputStream transformOutStream = new FileOutputStream( transformOutput );
- StreamResult result = new StreamResult( transformOutStream );
- String xsltIdentifierTag = documentRootName.toString();
- log.debug( "Tag for transformer: " + xsltIdentifierTag );
-
- preConverter.transform( source, result, xsltIdentifierTag, tempZipFile, null );
- transformOutStream.flush();
- transformOutStream.close();
-
- log.info( "Transform successful" );
- dxfInStream =
- new BufferedInputStream(new FileInputStream( transformOutput ));
- rootNameSpace = preConverter.getDocumentRoot( dxfInStream ).getNamespaceURI();
- dxfReader = XMLFactory.getXMLReader( dxfInStream );
- }
-
- log.debug( "Sending DXFv1 to converter, root local name: " + rootLocalName + ", name space: " + rootNameSpace );
+ dxfReader = XMLFactory.getXMLReader( xmlDataStream );
+
converter.read( dxfReader, params, state );
}
- catch ( IOException ex )
+ catch ( Exception ex )
{
log.error( ex );
@@ -197,10 +151,6 @@
{
dxfReader.closeReader();
}
- if ( transformOutput != null )
- {
- transformOutput.delete();
- }
if ( tempZipFile != null )
{
tempZipFile.delete();
@@ -208,10 +158,6 @@
try
{
- if ( dxfInStream != null )
- {
- dxfInStream.close();
- }
if ( zipFile != null )
{
zipFile.close();
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java 1970-01-01 00:00:00 +0000
@@ -1,119 +0,0 @@
-package org.hisp.dhis.importexport.xml;
-
-/*
- * Copyright (c) 2004-2014, 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.amplecode.staxwax.framework.XPathFilter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.external.location.LocationManager;
-import org.hisp.dhis.external.location.LocationManagerException;
-import org.hisp.dhis.importexport.ImportException;
-import org.springframework.core.io.ClassPathResource;
-import org.w3c.dom.Node;
-
-/**
- * An XSLT locator based on the dhis LocationManager
- *
- * It depends on a simple XML transformers configration file which maps tags to
- * stylesheets.
- *
- * @author bobj
- * @version created 30-Apr-2010
- */
-public class LocManagerXSLTLocator
- implements XSLTLocator
-{
- private static final Log log = LogFactory.getLog( LocManagerXSLTLocator.class );
-
- private static final String TRANSFORMER_MAP = "transform/transforms.xml";
-
- private LocationManager locationManager;
-
- public void setLocationManager( LocationManager locationManager )
- {
- this.locationManager = locationManager;
- }
-
- @Override
- public InputStream getTransformerByTag( String identifier )
- throws ImportException
- {
- Node transformerNode = null;
-
- String xpath = "/transforms/transform[@tag='" + identifier + "']/xslt";
- log.debug( "xpath search: " + xpath );
-
- // ---------------------------------------------------------------------
- // Search file system
- // ---------------------------------------------------------------------
-
- try
- {
- transformerNode = XPathFilter.findNode( locationManager.getInputStream( TRANSFORMER_MAP ), xpath );
- }
- catch ( LocationManagerException ex )
- {
- // Not found, proceed to search in classpath
- }
-
- if ( transformerNode != null )
- {
- log.info( "Loading transformer from file system: " + transformerNode.getTextContent() );
-
- try
- {
- return locationManager.getInputStream( "transform/" + transformerNode.getTextContent() );
- }
- catch ( LocationManagerException ex )
- {
- throw new ImportException( "Transformer mapped for format but could not be found on file system: " + transformerNode.getTextContent() );
- }
- }
-
- // ---------------------------------------------------------------------
- // Search classpath
- // ---------------------------------------------------------------------
-
- try
- {
- transformerNode = XPathFilter.findNode( new ClassPathResource( TRANSFORMER_MAP ).getInputStream(), xpath );
-
- log.info( "Loading transformer from classpath: " + transformerNode.getTextContent() );
-
- return new ClassPathResource( "transform/" + transformerNode.getTextContent() ).getInputStream();
- }
- catch ( IOException ex )
- {
- throw new ImportException( "No transformer configured for this format: " + identifier );
- }
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java 1970-01-01 00:00:00 +0000
@@ -1,100 +0,0 @@
-package org.hisp.dhis.importexport.xml;
-
-/*
- * Copyright (c) 2004-2014, 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.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-
-import org.apache.commons.math.util.MathUtils;
-
-/**
- *
- * @author bobj
- */
-public class Util
-{
- /**
- * Compensating for Excel wonky storage for dates
- *
- * @param xltimestr the number of days since 1/1/1900 as undertood by excel
- * @return
- */
- public static String date( String xltimestr )
- {
- try
- {
- // the number of days since 1/1/1900
- Integer xldays = new Integer( xltimestr );
-
- // the beginning of excel time is 1/1/1900
- Calendar cal = new GregorianCalendar();
- cal.set( 1900, 0, 1 );
- // cal.add( Calendar.DAY_OF_MONTH, 20 );
- cal.add( Calendar.DAY_OF_MONTH, xldays.intValue() - 2 );
- return cal.getTime().toString();
- }
- catch ( Exception ex )
- {
- return "";
- }
- }
-
- /**
- * Tokenizer to convert coordinates in GML to a sequence of
- * <coord>nnn,nnn</coord>
- *
- * @param coordinates
- * @return
- */
- public static String gmlToCoords( String coordinates, String decimalPlacesAsString )
- throws ParseException
- {
- NumberFormat nf = NumberFormat.getInstance( Locale.ENGLISH );
-
- int decimals = Integer.parseInt( decimalPlacesAsString );
-
- StringBuilder sb = new StringBuilder();
- String[] coords = coordinates.split( "\\s" );
-
- for ( String coordAsString : coords )
- {
- String[] latlon = coordAsString.split( "," );
- double lat = nf.parse( latlon[0] ).doubleValue();
- double lon = nf.parse( latlon[1] ).doubleValue();
- sb.append( "<coord>" );
- sb.append( MathUtils.round( lat, decimals ) + "," + MathUtils.round( lon, decimals ) );
- sb.append( "</coord>" );
- }
-
- return sb.toString();
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java 1970-01-01 00:00:00 +0000
@@ -1,174 +0,0 @@
-package org.hisp.dhis.importexport.xml;
-
-/*
- * Copyright (c) 2004-2014, 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.BufferedInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.stream.StreamSource;
-
-import org.amplecode.staxwax.factory.XMLFactory;
-import org.amplecode.staxwax.reader.XMLReader;
-import org.amplecode.staxwax.transformer.TransformerTask;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.importexport.ImportException;
-
-/**
- * GenericXMLConvertor transforms imported foreign XML to dxf.
- *
- * @author bobj
- */
-public class XMLPreConverter
-{
- private final Log log = LogFactory.getLog( XMLPreConverter.class );
-
- public static final int BUFFER_SIZE = 2000;
-
- public static final String TRANSFORMERS_CONFIG = "transform/transforms.xml";
-
- // -------------------------------------------------------------------------
- // Named XSLT parameters available to xslt stylesheets
- // -------------------------------------------------------------------------
-
- // Current timestamp
- public static final String TIMESTAMP = "timestamp";
-
- // url base where dxf metadata snapshots are found
- public static final String METADATA_URL_BASE = "metadata_url_base";
-
- // current dhis2 user
- public static final String DHIS_USER = "username";
-
- // url of zip file containing stream (may be null)
- public static final String ZIP_URL = "zip_url";
-
- public static final String defaultMetadataBase = "metadata/";
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private XSLTLocator xsltLocator;
-
- public void setXsltLocator( XSLTLocator xsltLocator )
- {
- this.xsltLocator = xsltLocator;
- }
-
- private URIResolver dhisResolver;
-
- public void setDhisResolver( URIResolver dhisResolver )
- {
- this.dhisResolver = dhisResolver;
- }
-
- public QName getDocumentRoot( BufferedInputStream xmlDataStream )
- throws ImportException
- {
- QName rootName = null;
-
- try
- {
- // buffer enough space to read root elemen
- xmlDataStream.mark( BUFFER_SIZE );
-
- XMLReader reader = XMLFactory.getXMLReader( xmlDataStream );
-
- reader.moveToStartElement();
- rootName = reader.getElementQName();
-
- xmlDataStream.reset();
- }
- catch ( Exception ex )
- {
- throw new ImportException( "Couldn't locate document root element", ex );
- }
-
- return rootName;
- }
-
- /**
- * Performs transform on stream
- *
- * @param source the input
- * @param result the result
- * @param xsltTag identifier used to look up xslt stylesheet
- * @param zipFile optional zipfile when importing from zip
- * @param userName the dhis username
- * @throws ImportException
- */
- public void transform( Source source, Result result, String xsltTag, File zipFile, String userName )
- throws ImportException
- {
- InputStream sheetStream = xsltLocator.getTransformerByTag( xsltTag );
- Source sheet = new StreamSource( sheetStream );
-
- log.debug( "Populating xslt parameters" );
- Map<String, String> xsltParams = new HashMap<>();
-
- if ( userName != null )
- {
- xsltParams.put( DHIS_USER, userName );
- }
- if ( zipFile != null )
- {
- xsltParams.put( ZIP_URL, zipFile.getAbsolutePath() );
- }
-
- xsltParams.put( METADATA_URL_BASE, defaultMetadataBase );
- Date now = new Date();
- DateFormat dfm = new SimpleDateFormat( "yyyy-MM-dd'T'hh-mm" ); // iso8601 timestamp
- xsltParams.put( TIMESTAMP, dfm.format( now ) );
-
- log.debug( "Applying stylesheet" );
-
- try
- {
- TransformerTask tt = new TransformerTask( sheet, xsltParams );
-
- tt.transform( source, result, dhisResolver );
- log.debug( "Transform successful" );
- }
- catch ( Exception ex )
- {
- throw new ImportException( "Failed to transform stream", ex );
- }
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-package org.hisp.dhis.importexport.xml;
-
-/*
- * Copyright (c) 2004-2014, 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.hisp.dhis.importexport.ImportException;
-
-/**
- *
- * @author bobj
- * @version created 30-Apr-2010
- */
-public interface XSLTLocator
-{
- /**
- * Look up an xslt stylesheet on the basis of a known identifier
- *
- * @param identifier
- * @return xslt stylesheet opened in InputStream or null if no stylesheet
- * found
- *
- */
- public InputStream getTransformerByTag( String identifier )
- throws ImportException;
-}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2014-02-05 12:00:46 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2014-10-10 16:00:19 +0000
@@ -217,20 +217,6 @@
<bean id="org.hisp.dhis.importexport.ImportService" class="org.hisp.dhis.importexport.DefaultImportService">
<property name="converter" ref="dxfv1-Converter" />
- <property name="preConverter" ref="preConverter" />
- </bean>
-
- <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
- <!-- XSLT based import -->
- <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
-
- <bean id="xsltLocator" class="org.hisp.dhis.importexport.xml.LocManagerXSLTLocator">
- <property name="locationManager" ref="locationManager" />
- </bean>
-
- <bean id="preConverter" class="org.hisp.dhis.importexport.xml.XMLPreConverter">
- <property name="xsltLocator" ref="xsltLocator" />
- <property name="dhisResolver" ref="dhisResolver" />
</bean>
<bean id="org.hisp.dhis.importexport.invoker.ConverterInvoker" class="org.hisp.dhis.importexport.invoker.DefaultConverterInvoker" />
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/analysis'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/analysis/ImportAnalyserTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/analysis/ImportAnalyserTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/analysis/ImportAnalyserTest.java 1970-01-01 00:00:00 +0000
@@ -1,114 +0,0 @@
-package org.hisp.dhis.importexport.analysis;
-
-/*
- * Copyright (c) 2004-2014, 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 static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.hisp.dhis.DhisTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.expression.ExpressionService;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ImportAnalyserTest
- extends DhisTest
-{
- @Autowired
- private ExpressionService expressionService;
-
- private ImportAnalyser analyser;
-
- // -------------------------------------------------------------------------
- // Fixture
- // -------------------------------------------------------------------------
-
- @Override
- public void setUpTest()
- {
- analyser = new DefaultImportAnalyser( expressionService );
- }
-
- // -------------------------------------------------------------------------
- // Tests
- // -------------------------------------------------------------------------
-
- @Test
- public void testUniqueConstraintViolations()
- {
- analyser.addObject( createDataElement( 'A' ) );
- analyser.addObject( createDataElement( 'B' ) );
- analyser.addObject( createDataElement( 'C' ) );
- analyser.addObject( createDataElement( 'A' ) );
- analyser.addObject( createDataElement( 'A' ) );
- analyser.addObject( null );
-
- analyser.addObject( createIndicator( 'A', new IndicatorType() ) );
- analyser.addObject( createIndicator( 'B', new IndicatorType() ) );
- analyser.addObject( createIndicator( 'A', new IndicatorType() ) );
- analyser.addObject( createIndicator( 'C', new IndicatorType() ) );
- analyser.addObject( createIndicator( 'A', new IndicatorType() ) );
- analyser.addObject( null );
-
- analyser.addObject( createOrganisationUnit( 'A' ) );
- analyser.addObject( createOrganisationUnit( 'B' ) );
- analyser.addObject( createOrganisationUnit( 'A' ) );
- analyser.addObject( null );
- analyser.addObject( null );
- analyser.addObject( null );
-
- ImportAnalysis analysis = analyser.getImportAnalysis();
- List<EntityPropertyValue> violations = analysis.getUniqueConstraintViolations();
-
- assertNotNull( violations );
- assertEquals( 9, violations.size() );
-
- assertTrue( violations.contains( new EntityPropertyValue( DataElement.class, "name", "DataElementA" ) ) );
- assertTrue( violations.contains( new EntityPropertyValue( DataElement.class, "shortname", "DataElementShortA" ) ) );
- assertTrue( violations.contains( new EntityPropertyValue( DataElement.class, "code", "DataElementCodeA" ) ) );
-
- assertTrue( violations.contains( new EntityPropertyValue( Indicator.class, "name", "IndicatorA" ) ) );
- assertTrue( violations.contains( new EntityPropertyValue( Indicator.class, "shortname", "IndicatorShortA" ) ) );
- assertTrue( violations.contains( new EntityPropertyValue( Indicator.class, "code", "IndicatorCodeA" ) ) );
-
- assertTrue( violations.contains( new EntityPropertyValue( OrganisationUnit.class, "name", "OrganisationUnitA" ) ) );
- assertTrue( violations.contains( new EntityPropertyValue( OrganisationUnit.class, "shortname", "OrganisationUnitShortA" ) ) );
- assertTrue( violations.contains( new EntityPropertyValue( OrganisationUnit.class, "code", "OrganisationUnitCodeA" ) ) );
- }
-}
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFOrganisationUnitsTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFOrganisationUnitsTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFOrganisationUnitsTest.java 1970-01-01 00:00:00 +0000
@@ -1,101 +0,0 @@
-package org.hisp.dhis.importexport.dxf;
-
-/*
- * Copyright (c) 2004-2014, 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.hisp.dhis.DhisTest;
-import org.hisp.dhis.external.location.LocationManagerException;
-import org.hisp.dhis.importexport.ImportParams;
-import org.hisp.dhis.importexport.ImportService;
-import org.hisp.dhis.importexport.ImportStrategy;
-import org.hisp.dhis.importexport.util.ImportExportUtils;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-
-import javax.annotation.Resource;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * @author Lars Helge Overland
- */
-public class DXFOrganisationUnitsTest
- extends DhisTest
-{
- private InputStream inputStream;
-
- @Resource(name="org.hisp.dhis.importexport.ImportService")
- private ImportService importService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- @Override
- public void setUpTest() throws LocationManagerException, IOException
- {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- inputStream = classLoader.getResourceAsStream( "dxfOrganisationUnits.xml" );
- }
-
- @Override
- public void tearDownTest()
- throws Exception
- {
- inputStream.close();
- }
-
- @Override
- public boolean emptyDatabaseAfterTest() // Empty before to avoid problem for subsequent tests?
- {
- return true;
- }
-
- @Test
- public void testImportOrganisationUnits() throws Exception
- {
- ImportParams params = ImportExportUtils.getImportParams( ImportStrategy.NEW_AND_UPDATES, false, false, false );
-
- importService.importData( params, inputStream );
-
- Collection<OrganisationUnit> units = organisationUnitService.getAllOrganisationUnits();
- OrganisationUnit unit = units.iterator().next();
-
- assertNotNull( units );
- assertEquals( 3, units.size() );
- assertEquals( "MultiPolygon", unit.getFeatureType() );
- assertEquals( "[[[[11.11,22.22],[33.33,44.44],[55.55,66.66]]],[[[77.77,88.88],[99.99,11.11],[22.22,33.33]]],[[[44.44,55.55],[66.66,77.77],[88.88,99.99]]]]", unit.getCoordinates() );
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/GML2DXFTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/GML2DXFTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/GML2DXFTest.java 1970-01-01 00:00:00 +0000
@@ -1,105 +0,0 @@
-package org.hisp.dhis.importexport.dxf;
-
-/*
- * Copyright (c) 2004-2014, 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 javax.annotation.Resource;
-
-import org.hisp.dhis.DhisTest;
-import org.hisp.dhis.importexport.ImportParams;
-import org.hisp.dhis.importexport.ImportService;
-import org.hisp.dhis.importexport.ImportStrategy;
-import org.hisp.dhis.importexport.util.ImportExportUtils;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Lars Helge Overland
- */
-public class GML2DXFTest
- extends DhisTest
-{
- @Resource(name="org.hisp.dhis.importexport.ImportService")
- private ImportService importService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- private InputStream inputStream;
-
- @Override
- public void setUpTest()
- {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- inputStream = classLoader.getResourceAsStream( "polygon.gml" );
- }
-
- @Override
- public boolean emptyDatabaseAfterTest()
- {
- return true;
- }
-
- @Test
- public void test()
- throws Exception
- {
- ImportParams params = ImportExportUtils.getImportParams( ImportStrategy.NEW_AND_UPDATES, false, false, false );
-
- importService.importData( params, inputStream );
-
- assertNotNull( organisationUnitService.getAllOrganisationUnits() );
- assertEquals( 13, organisationUnitService.getAllOrganisationUnits().size() );
-
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Bo" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 18, organisationUnitService.getOrganisationUnitByName( "Bonthe" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Moyamba" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 3, organisationUnitService.getOrganisationUnitByName( "Pujehun" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Kailahun" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Kenema" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Kono" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Bombali" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 3, organisationUnitService.getOrganisationUnitByName( "Kambia" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Koinadugu" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 9, organisationUnitService.getOrganisationUnitByName( "Port Loko" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 1, organisationUnitService.getOrganisationUnitByName( "Tonkolili" ).get( 0 ).getCoordinatesAsList().size() );
- assertEquals( 2, organisationUnitService.getOrganisationUnitByName( "Western Area" ).get( 0 ).getCoordinatesAsList().size() );
-
- assertEquals( 76, organisationUnitService.getOrganisationUnitByName( "Bo" ).get( 0 ).getCoordinatesAsList().get( 0 ).getNumberOfCoordinates() );
- assertEquals( 7, organisationUnitService.getOrganisationUnitByName( "Pujehun" ).get( 0 ).getCoordinatesAsList().get( 0 ).getNumberOfCoordinates() );
- assertEquals( 7, organisationUnitService.getOrganisationUnitByName( "Pujehun" ).get( 0 ).getCoordinatesAsList().get( 1 ).getNumberOfCoordinates() );
- assertEquals( 159, organisationUnitService.getOrganisationUnitByName( "Pujehun" ).get( 0 ).getCoordinatesAsList().get( 2 ).getNumberOfCoordinates() );
- assertEquals( 189, organisationUnitService.getOrganisationUnitByName( "Bonthe" ).get( 0 ).getCoordinatesAsList().get( 1 ).getNumberOfCoordinates() );
- }
-}
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/xml'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/xml/UtilTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/xml/UtilTest.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/xml/UtilTest.java 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
-package org.hisp.dhis.importexport.xml;
-
-/*
- * Copyright (c) 2004-2014, 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.junit.Assert;
-import org.junit.Test;
-
-/**
- * @author bobj
- */
-public class UtilTest
-{
- @Test
- public void testCoords()
- throws Exception
- {
- String src = "34.5,65,7 1234.67890,0.0056 451.23,-0.232561";
- String decimals = "4";
-
- String expected = "<coord>34.5,65.0</coord><coord>1234.6789,0.0056</coord><coord>451.23,-0.2326</coord>";
-
- String result = Util.gmlToCoords( src, decimals );
- Assert.assertEquals( expected, result );
- }
-}