← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19887: DataValueSetService. Implemented contraint option for requiring period of data value to be of any...

 

------------------------------------------------------------
revno: 19887
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-08-30 19:07:42 +0200
message:
  DataValueSetService. Implemented contraint option for requiring period of data value to be of any of the period types of the data element through its data sets.
added:
  dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/datavalueset/dataValueSetNonStrict.xml
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ImportOptions.java
  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/gml/DefaultGmlImportService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java
  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/metadata/CsvMetaDataImportTest.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FilteredMetaDataController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MetaDataController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/PdfFormController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java
  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/dxf2/MetaDataImportAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.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-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-08-27 15:28:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-08-30 17:07:42 +0000
@@ -35,6 +35,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.attribute.AttributeValue;
@@ -62,6 +63,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.google.common.collect.Sets;
 
 /**
  * A DataElement is a definition (meta-information about) of the entities that
@@ -339,7 +341,7 @@
 
     /**
      * Returns the PeriodType of the DataElement, based on the PeriodType of the
-     * DataSet which the DataElement is registered for. If this data element has
+     * DataSet which the DataElement is associated with. If this data element has
      * multiple data sets, the data set with the highest collection frequency is
      * returned.
      */
@@ -349,6 +351,15 @@
 
         return dataSet != null ? dataSet.getPeriodType() : null;
     }
