dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37843
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19322: Removed unused methods in GmlImportService. Refactored tests to use new scheme
------------------------------------------------------------
revno: 19322
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-06-09 16:24:56 +0200
message:
Removed unused methods in GmlImportService. Refactored tests to use new scheme
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlImportService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlPreProcessingResult.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/gml/GmlImportServiceTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java 2015-06-08 10:05:46 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java 2015-06-09 14:24:56 +0000
@@ -151,80 +151,6 @@
return GmlPreProcessingResult.success( metaData );
}
- // TODO Remove this (and refactor unit test to use preProcessGml)
- @Override
- public MetaData fromGml( InputStream inputStream )
- throws IOException, TransformerException
- {
- InputStream dxfStream;
- MetaData metaData;
-
- try
- {
- dxfStream = transformGml( inputStream );
- }
- catch (Exception e)
- {
- dxfStream = null;
- }
-
- if(dxfStream != null)
- {
- metaData = renderService.fromXml( dxfStream, MetaData.class );
- dxfStream.close();
- }
- else
- {
- return null;
- }
-
- Map<String, OrganisationUnit> uidMap = Maps.newHashMap(), codeMap = Maps.newHashMap(), nameMap = Maps.newHashMap();
-
- matchAndFilterOnIdentifiers( metaData.getOrganisationUnits(), uidMap, codeMap, nameMap );
-
- Map<String, OrganisationUnit> persistedUidMap = getMatchingPersistedOrgUnits( uidMap.keySet(), IdentifiableProperty.UID );
- Map<String, OrganisationUnit> persistedCodeMap = getMatchingPersistedOrgUnits( codeMap.keySet(), IdentifiableProperty.CODE );
- Map<String, OrganisationUnit> persistedNameMap = getMatchingPersistedOrgUnits( nameMap.keySet(), IdentifiableProperty.NAME );
-
- Iterator<OrganisationUnit> persistedIterator = Iterators.concat( persistedUidMap.values().iterator(),
- persistedCodeMap.values().iterator(), persistedNameMap.values().iterator() );
-
- while ( persistedIterator.hasNext() )
- {
- OrganisationUnit persisted = persistedIterator.next(), imported = null;
-
- if ( !Strings.isNullOrEmpty( persisted.getUid() ) && uidMap.containsKey( persisted.getUid() ) )
- {
- imported = uidMap.get( persisted.getUid() );
- }
- else if ( !Strings.isNullOrEmpty( persisted.getCode() ) && codeMap.containsKey( persisted.getCode() ) )
- {
- imported = codeMap.get( persisted.getCode() );
- }
- else if ( !Strings.isNullOrEmpty( persisted.getName() ) && nameMap.containsKey( persisted.getName() ) )
- {
- imported = nameMap.get( persisted.getName() );
- }
-
- if ( imported == null || imported.getCoordinates() == null || imported.getFeatureType() == null )
- {
- continue; // Failed to dereference a persisted entity for this org unit or geo data incomplete/missing, therefore ignore
- }
-
- mergeNonGeoData( persisted, imported );
- }
-
- return metaData;
- }
-
- @Transactional
- @Override
- public void importGml( InputStream inputStream, String userUid, ImportOptions importOptions, TaskId taskId )
- throws IOException, TransformerException
- {
- importService.importMetaData( userUid, fromGml( inputStream ), importOptions, taskId );
- }
-
@Transactional
@Override
public void importGml( MetaData metaData, String userUid, ImportOptions importOptions, TaskId taskId )
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlImportService.java 2015-06-05 12:56:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlImportService.java 2015-06-09 14:24:56 +0000
@@ -32,8 +32,6 @@
import org.hisp.dhis.dxf2.metadata.MetaData;
import org.hisp.dhis.scheduling.TaskId;
-import javax.xml.transform.TransformerException;
-import java.io.IOException;
import java.io.InputStream;
/**
@@ -47,21 +45,6 @@
String ID = GmlImportService.class.getName();
/**
- * Transform a GML document to MetaData containing the relevant updates
- * to geospatial features (e.g. coordinates, featuretypes). The process
- * filters the input against the database and merges in essential fields
- * needed for the meta data importer to only update the geospatial fields
- * and not nullify any 'missing' fields.
- *
- * @param inputStream the GML document to import.
- * @return a MetaData object reflecting the database content with the GML file changes merged in.
- * @throws IOException on failure to read the InputStream.
- * @throws TransformerException on failure to parse and transform the GML content.
- */
- MetaData fromGml( InputStream inputStream )
- throws IOException, TransformerException;
-
- /**
* Pre-process a GML document. The process, in short, entails the following:
* <ol>
* <li>Parse the GML payload and transform it into DXF2 format</li>
@@ -80,22 +63,8 @@
GmlPreProcessingResult preProcessGml( InputStream gmlInputStream );
/**
- * Imports GML data and merges the geospatial data updates into the database.
- * See {@link #fromGml(InputStream)} for details on the underlying process.
- *
- * @param inputStream the GML document to import.
- * @param userUid the UID of the user performing the import (task owner).
- * @param importOptions the ImportOptions for the MetaData importer.
- * @param taskId the TaskId of the process.
- * @throws IOException on failure to read the InputStream.
- * @throws TransformerException on failure to parse and transform the GML content.
- */
- void importGml( InputStream inputStream, String userUid, ImportOptions importOptions, TaskId taskId )
- throws IOException, TransformerException;
-
- /**
* Imports a MetaData object containing geospatial updates.
- * The MetaData should be retrieved using {@link #fromGml(InputStream)}.
+ * The MetaData should be retrieved using {@link #preProcessGml(InputStream)}.
*
* @param metaData the MetaData reflecting the geospatial updates.
* @param userUid the UID of the user performing the import (task owner).
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlPreProcessingResult.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlPreProcessingResult.java 2015-06-05 12:56:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/GmlPreProcessingResult.java 2015-06-09 14:24:56 +0000
@@ -21,7 +21,8 @@
private GmlPreProcessingResult(){}
- public static GmlPreProcessingResult success( MetaData resultMetaData ) {
+ public static GmlPreProcessingResult success( MetaData resultMetaData )
+ {
GmlPreProcessingResult result = new GmlPreProcessingResult();
result.setResultMetaData( resultMetaData );
result.setSuccess( true );
@@ -38,33 +39,38 @@
return result;
}
+ public boolean isSuccess()
+ {
+ return isSuccess;
+ }
+
+ public MetaData getResultMetaData()
+ {
+ return resultMetaData;
+ }
+
+ public Throwable getThrowable()
+ {
+ return throwable;
+ }
+
+ // -------------------------------------------------------------------------
+ // Private setters
+ // -------------------------------------------------------------------------
+
private void setSuccess( boolean isSuccess )
{
this.isSuccess = isSuccess;
}
- public boolean isSuccess()
- {
- return isSuccess;
- }
-
private void setResultMetaData( MetaData resultMetaData )
{
this.resultMetaData = resultMetaData;
}
- public MetaData getResultMetaData()
- {
- return resultMetaData;
- }
-
private void setThrowable( Throwable throwable )
{
this.throwable = throwable;
}
- public Throwable getThrowable()
- {
- return throwable;
- }
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/gml/GmlImportServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/gml/GmlImportServiceTest.java 2015-06-05 12:56:34 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/gml/GmlImportServiceTest.java 2015-06-09 14:24:56 +0000
@@ -77,7 +77,9 @@
public void fromGmlTest()
throws Exception
{
- MetaData metaData = gmlImportService.fromGml( inputStream );
+ GmlPreProcessingResult result = gmlImportService.preProcessGml( inputStream );
+ MetaData metaData = result.getResultMetaData();
+
Collection<OrganisationUnit> orgUnits = metaData.getOrganisationUnits();
assertNotNull( orgUnits );
@@ -117,6 +119,4 @@
assertEquals( 1, units.get( "Blindern").getCoordinatesAsList().get( 0 ).getNumberOfCoordinates() );
assertEquals( 76, units.get( "Forskningsparken" ).getCoordinatesAsList().get(0).getNumberOfCoordinates() );
}
-
- // TODO Add test for GmlImportService#preProcessGml(InputStream)
}