dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16904
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6566: Impl new write method on DataValueSetService
------------------------------------------------------------
revno: 6566
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-04-13 22:09:02 +0200
message:
Impl new write method on DataValueSetService
modified:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetStore.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.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-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java 2012-04-13 14:09:59 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java 2012-04-13 20:09:02 +0000
@@ -29,6 +29,8 @@
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Date;
+import java.util.Set;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
@@ -38,6 +40,8 @@
{
void writeDataValueSet( String dataSet, String period, String orgUnit, OutputStream out );
+ void writeDataValueSet( Set<String> dataSets, Date startDate, Date endDate, Set<String> orgUnits, OutputStream out );
+
ImportSummary saveDataValueSet( InputStream in );
ImportSummary saveDataValueSet( InputStream in, ImportOptions importOptions );
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetStore.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetStore.java 2012-04-01 12:24:57 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetStore.java 2012-04-13 20:09:02 +0000
@@ -38,6 +38,6 @@
public interface DataValueSetStore
{
- public void writeDataValueSet( DataSet dataSet, Date completeDate, OrganisationUnit orgUnit, Period period,
+ public void writeDataValueSet( DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit,
Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, OutputStream out );
}
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-13 14:09:59 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-13 20:09:02 +0000
@@ -38,7 +38,9 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.amplecode.quick.BatchHandler;
import org.amplecode.quick.BatchHandlerFactory;
@@ -144,7 +146,42 @@
period_ = periodService.reloadPeriod( period_ );
- dataValueSetStore.writeDataValueSet( dataSet_, completeDate, orgUnit_, period_, dataSet_.getDataElements(), wrap( period_ ), wrap( orgUnit_ ), out );
+ dataValueSetStore.writeDataValueSet( dataSet_, completeDate, period_, orgUnit_, dataSet_.getDataElements(), wrap( period_ ), wrap( orgUnit_ ), out );
+ }
+
+ public void writeDataValueSet( Set<String> dataSets, Date startDate, Date endDate, Set<String> orgUnits, OutputStream out )
+ {
+ Set<DataElement> dataElements = new HashSet<DataElement>();
+
+ for ( String ds : dataSets )
+ {
+ DataSet dataSet = dataSetService.getDataSet( ds );
+
+ if ( dataSet == null )
+ {
+ throw new IllegalArgumentException( ERROR_INVALID_DATA_SET + ds );
+ }
+
+ dataElements.addAll( dataSet.getDataElements() );
+ }
+
+ Set<Period> periods = new HashSet<Period>( periodService.getPeriodsBetweenDates( startDate, endDate ) );
+
+ Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
+
+ for ( String ou : orgUnits )
+ {
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( ou );
+
+ if ( orgUnit == null )
+ {
+ throw new IllegalArgumentException( ERROR_INVALID_ORG_UNIT + ou );
+ }
+
+ organisationUnits.add( orgUnit );
+ }
+
+ dataValueSetStore.writeDataValueSet( null, null, null, null, dataElements, periods, organisationUnits, out );
}
public ImportSummary saveDataValueSet( InputStream in )
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2012-04-13 10:21:57 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2012-04-13 20:09:02 +0000
@@ -61,7 +61,7 @@
// DataValueSetStore implementation
//--------------------------------------------------------------------------
- public void writeDataValueSet( DataSet dataSet, Date completeDate, OrganisationUnit orgUnit, Period period,
+ public void writeDataValueSet( DataSet dataSet, Date completeDate, Period period, OrganisationUnit orgUnit,
Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, OutputStream out )
{
XMLWriter writer = XMLFactory.getXMLWriter( out );