+    
+    /**
+     * Returns the PeriodTypes of the DataElement, based on the PeriodType of the
+     * DataSets which the DataElement is associated with.
+     */
+    public Set<PeriodType> getPeriodTypes()
+    {
+        return Sets.newHashSet( dataSets ).stream().map( dataSet -> dataSet.getPeriodType() ).collect( Collectors.toSet() );
+    }
 
     /**
      * Indicates whether this data element requires approval of data. Returns true

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2015-06-17 14:11:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2015-08-30 17:07:42 +0000
@@ -107,6 +107,12 @@
     final String KEY_CORS_WHITELIST = "keyCorsWhitelist";
     final String KEY_REQUIRE_ADD_TO_VIEW = "keyRequireAddToView";
     final String KEY_ALLOW_OBJECT_ASSIGNMENT = "keyAllowObjectAssignment";
+    
+    final String KEY_DATA_IMPORT_STRICT_PERIODS = "keyDataImportStrictPeriods";
+    final String KEY_DATA_IMPORT_STRICT_CATEGORY_OPTION_COMBOS = "keyDataImportStrictCategoryOptionCombos";
+    final String KEY_DATA_IMPORT_STRICT_ATTRIBUTE_OPTION_COMBOS = "keyDataImportStrictAttributeOptionCombos";
+    final String KEY_DATA_IMPORT_REQUIRE_CATEGORY_OPTION_COMBO = "keyDataImportRequireCategoryOptionCombo";
+    final String KEY_DATA_IMPORT_REQUIRE_ATTRIBUTE_OPTION_COMBO = "keyDataImportRequireAttributeOptionCombo";
 
     final String DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "lastMonth";
     final String DEFAULT_FLAG = "dhis2";

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ImportOptions.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ImportOptions.java	2015-02-25 06:11:43 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ImportOptions.java	2015-08-30 17:07:42 +0000
@@ -28,10 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.common.IdentifiableProperty.UID;
+
 import org.hisp.dhis.common.IdentifiableProperty;
 import org.hisp.dhis.common.MergeStrategy;
 import org.hisp.dhis.importexport.ImportStrategy;
 
+import com.google.common.base.MoreObjects;
+
 /**
  * The idScheme is a general setting which will apply to all objects. The idSchemes
  * can also be defined for specific objects such as dataElementIdScheme. The
@@ -41,8 +45,8 @@
  */
 public class ImportOptions
 {
-    private static final ImportOptions DEFAULT_OPTIONS = new ImportOptions(
-        IdentifiableProperty.UID, IdentifiableProperty.UID, false, true, ImportStrategy.NEW_AND_UPDATES, false );
+    private static final ImportOptions DEFAULT_OPTIONS = new ImportOptions().
+        setDataElementIdScheme( UID ).setOrgUnitIdScheme( UID ).setPreheatCache( true ).setImportStrategy( ImportStrategy.NEW_AND_UPDATES );
 
     private IdentifiableProperty idScheme;
 
@@ -56,13 +60,15 @@
 
     private boolean async;
 
-    private ImportStrategy importStrategy;
+    private ImportStrategy importStrategy = ImportStrategy.CREATE_AND_UPDATE;
 
     private MergeStrategy mergeStrategy = MergeStrategy.MERGE_IF_NOT_NULL;
 
     private boolean skipExistingCheck;
 
     private boolean sharing;
+    
+    private Boolean strictPeriods;
 
     //--------------------------------------------------------------------------
     // Constructors
@@ -71,33 +77,12 @@
     public ImportOptions()
     {
     }
-
-    public ImportOptions( ImportStrategy importStrategy )
-    {
-        this.importStrategy = importStrategy;
-    }
-
-    public ImportOptions( IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme,
-        boolean dryRun, boolean preheatCache, ImportStrategy importStrategy, boolean skipExistingCheck )
-    {
-        this.dataElementIdScheme = dataElementIdScheme;
-        this.orgUnitIdScheme = orgUnitIdScheme;
-        this.preheatCache = preheatCache;
-        this.dryRun = dryRun;
-        this.importStrategy = importStrategy;
-        this.skipExistingCheck = skipExistingCheck;
-    }
-
-    public ImportOptions( IdentifiableProperty idScheme, IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme,
-        boolean dryRun, boolean preheatCache, ImportStrategy importStrategy, boolean skipExistingCheck )
+    
+    public ImportOptions( IdentifiableProperty idScheme, IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdscheme )
     {
         this.idScheme = idScheme;
         this.dataElementIdScheme = dataElementIdScheme;
-        this.orgUnitIdScheme = orgUnitIdScheme;
-        this.preheatCache = preheatCache;
-        this.dryRun = dryRun;
-        this.importStrategy = importStrategy;
-        this.skipExistingCheck = skipExistingCheck;
+        this.orgUnitIdScheme = orgUnitIdscheme;
     }
 
     //--------------------------------------------------------------------------
@@ -108,6 +93,11 @@
     {
         return DEFAULT_OPTIONS;
     }
+    
+    public boolean hasStrictPeriods()
+    {
+        return strictPeriods != null;
+    }
 
     //--------------------------------------------------------------------------
     // Get methods
@@ -120,12 +110,12 @@
 
     public IdentifiableProperty getDataElementIdScheme()
     {
-        return dataElementIdScheme != null ? dataElementIdScheme : (idScheme != null ? idScheme : IdentifiableProperty.UID);
+        return dataElementIdScheme != null ? dataElementIdScheme : ( idScheme != null ? idScheme : IdentifiableProperty.UID );
     }
 
     public IdentifiableProperty getOrgUnitIdScheme()
     {
-        return orgUnitIdScheme != null ? orgUnitIdScheme : (idScheme != null ? idScheme : IdentifiableProperty.UID);
+        return orgUnitIdScheme != null ? orgUnitIdScheme : ( idScheme != null ? idScheme : IdentifiableProperty.UID );
     }
 
     public boolean isDryRun()
@@ -138,6 +128,11 @@
         return preheatCache;
     }
 
+    public boolean isAsync()
+    {
+        return async;
+    }
+
     public ImportStrategy getImportStrategy()
     {
         return importStrategy != null ? importStrategy : ImportStrategy.NEW_AND_UPDATES;
@@ -158,75 +153,99 @@
         return skipExistingCheck;
     }
 
+    public boolean isSharing()
+    {
+        return sharing;
+    }
+
+    public Boolean getStrictPeriods()
+    {
+        return strictPeriods;
+    }
+
     //--------------------------------------------------------------------------
     // Set methods
     //--------------------------------------------------------------------------
 
-    public void setIdScheme( String scheme )
-    {
-        this.idScheme = scheme != null ? IdentifiableProperty.valueOf( scheme.toUpperCase() ) : null;
-    }
-
-    public void setDataElementIdScheme( String scheme )
-    {
-        this.dataElementIdScheme = scheme != null ? IdentifiableProperty.valueOf( scheme.toUpperCase() ) : null;
-    }
-
-    public void setOrgUnitIdScheme( String scheme )
-    {
-        this.orgUnitIdScheme = scheme != null ? IdentifiableProperty.valueOf( scheme.toUpperCase() ) : null;
-    }
-
-    public void setDryRun( boolean dryRun )
+    public ImportOptions setIdScheme( IdentifiableProperty scheme )
+    {
+        this.idScheme = scheme != null ? scheme : null;
+        return this;
+    }
+
+    public ImportOptions setDataElementIdScheme( IdentifiableProperty scheme )
+    {
+        this.dataElementIdScheme = scheme != null ? scheme : null;
+        return this;
+    }
+
+    public ImportOptions setOrgUnitIdScheme( IdentifiableProperty scheme )
+    {
+        this.orgUnitIdScheme = scheme != null ? scheme : null;
+        return this;
+    }
+
+    public ImportOptions setDryRun( boolean dryRun )
     {
         this.dryRun = dryRun;
+        return this;
     }
 
