← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17509: Data entry. Splitting out data set associations from meta-data response. Should allow for paralle...

 

------------------------------------------------------------
revno: 17509
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-17 18:24:22 +0100
message:
  Data entry. Splitting out data set associations from meta-data response. Should allow for parallell download of content and less chance of time-out.
added:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataSetAssociationsAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSetAssociations.vm
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.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/responseMetaData.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
=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataSetAssociationsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataSetAssociationsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataSetAssociationsAction.java	2014-11-17 17:24:22 +0000
@@ -0,0 +1,61 @@
+package org.hisp.dhis.de.action;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hisp.dhis.configuration.ConfigurationService;
+import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetDataSetAssociationsAction
+    implements Action
+{
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+    
+    @Autowired
+    private ConfigurationService configurationService;
+
+    private List<Set<String>> dataSetAssociationSets;
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    public List<Set<String>> getDataSetAssociationSets()
+    {
+        return dataSetAssociationSets;
+    }
+
+    private Map<String, Integer> organisationUnitAssociationSetMap;
+
+    public Map<String, Integer> getOrganisationUnitAssociationSetMap()
+    {
+        return organisationUnitAssociationSetMap;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        OrganisationUnitLevel offlineOrgUnitLevel = configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
+
+        Integer level = offlineOrgUnitLevel != null ? offlineOrgUnitLevel.getLevel() : null;
+
+        OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet( level );
+
+        dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets();
+
+        organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap();
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-10-18 07:31:50 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-11-17 17:24:22 +0000
@@ -50,9 +50,6 @@
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -97,13 +94,6 @@
         this.dataSetService = dataSetService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
     private DataElementCategoryService categoryService;
 
     public void setCategoryService( DataElementCategoryService categoryService )
@@ -241,16 +231,6 @@
 
         expressionService.substituteExpressions( indicators, null );
 
-        OrganisationUnitLevel offlineOrgUnitLevel = configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
-
-        Integer level = offlineOrgUnitLevel != null ? offlineOrgUnitLevel.getLevel() : null;
-
-        OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet( level );
-
-        dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets();
-
-        organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap();
-
         if ( currentUserService.currentUserIsSuper() )
         {
             dataSets = new ArrayList<>( dataSetService.getAllDataSets() );

=== 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	2014-05-18 00:49:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2014-11-17 17:24:22 +0000
@@ -6,19 +6,18 @@
 
   <bean id="org.hisp.dhis.de.action.PageInitAction" class="org.hisp.dhis.de.action.PageInitAction" scope="prototype" />
 
-  <bean id="org.hisp.dhis.de.action.GetMetaDataAction" class="org.hisp.dhis.de.action.GetMetaDataAction"
-      scope="prototype">
+  <bean id="org.hisp.dhis.de.action.GetMetaDataAction" class="org.hisp.dhis.de.action.GetMetaDataAction" scope="prototype">
     <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
   </bean>
 
-  <bean id="org.hisp.dhis.de.action.GetDataValuesForDataSetAction"
-      class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" scope="prototype">
+  <bean id="org.hisp.dhis.de.action.GetDataSetAssociationsAction" class="org.hisp.dhis.de.action.GetDataSetAssociationsAction" scope="prototype"/>
+
+  <bean id="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" scope="prototype">
     <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
     <property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
@@ -33,16 +32,14 @@
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
   </bean>
 
-  <bean id="org.hisp.dhis.de.action.SaveMinMaxLimitsAction" class="org.hisp.dhis.de.action.SaveMinMaxLimitsAction"
-      scope="prototype">
+  <bean id="org.hisp.dhis.de.action.SaveMinMaxLimitsAction" class="org.hisp.dhis.de.action.SaveMinMaxLimitsAction" scope="prototype">
     <property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
   </bean>
 
-  <bean id="org.hisp.dhis.de.action.RemoveMinMaxLimitsAction" class="org.hisp.dhis.de.action.RemoveMinMaxLimitsAction"
-      scope="prototype">
+  <bean id="org.hisp.dhis.de.action.RemoveMinMaxLimitsAction" class="org.hisp.dhis.de.action.RemoveMinMaxLimitsAction" scope="prototype">
     <property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
@@ -59,8 +56,7 @@
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
   </bean>
 
-  <bean id="org.hisp.dhis.de.action.ValidationAction" class="org.hisp.dhis.de.action.ValidationAction"
-      scope="prototype">
+  <bean id="org.hisp.dhis.de.action.ValidationAction" class="org.hisp.dhis.de.action.ValidationAction" scope="prototype">
     <property name="validationRuleService" ref="org.hisp.dhis.validation.ValidationRuleService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="minMaxOutlierAnalysisService" ref="org.hisp.dhis.dataanalysis.MinMaxOutlierAnalysisService" />

=== 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	2014-09-02 19:37:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2014-11-17 17:24:22 +0000
@@ -21,6 +21,10 @@
     <action name="getMetaData" class="org.hisp.dhis.de.action.GetMetaDataAction">
       <result name="success" type="velocity-json">/dhis-web-dataentry/responseMetaData.vm</result>
     </action>
+    
+    <action name="getDataSetAssociations" class="org.hisp.dhis.de.action.GetDataSetAssociationsAction">
+      <result name="success" type="velocity-json">/dhis-web-dataentry/responseDataSetAssociations.vm</result>
+    </action>
 
     <action name="getDataValues" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction">
       <result name="success" type="velocity-json">/dhis-web-dataentry/responseDataValues.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	2014-11-17 16:35:57 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-17 17:24:22 +0000
@@ -84,6 +84,8 @@
 dhis2.de.cst.formulaPattern = /#\{.+?\}/g;
 dhis2.de.cst.separator = '.';
 dhis2.de.cst.valueMaxLength = 50000;
+dhis2.de.cst.metaData = 'dhis2.de.cst.metaData';
+dhis2.de.cst.dataSetAssociations = 'dhis2.de.cst.dataSetAssociations';
 
 // Colors
 
@@ -172,7 +174,10 @@
     $( '#orgUnitTree' ).one( 'ouwtLoaded', function()
     {
         console.log( 'Ouwt loaded' );
-        dhis2.de.loadMetaData();
+        
+        $.when( dhis2.de.loadMetaData(), dhis2.de.loadDataSetAssociations() ).done( function() {
+        	dhis2.de.setMetaDataLoaded();
+        } );
     } );
 
     $( document ).bind( 'dhis2.online', function( event, loggedIn )
@@ -252,41 +257,67 @@
 
 dhis2.de.loadMetaData = function()
 {
-    var KEY_METADATA = 'metadata';
-
+	var def = $.Deferred();
+	
     $.ajax( {
     	url: 'getMetaData.action',
     	dataType: 'json',
     	success: function( json )
 	    {
-	        sessionStorage[KEY_METADATA] = JSON.stringify( json.metaData );
+	        sessionStorage[dhis2.de.cst.metaData] = JSON.stringify( json.metaData );
 	    },
 	    complete: function()
 	    {
-	        var metaData = JSON.parse( sessionStorage[KEY_METADATA] );
-
+	        var metaData = JSON.parse( sessionStorage[dhis2.de.cst.metaData] );
 	        dhis2.de.emptyOrganisationUnits = metaData.emptyOrganisationUnits;
 	        dhis2.de.significantZeros = metaData.significantZeros;
 	        dhis2.de.dataElements = metaData.dataElements;
 	        dhis2.de.indicatorFormulas = metaData.indicatorFormulas;
 	        dhis2.de.dataSets = metaData.dataSets;
 	        dhis2.de.optionSets = metaData.optionSets;
-	        dhis2.de.dataSetAssociationSets = metaData.dataSetAssociationSets;
-	        dhis2.de.organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;
 	        dhis2.de.defaultCategoryCombo = metaData.defaultCategoryCombo;
 	        dhis2.de.categoryCombos = metaData.categoryCombos;
-	        dhis2.de.categories = metaData.categories;
-
-	        dhis2.de.metaDataIsLoaded = true;
-	        selection.responseReceived(); // Notify that meta data is loaded
-	        $( '#loaderSpan' ).hide();
-	        console.log( 'Meta-data loaded' );
-
-	        updateForms();
+	        dhis2.de.categories = metaData.categories;	        
+	        def.resolve();
 	    }
 	} );
+    
+    return def.promise();
 };
 
+dhis2.de.loadDataSetAssociations = function()
+{
+	var def = $.Deferred();
+	
+	$.ajax( {
+    	url: 'getDataSetAssociations.action',
+    	dataType: 'json',
+    	success: function( json )
+	    {
+	        sessionStorage[dhis2.de.cst.dataSetAssociations] = JSON.stringify( json.dataSetAssociations );
+	    },
+	    complete: function()
+	    {
+	        var metaData = JSON.parse( sessionStorage[dhis2.de.cst.dataSetAssociations] );
+	        dhis2.de.dataSetAssociationSets = metaData.dataSetAssociationSets;
+	        dhis2.de.organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;	        
+	        def.resolve();
+	    }
+	} );
+	
+	return def.promise();
+}
+
+dhis2.de.setMetaDataLoaded = function()
+{
+    dhis2.de.metaDataIsLoaded = true;
+    selection.responseReceived(); // Notify that meta data is loaded
+    $( '#loaderSpan' ).hide();
+    console.log( 'Meta-data loaded' );
+
+    updateForms();
+}
+
 dhis2.de.discardLocalData = function() {
     if( confirm( i18n_remove_local_data ) ) {
         dhis2.de.storageManager.clearAllDataValues();

=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSetAssociations.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSetAssociations.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSetAssociations.vm	2014-11-17 17:24:22 +0000
@@ -0,0 +1,19 @@
+{ "dataSetAssociations": {
+"dataSetAssociationSets": {
+#set( $size1 = $dataSetAssociationSets.size() )
+#set( $index = 0 )
+#foreach( $associationSet in $dataSetAssociationSets )
+"${index}": [
+#set( $index = $index + 1 )
+#set( $size2 = $associationSet.size() )
+#foreach( $id in $associationSet )
+"$encoder.jsonEncode( $id )"#if( $velocityCount < $size2 ),#end
+#end ]#if( $velocityCount < $size1 ),#end
+#end },
+
+"organisationUnitAssociationSetMap": {
+#set( $size = $organisationUnitAssociationSetMap.size() )
+#foreach( $orgUnit in $organisationUnitAssociationSetMap.keySet() )
+"${orgUnit}":"$organisationUnitAssociationSetMap.get( ${orgUnit} )"#if( $velocityCount < $size ),#end
+#end }
+} }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2014-11-17 16:35:57 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2014-11-17 17:24:22 +0000
@@ -40,24 +40,6 @@
 "validCompleteOnly":${dataSet.validCompleteOnly},"skipOffline":${dataSet.skipOffline}, "renderAsTabs":${dataSet.renderAsTabs}, "renderHorizontally":${dataSet.renderHorizontally}}#if( $velocityCount < $size ),#end
 #end },
 
-"dataSetAssociationSets": {
-#set( $size1 = $dataSetAssociationSets.size() )
-#set( $index = 0 )
-#foreach( $associationSet in $dataSetAssociationSets )
-"${index}": [
-#set( $index = $index + 1 )
-#set( $size2 = $associationSet.size() )
-#foreach( $id in $associationSet )
-"$encoder.jsonEncode( $id )"#if( $velocityCount < $size2 ),#end
-#end ]#if( $velocityCount < $size1 ),#end
-#end },
-
-"organisationUnitAssociationSetMap": {
-#set( $size = $organisationUnitAssociationSetMap.size() )
-#foreach( $orgUnit in $organisationUnitAssociationSetMap.keySet() )
-"${orgUnit}":"$organisationUnitAssociationSetMap.get( ${orgUnit} )"#if( $velocityCount < $size ),#end
-#end },
-
 "defaultCategoryCombo":"${defaultCategoryCombo.uid}",
 
 "categoryCombos": {