← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1394: Improved duplicate data elimination user interface.

 

------------------------------------------------------------
revno: 1394
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-02-04 13:29:22 +0100
message:
  Improved duplicate data elimination user interface.
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/DefaultDataMergeService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.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-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/DefaultDataMergeService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/DefaultDataMergeService.java	2010-01-28 09:23:55 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/datamerge/DefaultDataMergeService.java	2010-02-04 12:29:22 +0000
@@ -27,6 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.DeleteNotAllowedException;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -43,6 +46,8 @@
 public class DefaultDataMergeService
     implements DataMergeService
 {
+    private static final Log log = LogFactory.getLog( DefaultDataMergeService.class );
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -92,7 +97,10 @@
         }
         catch ( HierarchyViolationException ex )
         {
-            // Do nothing for now
+        }
+        catch ( DeleteNotAllowedException ex )
+        {
+            log.info( "Not deleting data element because it has custom dimensions and more data associated with it" );
         }
     }
 
@@ -126,7 +134,6 @@
         }
         catch ( HierarchyViolationException ex )
         {
-            // Do nothing for now
         }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm	2010-01-25 11:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/duplicateDataEliminationForm.vm	2010-02-04 12:29:22 +0000
@@ -3,9 +3,8 @@
 
 <div>
 	<label>$i18n.getString( "filter" ):</label><br>
-	<input type="text" style="width:294px" onkeyup="filterList( this.value, 'dataElementList' )"><br>
-	<select id="dataElementList" size="6" style="width:300px" onclick="dataElementSelected()"></select>
-	<select id="categoryOptionComboList" size="6" style="width:200px" onclick="categoryOptionComboSelected()"></select>
+	<input type="text" style="width:294px" onkeyup="filterList( this.value, 'operandList' )"><br>
+	<select id="operandList" size="6" style="width:400px" onclick="operandSelected()"></select>
 </div>
 
 <br>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js	2010-02-01 20:21:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/duplicateDataElimination.js	2010-02-04 12:29:22 +0000
@@ -1,79 +1,44 @@
 
-var dataElementToEliminate = 0;
-var categoryOptionComboToEliminate = 0;
-var dataElementToKeep = 0;
-var categoryOptionComboToKeep = 0;
+var operandToEliminate = 0;
+var operandToKeep = 0;
 
 function initLists()
 {	
 	$.getJSON( 
-        "../dhis-web-commons-ajax-json/getDataElements.action",
+        "../dhis-web-commons-ajax-json/getOperands.action",
         {},
         function( json )
         {
-        	var elements = json.dataElements;
-        	
-        	for ( var i = 0; i < elements.length; i++ )
-        	{
-        	   $( "#dataElementList" ).append( "<option value='" + 
-        	       elements[i].id + "'>" + elements[i].name + "</option>" );
-        	}
-        }
-    );
-}
-
-function dataElementSelected()
-{
-	$( "#categoryOptionComboList" ).children().remove();
-	
-	var dataElementId = $( "#dataElementList" ).val();
-	
-	$.getJSON( 
-        "../dhis-web-commons-ajax-json/getCategoryOptionCombos.action",
-        {
-        	"id": dataElementId
-        },
-        function( json )
-        {
-        	var cocs = json.categoryOptionCombos;
-        	
-        	for ( var i = 0; i < cocs.length; i++ )
-        	{
-        		$( "#categoryOptionComboList" ).append( "<option value='" +
-        		    cocs[i].id + "'>" + cocs[i].name + "</option>" );
-        	}
-        }
-    );
-}
-
-function categoryOptionComboSelected()
-{
-	$.getJSON( 
-	    "../dhis-web-commons-ajax-json/getDataElementName.action",
-	    {
-	   	    "dataElementId": $( "#dataElementList" ).val(),
-	   	    "categoryOptionComboId": $( "#categoryOptionComboList" ).val()
-	    },
-	    function( json )
-	    {
-	        if ( dataElementToEliminate == 0 && categoryOptionComboToEliminate == 0 ) // Step 1
-		    {
-		   	    $( "#eliminateNameField" ).html( json.name );
-		   	    $( "#confirmEliminateButton" ).removeAttr( "disabled" );
-		    }
-		    else // Step 2
-            {
-                $( "#keepNameField" ).html( json.name );
-                $( "#confirmKeepButton" ).removeAttr( "disabled" );
-		    }
-        }
-    );
+        	var operands = json.operands;
+        	
+        	for ( var i = 0; i < operands.length; i++ )
+        	{
+        	   $( "#operandList" ).append( "<option value='" + 
+        	       operands[i].id + "'>" + operands[i].operandName + "</option>" );
+        	}
+        }
+    );
+}
+
+function operandSelected()
+{
+	var operandName = $( "#operandList :selected" ).text();
+	
+	if ( operandToEliminate == 0 ) // Step 1
+    {
+        $( "#eliminateNameField" ).html( operandName );
+        $( "#confirmEliminateButton" ).removeAttr( "disabled" );
+    }
+    else // Step 2
+    {
+        $( "#keepNameField" ).html( operandName );
+        $( "#confirmKeepButton" ).removeAttr( "disabled" );
+    }	
 }
 
 function eliminateConfirmed()
 {
-	dataElementToEliminate = $( "#dataElementList" ).val();
-	categoryOptionComboToEliminate = $( "#categoryOptionComboList" ).val();
+	operandToEliminate = $( "#operandList" ).val();
 	
 	$( "#confirmEliminateButton" ).attr( "disabled", "disabled" );
 	
@@ -83,11 +48,9 @@
 
 function keepConfirmed()
 {
-	dataElementToKeep = $( "#dataElementList" ).val();
-	categoryOptionComboToKeep = $( "#categoryOptionComboList" ).val();
+	operandToKeep = $( "#operandList" ).val();
 	
-	if ( dataElementToEliminate == dataElementToKeep && 
-	   categoryOptionComboToEliminate == categoryOptionComboToKeep )
+	if ( operandToEliminate == operandToKeep )
     {
    	    setMessage( i18n_select_different_data_elements );
    	    return;
@@ -107,10 +70,10 @@
 	$.ajax({ 
 		"url": "eliminateDuplicateData.action", 
 		"data": { 
-			"dataElementToKeep": dataElementToKeep,
-			"categoryOptionComboToKeep": categoryOptionComboToKeep,
-			"dataElementToEliminate": dataElementToEliminate,
-			"categoryOptionComboToEliminate": categoryOptionComboToEliminate },
+			"dataElementToKeep": operandToKeep.split( "." )[0],
+			"categoryOptionComboToKeep": operandToKeep.split( "." )[1],
+			"dataElementToEliminate": operandToEliminate.split( "." )[0],
+			"categoryOptionComboToEliminate": operandToEliminate.split( "." )[1] },
 		"success": function()
 		{
 		    setMessage( i18n_elimination_done );