-    public void setPreheatCache( boolean preheatCache )
+    public ImportOptions setPreheatCache( boolean preheatCache )
     {
         this.preheatCache = preheatCache;
-    }
-
-    public boolean isAsync()
-    {
-        return async;
-    }
-
-    public void setAsync( boolean async )
+        return this;
+    }
+
+    public ImportOptions setAsync( boolean async )
     {
         this.async = async;
-    }
-
-    public void setStrategy( String strategy )
-    {
-        this.importStrategy = strategy != null ? ImportStrategy.valueOf( strategy.toUpperCase() ) : null;
-    }
-
-    public void setImportStrategy( String strategy )
-    {
-        this.importStrategy = strategy != null ? ImportStrategy.valueOf( strategy.toUpperCase() ) : null;
-    }
-
-    public void setSkipExistingCheck( boolean skipExistingCheck )
+        return this;
+    }
+
+    public ImportOptions setStrategy( ImportStrategy strategy )
+    {
+        this.importStrategy = strategy != null ? strategy : null;
+        return this;
+    }
+
+    public ImportOptions setImportStrategy( ImportStrategy strategy )
+    {
+        this.importStrategy = strategy != null ? strategy : null;
+        return this;
+    }
+
+    public ImportOptions setSkipExistingCheck( boolean skipExistingCheck )
     {
         this.skipExistingCheck = skipExistingCheck;
-    }
-
-    public boolean isSharing()
-    {
-        return sharing;
-    }
-
-    public void setSharing( boolean sharing )
+        return this;
+    }
+
+    public ImportOptions setSharing( boolean sharing )
     {
         this.sharing = sharing;
+        return this;
+    }
+
+    public ImportOptions setStrictPeriods( Boolean strictPeriods )
+    {
+        this.strictPeriods = strictPeriods;
+        return this;
     }
 
     @Override
     public String toString()
     {
-        return "[Id scheme: " + idScheme + ", data element id scheme: " + dataElementIdScheme + ", org unit id scheme: " +
-            orgUnitIdScheme + ", dry run: " + dryRun + ", preheat cache: " + preheatCache + ", async: " +
-            async + ", strategy: " + importStrategy + ", skip check: " + skipExistingCheck + "]";
+        return MoreObjects.toStringHelper( this.getClass() ).
+            add( "Id scheme", idScheme ).
+            add( "Data element id scheme", dataElementIdScheme ).
+            add( "Org unit id scheme", orgUnitIdScheme ).
+            add( "Dry run", dryRun ).
+            add( "Preheat cache", preheatCache ).
+            add( "Async", async ).
+            add( "Import strategy", importStrategy ).
+            add( "Skip existing check", skipExistingCheck ).
+            add( "Sharing", sharing ).
+            add( "Strict periods", strictPeriods ).toString();
     }
 }

=== 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-08-30 14:51:28 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2015-08-30 17:07:42 +0000
@@ -35,6 +35,7 @@
 import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
 import static org.hisp.dhis.system.util.DateUtils.getDefaultDate;
 import static org.hisp.dhis.system.util.DateUtils.parseDate;
+import static org.hisp.dhis.setting.SystemSettingManager.*;
 
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -87,7 +88,9 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.callable.CategoryOptionComboAclCallable;
 import org.hisp.dhis.system.callable.IdentifiableObjectCallable;
 import org.hisp.dhis.system.callable.PeriodCallable;
@@ -135,7 +138,10 @@
 
     @Autowired
     private DataValueSetStore dataValueSetStore;
-
+    
+    @Autowired
+    private SystemSettingManager systemSettingManager;
+    
     @Autowired
     private I18nManager i18nManager;
 
