← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15782: Validation, stddev/min-max analysis, removed possibility of changing data value directly. Too com...

 

------------------------------------------------------------
revno: 15782
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-06-20 12:57:40 +0200
message:
  Validation, stddev/min-max analysis, removed possibility of changing data value directly. Too complicated to keep in sync with the access control rules for doing data entry.
removed:
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/editDataValue.js
modified:
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm


--
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
=== removed file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/EditDataValueAction.java	1970-01-01 00:00:00 +0000
@@ -1,202 +0,0 @@
-package org.hisp.dhis.validationrule.action.dataanalysis;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * 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.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.user.CurrentUserService;
-
-import java.util.Date;
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Jon Moen Drange
- */
-public class EditDataValueAction
-    implements Action
-{
-    private static final Log log = LogFactory.getLog( EditDataValueAction.class );
-    
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private DataValueService dataValueService;
-
-    public void setDataValueService( DataValueService dataValueService )
-    {
-        this.dataValueService = dataValueService;
-    }
-
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private PeriodService periodService;
-
-    public void setPeriodService( PeriodService periodService )
-    {
-        this.periodService = periodService;
-    }
-    
-    private DataElementCategoryService categoryService;
-
-    public void setCategoryService( DataElementCategoryService categoryService )
-    {
-        this.categoryService = categoryService;
-    }
-
-    private CurrentUserService currentUserService;
-
-    public void setCurrentUserService( CurrentUserService currentUserService )
-    {
-        this.currentUserService = currentUserService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input & Output
-    // -------------------------------------------------------------------------
-
-    private String value;
-
-    public void setValue( String value )
-    {
-        this.value = value;
-    }
-
-    private Integer dataElementId;
-
-    public void setDataElementId( Integer dataElementId )
-    {
-        this.dataElementId = dataElementId;
-    }
-
-    private Integer periodId;
-
-    public void setPeriodId( Integer periodId )
-    {
-        this.periodId = periodId;
-    }
-
-    private Integer organisationUnitId;
-
-    public void setOrganisationUnitId( Integer organisationUnitId )
-    {
-        this.organisationUnitId = organisationUnitId;
-    }
-    
-    private Integer categoryOptionComboId;
-
-    public void setCategoryOptionComboId( Integer categoryOptionComboId )
-    {
-        this.categoryOptionComboId = categoryOptionComboId;
-    }
-
-    private int code = 0;
-
-    public int getCode()
-    {
-        return code;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        if ( value != null && value.trim().length() == 0 )
-        {
-            value = null;
-        }
-
-        if ( value != null )
-        {
-            value = value.trim();
-        }
-
-        DataElement dataElement = dataElementService.getDataElement( dataElementId );
-        Period period = periodService.getPeriod( periodId );
-        OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-        DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionComboId );
-        
-        DataValue dataValue = dataValueService.getDataValue( dataElement, period, unit, categoryOptionCombo );
-
-        String storedBy = currentUserService.getCurrentUsername();
-
-        storedBy = storedBy == null ? "[unknown]" : storedBy;
-
-        if ( dataValue == null ) // Add new
-        {
-            dataValue = new DataValue();
-            dataValue.setDataElement( dataElement );
-            dataValue.setPeriod( period );
-            dataValue.setSource( unit );
-            dataValue.setCategoryOptionCombo( categoryOptionCombo );
-            dataValue.setValue( value );
-            dataValue.setStoredBy( storedBy );
-            
-            dataValueService.addDataValue( dataValue );
-            
-            log.info( "Added data value: " + value );
-            
-            return SUCCESS;
-        }
-
-        dataValue.setValue( value );
-        dataValue.setStoredBy( storedBy );
-        dataValue.setTimestamp( new Date() );
-
-        dataValueService.updateDataValue( dataValue );
-
-        log.info( "Updated data value: " + value );
-        
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml	2014-05-18 00:49:40 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml	2014-06-20 10:57:40 +0000
@@ -185,17 +185,6 @@
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
   </bean>
 
-  <bean id="org.hisp.dhis.validationrule.action.dataanalysis.EditDataValueAction"
-    class="org.hisp.dhis.validationrule.action.dataanalysis.EditDataValueAction"
-    scope="prototype">
-    <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
-    <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
-    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-  </bean>
-
   <bean id="org.hisp.dhis.validationrule.action.dataanalysis.MarkForFollowupAction"
     class="org.hisp.dhis.validationrule.action.dataanalysis.MarkForFollowupAction"
     scope="prototype">

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2014-03-24 19:15:32 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2014-06-20 10:57:40 +0000
@@ -174,8 +174,7 @@
         ../dhis-web-commons/ouwt/ouwt.js,
         ../dhis-web-commons/oust/oust.js,
         ../dhis-web-commons/javascripts/lists.js,
-        javascript/dataAnalysis.js,
-        javascript/editDataValue.js
+        javascript/dataAnalysis.js
       </param>
       <interceptor-ref name="organisationUnitTreeStack" />
       <param name="requiredAuthorities">F_RUN_VALIDATION</param>
@@ -185,7 +184,7 @@
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-validationrule/followUpAnalysisForm.vm</param>
       <param name="menu">/dhis-web-validationrule/menu.vm</param>
-      <param name="javascripts">javascript/dataAnalysis.js,javascript/editDataValue.js</param>
+      <param name="javascripts">javascript/dataAnalysis.js</param>
       <param name="requiredAuthorities">F_RUN_VALIDATION</param>
     </action>
 
@@ -194,11 +193,6 @@
       <param name="requiredAuthorities">F_RUN_VALIDATION</param>
     </action>
 
-    <action name="editDataValue" class="org.hisp.dhis.validationrule.action.dataanalysis.EditDataValueAction">
-      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-      <param name="requiredAuthorities">F_DATAVALUE_ADD,F_DATAVALUE_DELETE</param>
-    </action>
-
     <action name="markForFollowup" class="org.hisp.dhis.validationrule.action.dataanalysis.MarkForFollowupAction">
       <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
     </action>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js	2013-10-15 14:31:30 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js	2014-06-20 10:57:40 +0000
@@ -104,3 +104,32 @@
     var url = 'exportAnalysisResult.action?type=' + type;
     window.location.href = url;
 }
+
+function markFollowUp( valueId )
+{	
+    var dataElementId = $( '#value-' + valueId + '-de' ).val();
+    var categoryOptionComboId = $( '#value-' + valueId + '-coc' ).val();
+    var periodId = $( '#value-' + valueId + '-pe' ).val();
+    var sourceId = $( '#value-' + valueId + '-ou' ).val();
+    
+    $.ajax( {
+    	url: 'markForFollowup.action',
+    	data: { dataElementId:dataElementId, periodId:periodId, sourceId:sourceId, categoryOptionComboId:categoryOptionComboId },
+    	type: 'POST',
+    	dataType: 'json',
+    	success: function( json )
+		{
+            var $image = $( '#value-' + valueId + '-followUp' );
+			
+            if ( json.message == "marked" )
+		    {
+		        $image.attr( "src", "../images/marked.png" );
+		        $image.attr( "title", i18n_unmark_value_for_followup );
+		    }
+		    else if ( json.message == "unmarked" )
+		    {
+		        $image.attr( "src", "../images/unmarked.png" );
+		        $image.attr( "title", i18n_mark_value_for_followup );   
+		    }
+		} } );
+}

=== removed file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/editDataValue.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/editDataValue.js	2014-01-23 14:09:55 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/editDataValue.js	1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
-
-function editValue( valueId )
-{
-	var field = document.getElementById( 'value-' + valueId + '-val' );
-	
-	var dataElementId = $( '#value-' + valueId + '-de' ).val();
-    var categoryOptionComboId = $( '#value-' + valueId + '-coc' ).val();
-	var periodId = $( '#value-' + valueId + '-pe' ).val();
-	var sourceId = $( '#value-' + valueId + '-ou' ).val();
-	
-	if ( field.value != '' )
-	{
-		if ( !dhis2.validation.isInt( field.value ) )
-		{
-			alert( i18n_value_must_be_a_number );
-			
-			field.select();
-	        field.focus(); 
-	        
-			return;   
-		}
-		else
-		{
-			var minString = $( '#value-' + valueId + '-min' ).val();
-			var maxString = $( '#value-' + valueId + '-max' ).val();
-			
-			var min = new Number( minString );
-			var max = new Number( maxString );
-			var value = new Number( field.value );
-			
-			if ( !( min == 0 && max == 0 ) ) // No min max found
-			{
-				if ( value < min )
-				{
-					var valueSaver = new ValueSaver( dataElementId, periodId, sourceId, categoryOptionComboId, field.value, valueId, '#ffcccc' );
-					valueSaver.save();
-					
-					alert( i18n_value_is_lower_than_min_value );
-					return;
-				}
-				
-				if ( value > max )
-				{
-					var valueSaver = new ValueSaver( dataElementId, periodId, sourceId, categoryOptionComboId, field.value, valueId, '#ffcccc' );
-					valueSaver.save();
-					
-					alert( i18n_value_is_higher_than_max_value );
-					return;
-				}
-			}
-		}
-	}
-	
-    var valueSaver = new ValueSaver( dataElementId, periodId, sourceId, categoryOptionComboId, field.value, valueId, '#ccffcc' );
-    valueSaver.save();
-}
-
-function markFollowUp( valueId )
-{	
-    var dataElementId = $( '#value-' + valueId + '-de' ).val();
-    var categoryOptionComboId = $( '#value-' + valueId + '-coc' ).val();
-    var periodId = $( '#value-' + valueId + '-pe' ).val();
-    var sourceId = $( '#value-' + valueId + '-ou' ).val();
-    
-    $.ajax( {
-    	url: 'markForFollowup.action',
-    	data: { dataElementId:dataElementId, periodId:periodId, sourceId:sourceId, categoryOptionComboId:categoryOptionComboId },
-    	type: 'POST',
-    	dataType: 'json',
-    	success: function( json )
-		{
-            var $image = $( '#value-' + valueId + '-followUp' );
-			
-            if ( json.message == "marked" )
-		    {
-		        $image.attr( "src", "../images/marked.png" );
-		        $image.attr( "title", i18n_unmark_value_for_followup );
-		    }
-		    else if ( json.message == "unmarked" )
-		    {
-		        $image.attr( "src", "../images/unmarked.png" );
-		        $image.attr( "title", i18n_mark_value_for_followup );   
-		    }
-		} } );
-}
-
-// -----------------------------------------------------------------------------
-// Saver object (modified version of dataentry/javascript/general.js)
-// -----------------------------------------------------------------------------
-
-function ValueSaver( dataElementId, periodId, organisationUnitId, categoryOptionComboId, value, valueId_, resultColor_ )
-{
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ccccff';
-
-    var valueId = valueId_;
-    var resultColor = resultColor_;
-    
-    this.save = function()
-    {        
-        $.ajax( {
-        	url: 'editDataValue.action',
-        	data: { dataElementId:dataElementId, periodId:periodId, organisationUnitId:organisationUnitId, categoryOptionComboId:categoryOptionComboId, value:value },
-        	type: 'POST',
-    		dataType: 'json',
-        	success: function( json )
-        	{
-        		if ( json.response == "success" )
-        		{
-        			markValue( resultColor );
-        		}
-        		else
-		        {
-		            markValue( ERROR );
-		            window.alert( "Failed saving value" );
-		        }
-        	},
-        	error: function( json )
-        	{
-        		markValue( ERROR );
-        		window.alert( "Failed saving value" );
-        	}
-        } );        
-    };
-    
-    function markValue( color )
-    {
-    	$( '#value-' + valueId + '-val' ).css( "background-color", color );
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm	2013-10-15 14:31:30 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm	2014-06-20 10:57:40 +0000
@@ -11,8 +11,6 @@
     var i18n_unmark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "unmark_value_for_followup" ) , "'")';
 </script>
 
-#set( $hasAccess = $auth.hasAccess( "dhis-web-validationrule", "editDataValue" ) )
-
 #if ( $dataValues.size() == 0 )
 
 <span id="info">$i18n.getString( "no_values_found" )</span>
@@ -54,8 +52,7 @@
 		
 		<td style="text-align:center">$value.min</td>
 		
-		<td style="width:100px">
-			<input id="value-${count}-val" value="$value.value" style="width: 95%; text-align: center;" tabindex="$count" type="text" onchange="editValue( $count )"#if( !$hasAccess ) disabled="disabled"#end>			
+		<td style="width:100px; text-align:center;">$encoder.htmlEncode( $value.value )		
             <input type="hidden" id="value-${count}-de" value="$value.dataElementId">
             <input type="hidden" id="value-${count}-pe" value="$value.periodId">
             <input type="hidden" id="value-${count}-ou" value="$value.sourceId">