=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java 2012-04-14 16:34:07 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java 2012-04-15 20:48:08 +0000 @@ -42,6 +42,10 @@ protected String orgUnitIdScheme; + protected Boolean dryRun; + + protected String strategy; + //-------------------------------------------------------------------------- // Properties //-------------------------------------------------------------------------- @@ -88,6 +92,26 @@ this.orgUnitIdScheme = orgUnitIdScheme; } + public Boolean getDryRun() + { + return dryRun; + } + + public void setDryRun( Boolean dryRun ) + { + this.dryRun = dryRun; + } + + public String getStrategy() + { + return strategy; + } + + public void setStrategy( String strategy ) + { + this.strategy = strategy; + } + public String getDataSet() { return dataSet; === 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-15 20:21:18 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-04-15 20:48:08 +0000 @@ -216,7 +216,8 @@ IdentifiableProperty dataElementIdScheme = dataValueSet.getDataElementIdScheme() != null ? IdentifiableProperty.valueOf( dataValueSet.getDataElementIdScheme().toUpperCase() ) : importOptions.getDataElementIdScheme(); IdentifiableProperty orgUnitIdScheme = dataValueSet.getOrgUnitIdScheme() != null ? IdentifiableProperty.valueOf( dataValueSet.getOrgUnitIdScheme().toUpperCase() ) : importOptions.getOrgUnitIdScheme(); - ImportStrategy strategy = importOptions.getImportStrategy(); + boolean dryRun = dataValueSet.getDryRun() != null ? dataValueSet.getDryRun() : importOptions.isDryRun(); + ImportStrategy strategy = dataValueSet.getStrategy() != null ? ImportStrategy.valueOf( dataValueSet.getStrategy() ) : importOptions.getImportStrategy(); Map dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, dataElementIdScheme ); Map orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, orgUnitIdScheme ); @@ -303,7 +304,7 @@ { if ( NEW_AND_UPDATES.equals( strategy ) || UPDATES.equals( strategy ) ) { - if ( !importOptions.isDryRun() ) + if ( !dryRun ) { batchHandler.updateObject( internalValue ); } @@ -315,7 +316,7 @@ { if ( NEW_AND_UPDATES.equals( strategy ) || NEW.equals( strategy ) ) { - if ( !importOptions.isDryRun() ) + if ( !dryRun ) { batchHandler.addObject( internalValue ); } === modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingDataValueSet.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingDataValueSet.java 2012-04-14 16:34:07 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingDataValueSet.java 2012-04-15 20:48:08 +0000 @@ -37,9 +37,12 @@ { private static final String XMLNS = "xmlns"; private static final String NS = "http://dhis2.org/schema/dxf/2.0"; + private static final String TRUE = "true"; private static final String FIELD_DATAELEMENTIDSCHEME = "dataElementIdScheme"; private static final String FIELD_ORGUNITIDSCHEME = "orgUnitIdScheme"; + private static final String FIELD_DRYRUN = "dryRun"; + private static final String FIELD_IMPORTSTRATEGY = "importStrategy"; private static final String FIELD_DATAVALUESET = "dataValueSet"; private static final String FIELD_DATAVALUE = "dataValue"; @@ -87,6 +90,18 @@ { return orgUnitIdScheme = orgUnitIdScheme == null ? reader.getAttributeValue( FIELD_ORGUNITIDSCHEME ) : orgUnitIdScheme; } + + @Override + public Boolean getDryRun() + { + return dryRun = dryRun == null ? ( TRUE.equals( reader.getAttributeValue( FIELD_DRYRUN ) ) ? Boolean.TRUE : null ) : dryRun; + } + + @Override + public String getStrategy() + { + return strategy = strategy == null ? reader.getAttributeValue( FIELD_IMPORTSTRATEGY ) : strategy; + } @Override public String getDataSet() === modified file 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java' --- dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java 2012-04-15 15:05:28 +0000 +++ dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java 2012-04-15 20:48:08 +0000 @@ -30,6 +30,8 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; +import static org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty.*; +import static org.hisp.dhis.importexport.ImportStrategy.*; import java.io.InputStreamReader; import java.util.Collection; @@ -46,6 +48,7 @@ import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; import org.hisp.dhis.dxf2.importsummary.ImportSummary; +import org.hisp.dhis.dxf2.metadata.ImportOptions; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.MonthlyPeriodType; @@ -195,4 +198,32 @@ assertTrue( dataValues.contains( new DataValue( deC, peB, ouA, optionComboA ) ) ); assertTrue( dataValues.contains( new DataValue( deC, peB, ouB, optionComboA ) ) ); } + + @Test + public void testImportDataValuesXmlDryRun() + throws Exception + { + ImportOptions options = new ImportOptions( UID, UID, true, NEW_AND_UPDATES ); + + dataValueSetService.saveDataValueSet( new ClassPathResource( "datavalueset/dataValueSetB.xml" ).getInputStream(), options ); + + Collection dataValues = dataValueService.getAllDataValues(); + + assertNotNull( dataValues ); + assertEquals( 0, dataValues.size() ); + } + + @Test + public void testImportDataValuesXmlUpdatesOnly() + throws Exception + { + ImportOptions options = new ImportOptions( UID, UID, false, UPDATES ); + + dataValueSetService.saveDataValueSet( new ClassPathResource( "datavalueset/dataValueSetB.xml" ).getInputStream(), options ); + + Collection dataValues = dataValueService.getAllDataValues(); + + assertNotNull( dataValues ); + assertEquals( 0, dataValues.size() ); + } } === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java' --- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java 2012-04-15 19:45:25 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java 2012-04-15 20:48:08 +0000 @@ -75,7 +75,7 @@ { this.upload = upload; } - + private boolean dryRun; public void setDryRun( boolean dryRun )