@@ -569,7 +575,10 @@
             ImportStrategy.valueOf( dataValueSet.getStrategy() ) : importOptions.getImportStrategy();
 
         boolean skipExistingCheck = importOptions.isSkipExistingCheck();
-
+        
+        boolean strictPeriods = importOptions.hasStrictPeriods() ? importOptions.getStrictPeriods() : 
+            (Boolean) systemSettingManager.getSystemSetting( KEY_DATA_IMPORT_STRICT_PERIODS, false );
+        
         //----------------------------------------------------------------------
         // Create meta-data maps
         //----------------------------------------------------------------------
@@ -578,6 +587,7 @@
         CachingMap<String, OrganisationUnit> orgUnitMap = new CachingMap<>();
         CachingMap<String, DataElementCategoryOptionCombo> optionComboMap = new CachingMap<>();
         CachingMap<String, Period> periodMap = new CachingMap<>();
+        CachingMap<String, Set<PeriodType>> dataElementPeriodTypesMap = new CachingMap<>();
         CachingMap<String, Boolean> orgUnitInHierarchyMap = new CachingMap<>();
 
         //----------------------------------------------------------------------
@@ -709,7 +719,7 @@
                 summary.getConflicts().add( new ImportConflict( dataValue.getPeriod(), "Period not valid" ) );
                 continue;
             }
-
+            
             if ( orgUnit == null )
             {
                 summary.getConflicts().add( new ImportConflict( dataValue.getOrgUnit(), "Organisation unit not found or not acccessible" ) );
@@ -768,6 +778,16 @@
                 continue;
             }
 
+            // -----------------------------------------------------------------
+            // Constraints
+            // -----------------------------------------------------------------
+
+            if ( strictPeriods && !dataElementPeriodTypesMap.get( dataValue.getDataElement(), () -> dataElement.getPeriodTypes() ).contains( period.getPeriodType() ) )
+            {
+                summary.getConflicts().add( new ImportConflict( dataValue.getPeriod(), "Period type of period: " + dataValue.getPeriod() + " not valid for data element: " + dataValue.getDataElement() ) );
+                continue;
+            }
+            
             internalValue.setDataElement( dataElement );
             internalValue.setPeriod( period );
             internalValue.setSource( orgUnit );

