dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13084
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4141: Loading zero significant data elements at page init instead of with ajax
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4141 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-14 10:41:02 +0200
message:
Loading zero significant data elements at page init instead of with ajax
removed:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/EmptyAction.java
renamed:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadOrganisationUnitAction.java => dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java
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/entry.js
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/responsePeriods.vm
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.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/user/UserCredentials.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2011-06-19 10:57:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2011-07-14 07:22:04 +0000
@@ -33,6 +33,8 @@
import java.util.HashSet;
import java.util.Set;
+import org.hisp.dhis.dataset.DataSet;
+
/**
* @author Nguyen Hong Duc
* @version $Id: UserCredentials.java 2869 2007-02-20 14:26:09Z andegje $
@@ -87,6 +89,22 @@
}
/**
+ * Returns a set of the aggregated data sets for all user authority groups
+ * of this user credentials.
+ */
+ public Set<DataSet> getAllDataSets()
+ {
+ Set<DataSet> dataSets = new HashSet<DataSet>();
+
+ for ( UserAuthorityGroup group : userAuthorityGroups )
+ {
+ dataSets.addAll( group.getDataSets() );
+ }
+
+ return dataSets;
+ }
+
+ /**
* Indicates whether this user credentials can issue the given user authority
* group. First the given authority group must not be null. Second this
* user credentials must not contain the given authority group. Third
=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/EmptyAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/EmptyAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/EmptyAction.java 1970-01-01 00:00:00 +0000
@@ -1,48 +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 com.opensymphony.xwork2.Action;
-
-/**
- * @author Torgeir Lorange Ostby
- * @version $Id: EmptyAction.java 2974 2007-03-03 22:11:13Z torgeilo $
- */
-public class EmptyAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java 2011-05-20 13:28:27 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java 2011-07-14 08:39:01 +0000
@@ -31,9 +31,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.de.state.SelectedStateManager;
@@ -110,14 +108,7 @@
{
return periodValid;
}
-
- private Set<DataElement> significantZeros = new HashSet<DataElement>();
-
- public Set<DataElement> getSignificantZeros()
- {
- return significantZeros;
- }
-
+
private Collection<Indicator> indicators = new HashSet<Indicator>();
public Collection<Indicator> getIndicators()
@@ -164,18 +155,6 @@
}
// -----------------------------------------------------------------
- // Load data elemements for which zero values are insignificant
- // -----------------------------------------------------------------
-
- for ( DataElement dataElement : selectedDataSet.getDataElements() )
- {
- if ( dataElement.isZeroIsSignificant() )
- {
- significantZeros.add( dataElement );
- }
- }
-
- // -----------------------------------------------------------------
// Explode and add indicators from data set
// -----------------------------------------------------------------
=== renamed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadOrganisationUnitAction.java' => 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadOrganisationUnitAction.java 2011-05-20 13:28:27 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java 2011-07-14 08:39:01 +0000
@@ -27,6 +27,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.de.state.SelectedStateManager;
import com.opensymphony.xwork2.Action;
@@ -34,7 +38,7 @@
/**
* @author Lars Helge Overland
*/
-public class LoadOrganisationUnitAction
+public class PageInitAction
implements Action
{
// -------------------------------------------------------------------------
@@ -47,17 +51,37 @@
{
this.selectedStateManager = selectedStateManager;
}
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Collection<DataElement> significantZeros;
+
+ public Collection<DataElement> getSignificantZeros()
+ {
+ return significantZeros;
+ }
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
- {
+ {
selectedStateManager.clearSelectedOrganisationUnits();
selectedStateManager.clearSelectedDataSet();
selectedStateManager.clearSelectedPeriod();
+ significantZeros = dataElementService.getDataElementsByZeroIsSignificant( true );
+
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 2011-04-03 10:25:42 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java 2011-07-14 07:22:04 +0000
@@ -30,14 +30,10 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -47,9 +43,7 @@
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.user.UserAuthorityGroup;
-import org.hisp.dhis.user.UserCredentials;
-import org.hisp.dhis.user.UserService;
+import org.hisp.dhis.user.User;
import com.opensymphony.xwork2.ActionContext;
@@ -61,14 +55,9 @@
public class DefaultSelectedStateManager
implements SelectedStateManager
{
- private static final Log log = LogFactory.getLog( DefaultSelectedStateManager.class );
-
public static final String SESSION_KEY_SELECTED_DATASET_ID = "data_entry_selected_dataset_id";
-
public static final String SESSION_KEY_SELECTED_PERIOD_INDEX = "data_entry_selected_period_index";
-
- public static final String SESSION_KEY_BASE_PERIOD = "data_entry_base_period";
-
+ public static final String SESSION_KEY_BASE_PERIOD = "data_entry_base_period";
public static final String SESSION_KEY_SELECTED_DISPLAY_MODE = "data_entry_selected_display_mode";
// -------------------------------------------------------------------------
@@ -89,13 +78,6 @@
this.selectionManager = selectionManager;
}
- private UserService userService;
-
- public void setUserService( UserService userService )
- {
- this.userService = userService;
- }
-
private CurrentUserService currentUserService;
public void setCurrentUserService( CurrentUserService currentUserService )
@@ -157,18 +139,11 @@
// Retain only DataSets from current user's authority groups
// ---------------------------------------------------------------------
- if ( currentUserService.getCurrentUser() != null && !currentUserService.currentUserIsSuper() )
+ User currentUser = currentUserService.getCurrentUser();
+
+ if ( currentUser != null && !currentUserService.currentUserIsSuper() )
{
- UserCredentials userCredentials = userService.getUserCredentials( currentUserService.getCurrentUser() );
-
- Set<DataSet> dataSetUserAuthorityGroups = new HashSet<DataSet>();
-
- for ( UserAuthorityGroup userAuthorityGroup : userCredentials.getUserAuthorityGroups() )
- {
- dataSetUserAuthorityGroups.addAll( userAuthorityGroup.getDataSets() );
- }
-
- dataSets.retainAll( dataSetUserAuthorityGroups );
+ dataSets.retainAll( currentUser.getUserCredentials().getAllDataSets() );
}
// ---------------------------------------------------------------------
@@ -360,15 +335,11 @@
if ( basePeriod == null )
{
- log.debug( "Base period is null, creating new" );
-
basePeriod = periodType.createPeriod();
getSession().put( SESSION_KEY_BASE_PERIOD, basePeriod );
}
else if ( !basePeriod.getPeriodType().equals( periodType ) )
{
- log.debug( "Wrong type of base period, transforming" );
-
basePeriod = periodType.createPeriod( basePeriod.getStartDate() );
getSession().put( SESSION_KEY_BASE_PERIOD, basePeriod );
}
=== 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-07-14 06:29:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-07-14 08:39:01 +0000
@@ -3,8 +3,6 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
- <bean id="org.hisp.dhis.de.action.EmptyAction" class="org.hisp.dhis.de.action.EmptyAction" />
-
<bean id="org.hisp.dhis.de.history.HistoryRetriever" class="org.hisp.dhis.de.history.DefaultHistoryRetriever">
<property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
@@ -14,13 +12,18 @@
<bean id="org.hisp.dhis.de.state.SelectedStateManager" class="org.hisp.dhis.de.state.DefaultSelectedStateManager">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
- <property name="userService" ref="org.hisp.dhis.user.UserService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
<!-- Actions -->
+ <bean id="org.hisp.dhis.de.action.PageInitAction" class="org.hisp.dhis.de.action.PageInitAction"
+ scope="prototype">
+ <property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+ </bean>
+
<bean id="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction"
scope="prototype">
<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
@@ -28,11 +31,6 @@
<property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
</bean>
- <bean id="org.hisp.dhis.de.action.LoadOrganisationUnitAction" class="org.hisp.dhis.de.action.LoadOrganisationUnitAction"
- scope="prototype">
- <property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
- </bean>
-
<bean id="org.hisp.dhis.de.action.LoadDataSetsAction" class="org.hisp.dhis.de.action.LoadDataSetsAction" scope="prototype">
<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
</bean>
=== 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 2011-07-14 06:29:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-07-14 07:33:23 +0000
@@ -8,24 +8,20 @@
<package name="dhis-web-dataentry" extends="dhis-web-commons" namespace="/dhis-web-dataentry">
- <action name="index" class="org.hisp.dhis.de.action.EmptyAction">
- <result name="success" type="redirect">displayForm.action</result>
- </action>
-
- <action name="getDataValues" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction">
- <result name="success" type="velocity-json">/dhis-web-dataentry/responseDataValues.vm</result>
- </action>
-
- <action name="displayForm" class="org.hisp.dhis.de.action.LoadOrganisationUnitAction">
+ <action name="index" class="org.hisp.dhis.de.action.PageInitAction">
<interceptor-ref name="organisationUnitTreeStack" />
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-dataentry/select.vm</param>
<param name="menu">/dhis-web-dataentry/menu.vm</param>
<param name="menuTreeHeight">420</param>
<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/form.js,javascript/entry.js</param>
- <param name="stylesheets">style/dhis-web-dataentry.css</param>
+ <param name="stylesheets">style/dhis-web-dataentry.css</param>
</action>
+ <action name="getDataValues" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction">
+ <result name="success" type="velocity-json">/dhis-web-dataentry/responseDataValues.vm</result>
+ </action>
+
<action name="loadDataSets" class="org.hisp.dhis.de.action.LoadDataSetsAction">
<result name="success" type="velocity-json">/dhis-web-dataentry/responseDataSets.vm</result>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-07-13 15:09:37 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-07-14 08:39:01 +0000
@@ -161,12 +161,12 @@
}
}
}
+
+ var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, value, COLOR_GREEN );
+ valueSaver.save();
+
+ updateIndicators(); // Update indicators in case of custom form
}
-
- var valueSaver = new ValueSaver( dataElementId, optionComboId, currentOrganisationUnitId, value, COLOR_GREEN );
- valueSaver.save();
-
- updateIndicators(); // Update indicators in case of custom form
}
function saveBoolean( dataElementId, optionComboId )
=== 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 2011-07-14 06:29:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-07-14 08:39:01 +0000
@@ -1,4 +1,4 @@
-// Identifiers for which zero values are, insignificant, also used in entry.js
+// Identifiers for which zero values are, insignificant, also used in entry.js, populated in select.vm
var significantZeros = [];
// Associative array with [indicator id, expression] for indicators in form, also used in entry.js
@@ -150,7 +150,6 @@
$.getJSON( url, function( json )
{
- significantZeros = json.significantZeros;
indicatorFormulas = json.indicatorFormulas;
addOptionById( 'selectedPeriodIndex', '-1', '[ ' + i18n_select_period + ' ]' );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm 2011-05-20 11:28:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm 2011-07-14 08:39:01 +0000
@@ -9,11 +9,6 @@
"externalId": "$!{period.externalId}"
}#if( $velocityCount < $size1 ),#end
#end ],
-#set( $size2 = $significantZeros.size() )
- "significantZeros": [
-#foreach( $dataElement in $significantZeros )
- ${dataElement.id}#if( $velocityCount < $size2 ),#end
-#end ],
#set( $size3 = $indicators.size() )
"indicatorFormulas": {
#foreach( $indicator in $indicators )
=== 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-07-13 17:49:13 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-07-14 08:39:01 +0000
@@ -17,7 +17,11 @@
var i18n_saving_minmax_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_minmax_failed_error_code" ) , "'")';
var i18n_confirm_complete = '$encoder.jsEscape( $i18n.getString( "confirm_complete" ) , "'")';
var i18n_confirm_undo = '$encoder.jsEscape( $i18n.getString( "confirm_undo" ) , "'")';
- var i18n_no_response_from_server = '$encoder.jsEscape( $i18n.getString( "no_response_from_server" ) , "'")';
+ var i18n_no_response_from_server = '$encoder.jsEscape( $i18n.getString( "no_response_from_server" ) , "'")';
+
+ significantZeros = [
+ #set( $size = $significantZeros.size() )
+ #foreach( $dataElement in $significantZeros )${dataElement.id}#if( $velocityCount < $size ),#end #end ];
</script>
<h3>$i18n.getString( "data_entry" ) #openHelp( "dataEntry" )</h3>