← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2591: Removed function for generating min-max in data entry - not so relevant function and better done ...

 

------------------------------------------------------------
revno: 2591
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-01-17 13:03:26 +0100
message:
  Removed function for generating min-max in data entry - not so relevant function and better done from administration module
removed:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.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-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java	2010-04-29 04:33:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java	1970-01-01 00:00:00 +0000
@@ -1,143 +0,0 @@
-package org.hisp.dhis.de.action;
-
-/*
- * Copyright (c) 2004-2010, 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 java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.de.state.SelectedStateManager;
-import org.hisp.dhis.minmax.MinMaxDataElement;
-import org.hisp.dhis.minmax.MinMaxDataElementService;
-import org.hisp.dhis.minmax.validation.MinMaxValuesGenerationService;
-import org.hisp.dhis.options.SystemSettingManager;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Margrethe Store
- * @version $Id: MinMaxGeneratingAction.java 5568 2008-08-21 13:47:11Z larshelg $
- * @version $Id: MinMaxGeneratingAction.java 2010-04-16 13:47:11Z Chau Thu Tran $
- */
-public class MinMaxGeneratingAction implements Action {
-    private static final Log log = LogFactory.getLog( MinMaxGeneratingAction.class );
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private MinMaxDataElementService minMaxDataElementService;
-
-    public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
-    {
-        this.minMaxDataElementService = minMaxDataElementService;
-    }
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private MinMaxValuesGenerationService minMaxValuesGenerationService;
-
-    public void setMinMaxValuesGenerationService( MinMaxValuesGenerationService minMaxValuesGenerationService )
-    {
-        this.minMaxValuesGenerationService = minMaxValuesGenerationService;
-    }
-
-    private SystemSettingManager systemSettingManager;
-
-    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
-    {
-        this.systemSettingManager = systemSettingManager;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private List<MinMaxDataElement> minMaxDataElements;
-
-    public List<MinMaxDataElement> getMinMaxDataElements()
-    {
-        return minMaxDataElements;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        log.info( "Starting min-max limits generation" );
-
-        minMaxDataElements = new ArrayList<MinMaxDataElement>();
-
-        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        DataSet dataSet = selectedStateManager.getSelectedDataSet();
-
-        Double factor = (Double) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_FACTOR_OF_DEVIATION,
-            2.0 );
-
-        // Get min/max values for dataelements into dataset
-        Collection<MinMaxDataElement> minMaxDataElements = (Collection<MinMaxDataElement>) minMaxValuesGenerationService
-            .getMinMaxValues( organisationUnit, dataSet.getDataElements(), factor );
-
-        // Save min / max value
-        for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
-        {
-            MinMaxDataElement minMaxValue = minMaxDataElementService.getMinMaxDataElement( minMaxDataElement
-                .getSource(), minMaxDataElement.getDataElement(), minMaxDataElement.getOptionCombo() );
-
-            if ( minMaxValue != null )
-            {
-                minMaxValue.setMax( minMaxDataElement.getMax() );
-                minMaxValue.setMin( minMaxDataElement.getMin() );
-                minMaxDataElementService.updateMinMaxDataElement( minMaxValue );
-            }
-            else
-            {
-                minMaxDataElement.setGenerated( true );
-                minMaxDataElementService.addMinMaxDataElement( minMaxDataElement );
-            }
-        }
-
-        log.info( "Generated min-max limits" );
-
-        return SUCCESS;
-    }
-    
-}

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java	2010-12-30 09:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java	2011-01-17 12:03:26 +0000
@@ -152,7 +152,7 @@
         // Retain only DataSets from current user's authority groups
         // ---------------------------------------------------------------------
 