=== 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-07-03 14:17:06 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/gml/DefaultGmlImportService.java	2015-08-30 17:07:42 +0000
@@ -129,7 +129,7 @@
     {
         if ( !importOptions.getImportStrategy().isUpdate() )
         {
-            importOptions.setImportStrategy( ImportStrategy.UPDATE.name() );
+            importOptions.setImportStrategy( ImportStrategy.UPDATE );
             log.warn( "Changed GML import strategy to update. Only updates are supported." );
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2015-06-10 03:15:14 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2015-08-30 17:07:42 +0000
@@ -28,6 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.springframework.util.Assert.notNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.SessionFactory;
@@ -50,15 +59,6 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.springframework.util.Assert.notNull;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -105,7 +105,7 @@
         ImportOptions importOptions = new ImportOptions();
         importOptions.setDryRun( false );
         importOptions.setPreheatCache( false );
-        importOptions.setImportStrategy( importStrategy.toString() );
+        importOptions.setImportStrategy( importStrategy );
         importOptions.setMergeStrategy( mergeStrategy );
 
         objectBridge.setWriteEnabled( !importOptions.isDryRun() );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2015-06-01 19:49:10 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2015-08-30 17:07:42 +0000
@@ -30,8 +30,6 @@
 
 import static org.hisp.dhis.common.IdentifiableProperty.CODE;
 import static org.hisp.dhis.common.IdentifiableProperty.UID;
-import static org.hisp.dhis.importexport.ImportStrategy.NEW_AND_UPDATES;
-import static org.hisp.dhis.importexport.ImportStrategy.UPDATES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -52,9 +50,10 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.importsummary.ImportStatus;
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
-import org.hisp.dhis.dxf2.common.ImportOptions;
+import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
 import org.hisp.dhis.mock.MockCurrentUserService;
 import org.hisp.dhis.mock.batchhandler.MockBatchHandler;
@@ -185,6 +184,12 @@
         dataElementService.addDataElement( deB );
         dataElementService.addDataElement( deC );
         dataElementService.addDataElement( deD );
+        
+        dsA.addDataElement( deA );
+        dsA.addDataElement( deB );
+        dsA.addDataElement( deC );
+        dsA.addDataElement( deD );        
+        
         dataSetService.addDataSet( dsA );
         organisationUnitService.addOrganisationUnit( ouA );
         organisationUnitService.addOrganisationUnit( ouB );
@@ -286,7 +291,7 @@
     {
         in = new ClassPathResource( "datavalueset/dataValueSetBcode.xml" ).getInputStream();
         
-        ImportOptions options = new ImportOptions( CODE, CODE, CODE, false, true, NEW_AND_UPDATES, false );
+        ImportOptions options = new ImportOptions( CODE, CODE, CODE );
         ImportSummary summary = dataValueSetService.saveDataValueSet( in, options );
 
         assertEquals( summary.getConflicts().toString(), 0, summary.getConflicts().size() );
@@ -305,7 +310,7 @@
     {
         in = new ClassPathResource( "datavalueset/dataValueSetBcode.xml" ).getInputStream();
         
-        ImportOptions options = new ImportOptions( CODE, CODE, CODE, false, false, NEW_AND_UPDATES, false );
+        ImportOptions options = new ImportOptions( CODE, CODE, CODE ).setPreheatCache( false );
         ImportSummary summary = dataValueSetService.saveDataValueSet( in, options );
 
         assertEquals( summary.getConflicts().toString(), 0, summary.getConflicts().size() );
@@ -342,7 +347,7 @@
     {
         in = new ClassPathResource( "datavalueset/dataValueSetB.xml" ).getInputStream();
         
-        ImportOptions options = new ImportOptions( UID, UID, UID, true, true, NEW_AND_UPDATES, false );
+        ImportOptions options = new ImportOptions( UID, UID, UID ).setDryRun( true );
         
         ImportSummary summary = dataValueSetService.saveDataValueSet( in, options );
 
@@ -361,7 +366,7 @@
     {
         in = new ClassPathResource( "datavalueset/dataValueSetB.xml" ).getInputStream();
         
-        ImportOptions options = new ImportOptions( UID, UID, UID, false, true, UPDATES, false );
+        ImportOptions options = new ImportOptions( UID, UID, UID ).setImportStrategy( ImportStrategy.UPDATES );
         
         ImportSummary summary = dataValueSetService.saveDataValueSet( in, options );
 
@@ -473,6 +478,24 @@
         assertEquals( 1, dataValues.size() ); 
     }
 
+    @Test
+    public void testImportDataValuesWithNonStrictPeriods()
+        throws Exception
+    {
+        in = new ClassPathResource( "datavalueset/dataValueSetNonStrict.xml" ).getInputStream();
+
+        ImportOptions options = new ImportOptions().setStrictPeriods( true );
+
+        ImportSummary summary = dataValueSetService.saveDataValueSet( in, options );
+
+        assertEquals( summary.getConflicts().toString(), 2, summary.getConflicts().size() );
+        assertEquals( 1, summary.getImportCount().getImported() );
+        assertEquals( 0, summary.getImportCount().getUpdated() );
+        assertEquals( 0, summary.getImportCount().getDeleted() );
+        assertEquals( 2, summary.getImportCount().getIgnored() );
+        assertEquals( ImportStatus.SUCCESS, summary.getStatus() );
+    }
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------

=== 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-07-03 14:17:06 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/gml/GmlImportServiceTest.java	2015-08-30 17:07:42 +0000
@@ -28,6 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+
 import org.apache.commons.io.IOUtils;
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.dxf2.common.ImportOptions;
@@ -43,12 +49,6 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 
-import java.io.IOException;
-import java.io.InputStream;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 /**
  * @author Halvdan Hoem Grelland
  */
@@ -124,7 +124,7 @@
 
         taskId = new TaskId( TaskCategory.METADATA_IMPORT, user );
 
-        importOptions = new ImportOptions( ImportStrategy.UPDATE );
+        importOptions = new ImportOptions().setImportStrategy( ImportStrategy.UPDATE );
         importOptions.setDryRun( false );
         importOptions.setPreheatCache( true );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/CsvMetaDataImportTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/CsvMetaDataImportTest.java	2015-03-27 11:01:54 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata/CsvMetaDataImportTest.java	2015-08-30 17:07:42 +0000
@@ -67,7 +67,7 @@
     
     private InputStream input;
     
-    private final ImportOptions importOptions = new ImportOptions( ImportStrategy.NEW_AND_UPDATES );
+    private final ImportOptions importOptions = new ImportOptions().setImportStrategy( ImportStrategy.NEW_AND_UPDATES );
     
     @Test
     public void testDataElementImport()

=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/datavalueset/dataValueSetNonStrict.xml'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/datavalueset/dataValueSetNonStrict.xml	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/resources/datavalueset/dataValueSetNonStrict.xml	2015-08-30 17:07:42 +0000
@@ -0,0 +1,5 @@
+<dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0"; dataSet="pBOMPrpg1QX" orgUnit="DiszpKrYNg8">
+    <dataValue dataElement="f7n9E0hX8qk" period="201201" value="10001" storedBy="john" timestamp="2012-01-01" comment="comment" followup="false"/>
+    <dataValue dataElement="Ix2HsbDMLea" period="2012Q2" value="10002" storedBy="john" timestamp="2012-01-02" comment="comment" followup="false"/>
+    <dataValue dataElement="eY5ehpbEsB7" period="2012" value="10003" storedBy="john" timestamp="2012-01-03" comment="comment" followup="false"/>
+</dataValueSet>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FilteredMetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FilteredMetaDataController.java	2015-07-15 15:49:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FilteredMetaDataController.java	2015-08-30 17:07:42 +0000
@@ -260,7 +260,7 @@
         MetaData metaData = new ObjectMapper().readValue( json.getString( "metaData" ), MetaData.class );
 
         ImportOptions importOptions = new ImportOptions();
-        importOptions.setStrategy( strategy.toString() );
+        importOptions.setStrategy( strategy );
         importOptions.setDryRun( dryRun );
 
         scheduler.executeTask( new ImportMetaDataTask( user.getUid(), importService, importOptions, taskId, metaData ) );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MetaDataController.java	2015-07-15 15:49:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MetaDataController.java	2015-08-30 17:07:42 +0000
@@ -239,7 +239,7 @@
     @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.DELETE, consumes = { "application/xml", "text/*" } )
     public void deleteXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        importOptions.setImportStrategy( ImportStrategy.DELETE.name() );
+        importOptions.setImportStrategy( ImportStrategy.DELETE );
         importXml( importOptions, response, request );
     }
 
@@ -261,7 +261,7 @@
     @RequestMapping( value = MetaDataController.RESOURCE_PATH, method = RequestMethod.DELETE, consumes = "application/json" )
     public void deleteJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        importOptions.setImportStrategy( ImportStrategy.DELETE.name() );
+        importOptions.setImportStrategy( ImportStrategy.DELETE );
         importJson( importOptions, response, request );
     }
 
@@ -286,7 +286,7 @@
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".zip", MetaDataController.RESOURCE_PATH + ".xml.zip" }, method = RequestMethod.DELETE, consumes = { "application/xml", "text/*" } )
     public void deleteZippedXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        importOptions.setImportStrategy( ImportStrategy.DELETE.name() );
