← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6874: Implemented import option for skipping check for existing data value records

 

------------------------------------------------------------
revno: 6874
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-05-07 16:57:43 +0200
message:
  Implemented import option for skipping check for existing data value records
modified:
  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/metadata/ImportOptions.java
  dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.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/resources/org/hisp/dhis/importexport/i18n_module.properties
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js


--
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/DefaultDataValueSetService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2012-05-07 14:29:01 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2012-05-07 14:57:43 +0000
@@ -219,6 +219,7 @@
         IdentifiableProperty orgUnitIdScheme = dataValueSet.getOrgUnitIdScheme() != null ? IdentifiableProperty.valueOf( dataValueSet.getOrgUnitIdScheme().toUpperCase() ) : importOptions.getOrgUnitIdScheme();
         boolean dryRun = dataValueSet.getDryRun() != null ? dataValueSet.getDryRun() : importOptions.isDryRun();
         ImportStrategy strategy = dataValueSet.getStrategy() != null ? ImportStrategy.valueOf( dataValueSet.getStrategy() ) : importOptions.getImportStrategy();
+        boolean skipExistingCheck = importOptions.isSkipExistingCheck();
         
         Map<String, DataElement> dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, dataElementIdScheme );
         Map<String, OrganisationUnit> orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, orgUnitIdScheme );
@@ -312,7 +313,7 @@
             internalValue.setComment( dataValue.getComment() );
             internalValue.setFollowup( dataValue.getFollowup() );
             
-            if ( batchHandler.objectExists( internalValue ) )
+            if ( !skipExistingCheck && batchHandler.objectExists( internalValue ) )
             {
                 if ( NEW_AND_UPDATES.equals( strategy ) || UPDATES.equals( strategy ) )
                 {

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java	2012-04-20 18:31:48 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java	2012-05-07 14:57:43 +0000
@@ -42,8 +42,10 @@
     private boolean dryRun = false;
 
     private ImportStrategy importStrategy;
+    
+    private boolean skipExistingCheck;
 
-    private static final ImportOptions DEFAULT_OPTIONS = new ImportOptions( IdentifiableProperty.UID, IdentifiableProperty.UID, false, ImportStrategy.NEW_AND_UPDATES );
+    private static final ImportOptions DEFAULT_OPTIONS = new ImportOptions( IdentifiableProperty.UID, IdentifiableProperty.UID, false, ImportStrategy.NEW_AND_UPDATES, false );
 
     public static ImportOptions getDefaultImportOptions()
     {
@@ -59,12 +61,13 @@
         this.importStrategy = importStrategy;
     }
 
-    public ImportOptions( IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme, boolean dryRun, ImportStrategy importStrategy )
+    public ImportOptions( IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme, boolean dryRun, ImportStrategy importStrategy, boolean skipExistingCheck )
     {
         this.dataElementIdScheme = dataElementIdScheme;
         this.orgUnitIdScheme = orgUnitIdScheme;
         this.dryRun = dryRun;
         this.importStrategy = importStrategy;
+        this.skipExistingCheck = skipExistingCheck;
     }
 
     //--------------------------------------------------------------------------
@@ -91,6 +94,11 @@
         return importStrategy != null ? importStrategy : ImportStrategy.NEW_AND_UPDATES;
     }
 
+    public boolean isSkipExistingCheck()
+    {
+        return skipExistingCheck;
+    }
+
     //--------------------------------------------------------------------------
     // Set methods
     //--------------------------------------------------------------------------
@@ -114,11 +122,16 @@
     {
         this.importStrategy = strategy != null ? ImportStrategy.valueOf( strategy.toUpperCase() ) : null;
     }
-    
+
+    public void setSkipExistingCheck( boolean skipExistingCheck )
+    {
+        this.skipExistingCheck = skipExistingCheck;
+    }
+
     @Override
     public String toString()
     {
         return "[data element id scheme: " + dataElementIdScheme + ", org unit id scheme: " + 
-            orgUnitIdScheme + ", dry run: " + dryRun + ", strategy: " + importStrategy + "]";
+            orgUnitIdScheme + ", dry run: " + dryRun + ", strategy: " + importStrategy + ", skip check: " + skipExistingCheck + "]";
     }
 }