-        if ( !currentUserService.currentUserIsSuper() )
+        if ( currentUserService.getCurrentUser() != null && !currentUserService.currentUserIsSuper() )
         {
             UserCredentials userCredentials = userService.getUserCredentials( currentUserService.getCurrentUser() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2011-01-17 12:03:26 +0000
@@ -141,13 +141,6 @@
 		<property name="dataValueAuditService" ref="org.hisp.dhis.datavalue.DataValueAuditService" />
 	</bean>
 
-	<bean id="org.hisp.dhis.de.action.MinMaxGeneratingAction" class="org.hisp.dhis.de.action.MinMaxGeneratingAction" scope="prototype">
-		<property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
-		<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
-		<property name="minMaxValuesGenerationService" ref="org.hisp.dhis.minmax.validation.MinMaxValuesGenerationService" />
-		<property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
-	</bean>
-
 	<bean id="org.hisp.dhis.de.action.RegisterCompleteDataSetAction" class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction" scope="prototype">
 		<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
 		<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2010-11-26 21:48:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-01-17 12:03:26 +0000
@@ -103,12 +103,6 @@
 			<param name="javascripts">javascript/history.js</param>
 		</action>
 
-		<action name="minMaxGeneration" class="org.hisp.dhis.de.action.MinMaxGeneratingAction">
-			<result name="success" type="velocity-xml">responseMinMaxGeneration.vm</result>
-			<param name="onExceptionReturn">plainTextError</param>
-			<param name="requiredAuthorities">F_DATAELEMENT_MINMAX_ADD,F_DATAELEMENT_MINMAX_UPDATE</param>
-		</action>
-
 		<action name="registerCompleteDataSet" class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction">
 			<result name="success" type="velocity">/dhis-web-dataentry/responseVoid.vm</result>
 			<result name="input" type="velocity-xml">/dhis-web-dataentry/responseInput.vm</result>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2010-11-26 19:56:18 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-01-17 12:03:26 +0000
@@ -367,69 +367,6 @@
 }
 
 // -----------------------------------------------------------------------------
-// Min max
-// -----------------------------------------------------------------------------
-
-/**
- * Set min/max limits for dataelements that has one or more values, and no 
- * manually entred min/max limits.
- */
-function SetGeneratedMinMaxValues()
-{
-    this.save = function()
-    {
-        var request = new Request();
-        request.setCallbackSuccess( handleResponse );
-        request.setCallbackError( handleHttpError );
-        request.setResponseTypeXML( 'minmax' );
-        request.send( 'minMaxGeneration.action' );
-    };
-    
-    function handleResponse( rootElement )
-    {
-        var dataElements = rootElement.getElementsByTagName( 'dataelement' );
-        
-        for( i = 0; i < dataElements.length; i++ )
-        {
-            var deId = getElementValue( dataElements[i], 'dataelementId' );
-            var ocId = getElementValue( dataElements[i], 'optionComboId' );
-            
-            setInnerHTML('value[' + deId + ':' + ocId + '].min', getElementValue( dataElements[i], 'minLimit'));
-            setInnerHTML('value[' + deId + ':' + ocId + '].max', getElementValue( dataElements[i], 'maxLimit'));
-        }        
-    }
-    
-    function handleHttpError( errorCode )
-    {
-        window.alert( i18n_saving_minmax_failed_error_code + '\n\n' + errorCode );
-    }
-    
-    function getElementValue( parentElement, childElementName )
-    {
-        var textNode = parentElement.getElementsByTagName( childElementName )[0].firstChild;
-        
-        if ( textNode )
-        {
-            return textNode.nodeValue;
-        }
-        else
-        {
-            return null;
-        }
-    }    
-}
-
-function generateMinMaxValues()
-{    
-	lockScreen();
-	var setGeneratedMinMaxValues = new SetGeneratedMinMaxValues();
-    setGeneratedMinMaxValues.save();
-	
-	unLockScreen();
-	setHeaderDelayMessage(i18n_generate_min_max_success);
-}
-
-// -----------------------------------------------------------------------------
 // Data completeness
 // -----------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-01-06 16:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-01-17 12:03:26 +0000
@@ -9,7 +9,6 @@
 </div>
 
 <div id="actions" style="">	
-    <input type="button" value="$i18n.getString( 'generate_min_max' )" onclick="javascript:generateMinMaxValues()" style="width:150px" #if( !$auth.hasAccess( "dhis-web-dataentry", "minMaxGeneration" ) ) disabled="disabled" #end/><br/>
     <input type="button" value="$i18n.getString( 'run_validation' )" onclick="javascript:validate()" style="width:150px"/><br/>
     <input type="button" id="calculateCDEs" value="$i18n.getString( 'save_calculated' )" name="calculateCDEs" onclick="calculateAndSaveCDEs()" style="width:150px"/><br/><br/>