+        importOptions.setImportStrategy( ImportStrategy.DELETE );
         importZippedXml( importOptions, response, request );
     }
 
@@ -311,7 +311,7 @@
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".zip", MetaDataController.RESOURCE_PATH + ".json.zip" }, method = RequestMethod.DELETE, consumes = "application/json" )
     public void deleteZippedJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        importOptions.setImportStrategy( ImportStrategy.DELETE.name() );
+        importOptions.setImportStrategy( ImportStrategy.DELETE );
         importZippedJson( importOptions, response, request );
     }
 
@@ -334,7 +334,7 @@
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".gz", MetaDataController.RESOURCE_PATH + ".xml.gz" }, method = RequestMethod.DELETE, consumes = { "application/xml", "text/*" } )
     public void deleteGZippedXml( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        importOptions.setImportStrategy( ImportStrategy.DELETE.name() );
+        importOptions.setImportStrategy( ImportStrategy.DELETE );
         importGZippedXml( importOptions, response, request );
     }
 
@@ -357,7 +357,7 @@
     @RequestMapping( value = { MetaDataController.RESOURCE_PATH + ".gz", MetaDataController.RESOURCE_PATH + ".json.gz" }, method = RequestMethod.DELETE, consumes = "application/json" )
     public void deleteGZippedJson( ImportOptions importOptions, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        importOptions.setImportStrategy( ImportStrategy.DELETE.name() );
+        importOptions.setImportStrategy( ImportStrategy.DELETE );
         importGZippedJson( importOptions, response, request );
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/PdfFormController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/PdfFormController.java	2015-07-15 15:49:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/PdfFormController.java	2015-08-30 17:07:42 +0000
@@ -28,11 +28,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.lowagie.text.Document;
-import com.lowagie.text.pdf.PdfWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.common.IdentifiableProperty;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.common.cache.CacheStrategy;
 import org.hisp.dhis.commons.util.StreamUtils;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.dxf2.common.ImportOptions;
@@ -41,7 +46,6 @@
 import org.hisp.dhis.dxf2.pdfform.PdfDataEntryFormUtil;
 import org.hisp.dhis.dxf2.pdfform.PdfFormFontSettings;
 import org.hisp.dhis.i18n.I18nManager;
-import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.scheduling.TaskCategory;
@@ -50,7 +54,6 @@
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.webapi.service.WebMessageService;
 import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.common.cache.CacheStrategy;
 import org.hisp.dhis.webapi.utils.PdfDataEntryFormImportUtil;
 import org.hisp.dhis.webapi.utils.WebMessageUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -60,13 +63,8 @@
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import com.lowagie.text.Document;
+import com.lowagie.text.pdf.PdfWriter;
 
 /**
  * @author James Chang <jamesbchang@xxxxxxxxx>
@@ -75,8 +73,6 @@
 @RequestMapping( value = "/pdfForm" )
 public class PdfFormController
 {
-    private static final Log log = LogFactory.getLog( PdfFormController.class );
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -145,14 +141,6 @@
     public void sendFormPdfDataSet( HttpServletRequest request, HttpServletResponse response )
         throws Exception
     {
-        ImportStrategy strategy = ImportStrategy.NEW_AND_UPDATES;
-        IdentifiableProperty dataElementIdScheme = IdentifiableProperty.UID;
-        IdentifiableProperty orgUnitIdScheme = IdentifiableProperty.UID;
-
-        ImportOptions options = new ImportOptions( dataElementIdScheme, orgUnitIdScheme, false, true, strategy, false );
-
-        log.info( options );
-
         TaskId taskId = new TaskId( TaskCategory.DATAVALUE_IMPORT, currentUserService.getCurrentUser() );
 
         notifier.clear( taskId );
@@ -161,7 +149,7 @@
 
         in = StreamUtils.wrapAndCheckCompressionFormat( in );
 
-        dataValueSetService.saveDataValueSetPdf( in, options, taskId );
+        dataValueSetService.saveDataValueSetPdf( in, ImportOptions.getDefaultImportOptions(), taskId );
 
         webMessageService.send( WebMessageUtils.ok( "Import successful." ), response, request );
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java	2015-07-09 06:53:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventController.java	2015-08-30 17:07:42 +0000
@@ -301,7 +301,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
     public void postXmlEvent( @RequestParam( defaultValue = "CREATE" ) ImportStrategy strategy, HttpServletResponse response, HttpServletRequest request, ImportOptions importOptions ) throws Exception
     {
-        importOptions.setImportStrategy( strategy.name() );
+        importOptions.setImportStrategy( strategy );
         InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
 
         if ( !importOptions.isAsync() )
@@ -347,7 +347,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_ADD')" )
     public void postJsonEvent( @RequestParam( defaultValue = "CREATE" ) ImportStrategy strategy, HttpServletResponse response, HttpServletRequest request, ImportOptions importOptions ) throws Exception
     {
-        importOptions.setImportStrategy( strategy.name() );
+        importOptions.setImportStrategy( strategy );
         InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
 
         if ( !importOptions.isAsync() )

=== 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	2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java	2015-08-30 17:07:42 +0000
@@ -28,25 +28,26 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.opensymphony.xwork2.Action;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.IdentifiableProperty;
+import org.hisp.dhis.commons.util.StreamUtils;
+import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
-import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.importexport.action.util.ImportDataValueTask;
 import org.hisp.dhis.scheduling.TaskCategory;
 import org.hisp.dhis.scheduling.TaskId;
 import org.hisp.dhis.system.notification.Notifier;
 import org.hisp.dhis.system.scheduling.Scheduler;
-import org.hisp.dhis.commons.util.StreamUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
+import com.opensymphony.xwork2.Action;
 
 /**
  * @author Lars Helge Overland
@@ -153,8 +154,10 @@
 
         in = StreamUtils.wrapAndCheckCompressionFormat( in );
 
-        ImportOptions options = new ImportOptions( idScheme, dataElementIdScheme, orgUnitIdScheme, dryRun, preheatCache, strategy, skipExistingCheck );
-
+        ImportOptions options = new ImportOptions().
+            setIdScheme( idScheme ).setDataElementIdScheme( dataElementIdScheme ).setOrgUnitIdScheme( orgUnitIdScheme ).
+            setDryRun( dryRun ).setPreheatCache( preheatCache ).setStrategy( strategy ).setSkipExistingCheck( skipExistingCheck );
+        
         log.info( options );
 
         scheduler.executeTask( new ImportDataValueTask( dataValueSetService, in, options, taskId, importFormat ) );

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/MetaDataImportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/MetaDataImportAction.java	2015-07-03 14:17:06 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/MetaDataImportAction.java	2015-08-30 17:07:42 +0000
@@ -35,13 +35,14 @@
 import java.util.Map;
 
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.commons.util.StreamUtils;
 import org.hisp.dhis.dataelement.CategoryOptionGroup;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.csv.CsvImportService;
 import org.hisp.dhis.dxf2.gml.GmlImportService;
-import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.metadata.ImportService;
 import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.importexport.action.util.ImportMetaDataCsvTask;
@@ -54,7 +55,6 @@
 import org.hisp.dhis.scheduling.TaskId;
 import org.hisp.dhis.system.notification.Notifier;
 import org.hisp.dhis.system.scheduling.Scheduler;
-import org.hisp.dhis.commons.util.StreamUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.validation.ValidationRule;
@@ -171,7 +171,7 @@
         in = StreamUtils.wrapAndCheckCompressionFormat( in );
 
         ImportOptions importOptions = new ImportOptions();
-        importOptions.setStrategy( strategy.toString() );
+        importOptions.setStrategy( strategy );
         importOptions.setDryRun( dryRun );
         importOptions.setPreheatCache( preheatCache );
 

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java	2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/event/ImportEventAction.java	2015-08-30 17:07:42 +0000
@@ -28,29 +28,32 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.opensymphony.xwork2.Action;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.hisp.dhis.common.IdentifiableProperty;
+import org.hisp.dhis.commons.util.StreamUtils;
+import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.dxf2.events.event.EventService;
 import org.hisp.dhis.dxf2.events.event.Events;
 import org.hisp.dhis.dxf2.events.event.ImportEventTask;
 import org.hisp.dhis.dxf2.events.event.ImportEventsTask;
 import org.hisp.dhis.dxf2.events.event.csv.CsvEventService;
-import org.hisp.dhis.dxf2.common.ImportOptions;
 import org.hisp.dhis.scheduling.TaskCategory;
 import org.hisp.dhis.scheduling.TaskId;
 import org.hisp.dhis.system.notification.Notifier;
 import org.hisp.dhis.system.scheduling.Scheduler;
-import org.hisp.dhis.commons.util.StreamUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
+import com.opensymphony.xwork2.Action;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
-public class ImportEventAction implements Action
+public class ImportEventAction 
+    implements Action
 {
     public static final String FORMAT_CSV = "csv";
 
@@ -102,9 +105,9 @@
         this.payloadFormat = payloadFormat;
     }
 
-    private String orgUnitIdScheme = "UID";
+    private IdentifiableProperty orgUnitIdScheme = IdentifiableProperty.UID;
 
-    public void setOrgUnitIdScheme( String orgUnitIdScheme )
+    public void setOrgUnitIdScheme( IdentifiableProperty orgUnitIdScheme )
     {
         this.orgUnitIdScheme = orgUnitIdScheme;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.java	2015-07-03 14:17:06 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/util/ImportMetaDataGmlTask.java	2015-08-30 17:07:42 +0000
@@ -76,7 +76,7 @@
     @Override
     public void run()
     {
-        importOptions.setImportStrategy( ImportStrategy.UPDATE.name() );
+        importOptions.setImportStrategy( ImportStrategy.UPDATE );
         gmlImportService.importGml( inputStream, userUid, importOptions, taskId );
     }
 }