=== 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 20:48:08 +0000
+++ dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetServiceTest.java	2012-05-07 14:57:43 +0000
@@ -203,7 +203,7 @@
     public void testImportDataValuesXmlDryRun()
         throws Exception
     {
-        ImportOptions options = new ImportOptions( UID, UID, true, NEW_AND_UPDATES );
+        ImportOptions options = new ImportOptions( UID, UID, true, NEW_AND_UPDATES, false );
         
         dataValueSetService.saveDataValueSet( new ClassPathResource( "datavalueset/dataValueSetB.xml" ).getInputStream(), options );
         
@@ -217,7 +217,7 @@
     public void testImportDataValuesXmlUpdatesOnly()
         throws Exception
     {
-        ImportOptions options = new ImportOptions( UID, UID, false, UPDATES );
+        ImportOptions options = new ImportOptions( UID, UID, false, UPDATES, false );
         
         dataValueSetService.saveDataValueSet( new ClassPathResource( "datavalueset/dataValueSetB.xml" ).getInputStream(), options );
         

=== 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-30 20:10:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/datavalue/ImportDataValueAction.java	2012-05-07 14:57:43 +0000
@@ -107,6 +107,13 @@
     {
         this.orgUnitIdScheme = orgUnitIdScheme;
     }
+    
+    private boolean skipExistingCheck;
+
+    public void setSkipExistingCheck( boolean skipExistingCheck )
+    {
+        this.skipExistingCheck = skipExistingCheck;
+    }
 
     private String importFormat;
 
@@ -139,7 +146,7 @@
 
         TaskId taskId = new TaskId( TaskCategory.DATAVALUE_IMPORT, currentUserService.getCurrentUser() );
 
-        ImportOptions options = new ImportOptions( dataElementIdScheme, orgUnitIdScheme, dryRun, strategy );
+        ImportOptions options = new ImportOptions( dataElementIdScheme, orgUnitIdScheme, dryRun, strategy, skipExistingCheck );
         
         log.info( options );
         

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2012-04-30 20:10:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2012-05-07 14:57:43 +0000
@@ -303,4 +303,7 @@
 uid=UID
 name=Name
 code=Code
-more_options=More options
\ No newline at end of file
+more_options=More options
+existing_record_check=Existing record check
+check_safe_recommended=Check (safe + recommended)
+skip_check_fast=Skip check (fast)
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2012-04-30 20:10:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2012-05-07 14:57:43 +0000
@@ -12,14 +12,14 @@
 </tr>
 <tr>
 	<td>$i18n.getString( "dry_run" )</td>
-	<td><select id="dryRun" name="dryRun" style="width:180px">
+	<td><select id="dryRun" name="dryRun" style="width:190px">
 		<option value="false">$i18n.getString( "no" )</option>
 		<option value="true">$i18n.getString( "yes" )</option>
     </select></td>
 </tr>
 <tr>
 	<td>$i18n.getString( "strategy" )</td>
-	<td><select id="strategy" name="strategy" style="width:180px">
+	<td><select id="strategy" name="strategy" style="width:190px">
 		<option value="NEW_AND_UPDATES">$i18n.getString( "new_and_updates" )</option>
 		<option value="NEW">$i18n.getString( "new_only" )</option>
 		<option value="UPDATES">$i18n.getString( "updates_only" )</option>
@@ -31,7 +31,7 @@
 </tr>
 <tr class="moreOptions" style="display:none">
 	<td>$i18n.getString( "data_element_id_scheme" )</td>	
-	<td><select id="dataElementIdScheme" name="dataElementIdScheme" style="width:180px">
+	<td><select id="dataElementIdScheme" name="dataElementIdScheme" style="width:190px">
 		<option value="UID">$i18n.getString( "uid" )</option>
 		<option value="NAME">$i18n.getString( "name" )</option>
 		<option value="CODE">$i18n.getString( "code" )</option>
@@ -39,12 +39,19 @@
 </tr>
 <tr class="moreOptions" style="display:none">
 	<td>$i18n.getString( "org_unit_id_scheme" )</td>	
-	<td><select id="orgUnitIdScheme" name="orgUnitIdScheme" style="width:180px">
+	<td><select id="orgUnitIdScheme" name="orgUnitIdScheme" style="width:190px">
 		<option value="UID">$i18n.getString( "uid" )</option>
 		<option value="NAME">$i18n.getString( "name" )</option>
 		<option value="CODE">$i18n.getString( "code" )</option>
     </select></td>
 </tr>
+<tr class="moreOptions" style="display:none">
+	<td>$i18n.getString( "existing_record_check" )</td>	
+	<td><select id="skipExistingCheck" name="skipExistingCheck" style="width:190px">
+		<option value="false">$i18n.getString( "check_safe_recommended" )</option>
+		<option value="true">$i18n.getString( "skip_check_fast" )</option>
+    </select></td>
+</tr>
 <tr>
 	<td></td>
 	<td><input type="button" value="$i18n.getString( 'import' )" style="width:120px" onclick="importDataValue()"/></td>

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js	2012-04-30 20:10:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js	2012-05-07 14:57:43 +0000
@@ -15,7 +15,7 @@
 function toggleOptions()
 {
 	$( ".moreOptions" ).toggle();
-	$.toggleCss( "inputCriteria", "height", "144px", "200px" );
+	$.toggleCss( "inputCriteria", "height", "144px", "230px" );
 }
 
 function pingNotificationsTimeout()