← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17534: Data entry, introduced validation caching on meta data response

 

------------------------------------------------------------
revno: 17534
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-19 13:17:41 +0100
message:
  Data entry, introduced validation caching on meta data response
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/webapp/dhis-web-dataentry/javascript/form.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-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-11-19 11:16:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-11-19 12:17:41 +0000
@@ -31,12 +31,15 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.dataelement.DataElement;
@@ -50,8 +53,11 @@
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.option.OptionSet;
+import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
@@ -111,6 +117,9 @@
     @Autowired
     private ConfigurationService configurationService;
 
+    @Autowired
+    private IdentifiableObjectManager identifiableObjectManager;
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -192,8 +201,21 @@
     @Override
     public String execute()
     {
-        //TODO 403
+        Date lastUpdated = DateUtils.max( 
+            identifiableObjectManager.getLastUpdated( DataElement.class ), 
+            identifiableObjectManager.getLastUpdated( OptionSet.class ),
+            identifiableObjectManager.getLastUpdated( Indicator.class ),
+            identifiableObjectManager.getLastUpdated( DataSet.class ),
+            identifiableObjectManager.getLastUpdated( DataElementCategoryCombo.class ),
+            identifiableObjectManager.getLastUpdated( DataElementCategory.class ),
+            identifiableObjectManager.getLastUpdated( DataElementCategoryOption.class ));
+        String tag = lastUpdated != null ? DateUtils.LONG_DATE_FORMAT.format( lastUpdated ) : null;
         
+        if ( ContextUtils.isNotModified( ServletActionContext.getRequest(), ServletActionContext.getResponse(), tag ) )
+        {
+            return SUCCESS;
+        }
+                
         User user = currentUserService.getCurrentUser();
 
         if ( user != null && user.getOrganisationUnits().isEmpty() )

=== 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-18 14:45:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-19 12:17:41 +0000
@@ -263,6 +263,7 @@
     $.ajax( {
     	url: 'getMetaData.action',
     	dataType: 'json',
+    	cache: true,
     	success: function( json )
 	    {
 	        sessionStorage[dhis2.de.cst.metaData] = JSON.stringify( json.metaData );