← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8845: Added caching for get geojson facilities request in gis

 

------------------------------------------------------------
revno: 8845
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-11-03 22:38:41 +0300
message:
  Added caching for get geojson facilities request in gis
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.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/common/IdentifiableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java	2012-06-25 18:40:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java	2012-11-03 19:38:41 +0000
@@ -114,7 +114,7 @@
         {
             for ( IdentifiableObject object : objects )
             {
-                if ( object != null && object.getLastUpdated() != null && (latest == null || object.getLastUpdated().after( latest )) )
+                if ( object != null && object.getLastUpdated() != null && ( latest == null || object.getLastUpdated().after( latest ) ) )
                 {
                     latest = object.getLastUpdated();
                 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java	2012-11-01 16:45:28 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java	2012-11-03 19:38:41 +0000
@@ -27,11 +27,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.util.ContextUtils.clearIfNotModified;
+
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
+import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -109,6 +115,30 @@
     public String execute()
         throws Exception
     {
+        groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
+
+        // ---------------------------------------------------------------------
+        // Check if modified for caching purposes
+        // ---------------------------------------------------------------------
+
+        Set<OrganisationUnitGroup> groups = new HashSet<OrganisationUnitGroup>();
+        
+        for ( OrganisationUnitGroupSet groupSet : groupSets )
+        {
+            groups.addAll( groupSet.getOrganisationUnitGroups() );
+        }
+        
+        boolean modified = !clearIfNotModified( ServletActionContext.getRequest(), ServletActionContext.getResponse(), groups );
+        
+        if ( !modified )
+        {
+            return SUCCESS;
+        }
+
+        // ---------------------------------------------------------------------
+        // Retrieve list of organisation units and populate group names
+        // ---------------------------------------------------------------------
+
         OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentId );
 
         if ( parent == null )
@@ -133,8 +163,6 @@
 
         FilterUtils.filter( organisationUnits, new OrganisationUnitWithValidCoordinatesFilter() );
 
-        groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
-
         object = new ArrayList<OrganisationUnit>();
 
         for ( OrganisationUnit unit : organisationUnits )