dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41106
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20924: ADX import. Included notifications.
------------------------------------------------------------
revno: 20924
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-02 12:18:46 -0500
message:
ADX import. Included notifications.
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/adx/webapi/AdxController.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/adx/AdxDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataService.java 2015-11-02 17:05:15 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/AdxDataService.java 2015-11-02 17:18:46 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.dxf2.common.ImportOptions;
import org.hisp.dhis.dxf2.datavalueset.DataExportParams;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
+import org.hisp.dhis.scheduling.TaskId;
/**
* @author bobj
@@ -70,9 +71,11 @@
*
* @param in the InputStream.
* @param importOptions the importOptions.
+ * @param id the task id.
+ *
* @return an ImportSummaries collection of ImportSummary for each DataValueSet.
*/
- ImportSummaries postData( InputStream in, ImportOptions importOptions );
+ ImportSummaries saveDataValueSet( InputStream in, ImportOptions importOptions, TaskId id );
- void getData( DataExportParams params, OutputStream out );
+ void writeDataValueSet( DataExportParams params, OutputStream out );
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java 2015-11-02 17:05:15 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java 2015-11-02 17:18:46 +0000
@@ -77,6 +77,8 @@
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.system.notification.Notifier;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -111,20 +113,25 @@
@Autowired
private IdentifiableObjectManager identifiableObjectManager;
+
+ @Autowired
+ private Notifier notifier;
// -------------------------------------------------------------------------
// Public methods
// -------------------------------------------------------------------------
@Override
- public void getData( DataExportParams params, OutputStream out )
+ public void writeDataValueSet( DataExportParams params, OutputStream out )
{
throw new UnsupportedOperationException( "ADX export not supported yet." );
}
@Override
- public ImportSummaries postData( InputStream in, ImportOptions importOptions )
+ public ImportSummaries saveDataValueSet( InputStream in, ImportOptions importOptions, TaskId id )
{
+ notifier.clear( id ).notify( id, "ADX parsing process started" );
+
XMLReader adxReader = XMLFactory.getXMLReader( in );
ImportSummaries importSummaries = new ImportSummaries();
@@ -146,7 +153,7 @@
XMLStreamWriter dxfWriter = factory.createXMLStreamWriter( pipeOut );
// note this returns conflicts which are detected at ADX level
- List<ImportConflict> adxConflicts = parseADXGroupToDxf( adxReader, dxfWriter, importOptions );
+ List<ImportConflict> adxConflicts = parseAdxGroupToDxf( adxReader, dxfWriter, importOptions );
pipeOut.flush();
@@ -177,10 +184,13 @@
importSummaries.addImportSummary( importSummary );
log.warn( "Import failed: " + ex );
}
+
count++;
}
executor.shutdown();
+
+ notifier.notify( id, "ADX parsing done" );
return importSummaries;
}
@@ -189,7 +199,7 @@
// Utility methods
// -------------------------------------------------------------------------
- private List<ImportConflict> parseADXGroupToDxf( XMLReader adxReader, XMLStreamWriter dxfWriter, ImportOptions importOptions )
+ private List<ImportConflict> parseAdxGroupToDxf( XMLReader adxReader, XMLStreamWriter dxfWriter, ImportOptions importOptions )
throws XMLStreamException, AdxException
{
List<ImportConflict> adxConflicts = new LinkedList<>();
@@ -234,7 +244,7 @@
groupAttributes.put( AdxDataService.DATASET, dataSet.getUid() );
DataElementCategoryCombo attributeCombo = dataSet.getCategoryCombo();
- attributesToDXF( AdxDataService.ATTOPTCOMBO, attributeCombo, groupAttributes, dataElementIdScheme );
+ attributesToDxf( AdxDataService.ATTOPTCOMBO, attributeCombo, groupAttributes, dataElementIdScheme );
}
// write the remaining attributes through to DXF stream
@@ -295,7 +305,7 @@
log.debug( "No categoryOptionCombo present." );
DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();
- attributesToDXF( AdxDataService.CATOPTCOMBO, categoryCombo, dvAttributes, dataElementIdScheme );
+ attributesToDxf( AdxDataService.CATOPTCOMBO, categoryCombo, dvAttributes, dataElementIdScheme );
}
// if data element type is string we need to pick out the 'annotation' element
@@ -397,7 +407,7 @@
return catoptcombo;
}
- private void attributesToDXF( String optionComboName, DataElementCategoryCombo catCombo,
+ private void attributesToDxf( String optionComboName, DataElementCategoryCombo catCombo,
Map<String, String> attributes, IdentifiableProperty scheme )
throws AdxException
{
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2015-11-02 03:52:38 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2015-11-02 17:18:46 +0000
@@ -535,7 +535,7 @@
private ImportSummary saveDataValueSet( ImportOptions importOptions, TaskId id, DataValueSet dataValueSet )
{
Clock clock = new Clock( log ).startClock().logTime( "Starting data value import, options: " + importOptions );
- notifier.clear( id ).notify( id, "Process started" );
+ notifier.clear( id ).notify( id, "Process started" );
ImportSummary summary = new ImportSummary();
=== modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/adx/webapi/AdxController.java'
--- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/adx/webapi/AdxController.java 2015-11-02 17:05:15 +0000
+++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/adx/webapi/AdxController.java 2015-11-02 17:18:46 +0000
@@ -68,7 +68,7 @@
public void postXMLDataValueSet( ImportOptions importOptions,
HttpServletResponse response, InputStream in, Model model ) throws IOException
{
- ImportSummaries importSummaries = adxService.postData( in, importOptions );
+ ImportSummaries importSummaries = adxService.saveDataValueSet( in, importOptions, null );
log.debug( "Data values set saved" );