← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2931: Fixed issue with caching in orgunit distribution report. Added proper in-progress feedback.

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 2931 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-02-28 16:46:58 +0100
message:
  Fixed issue with caching in orgunit distribution report. Added proper in-progress feedback.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java	2011-01-26 11:36:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GridHeader.java	2011-02-28 15:46:58 +0000
@@ -1,5 +1,8 @@
 package org.hisp.dhis.common;
 
+import java.util.Arrays;
+import java.util.List;
+
 /*
  * Copyright (c) 2004-2010, University of Oslo
  * All rights reserved.
@@ -32,6 +35,8 @@
  */
 public class GridHeader
 {
+    private static final List<String> NUMERIC_TYPES = Arrays.asList( Float.class.getName(), Double.class.getName(), Long.class.getName(), Integer.class.getName() );
+    
     private String name;
     
     private String column;
@@ -78,6 +83,11 @@
         this.meta = meta;
     }
 
+    public boolean isNumeric()
+    {
+        return type != null && NUMERIC_TYPES.contains( type );
+    }
+    
     public String getName()
     {
         return name;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-02-23 23:39:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-02-28 15:46:58 +0000
@@ -91,6 +91,8 @@
         executeSql( "ALTER TABLE reporttable DROP column dimensiontype" );
         executeSql( "ALTER TABLE reporttable DROP column tablename" );
         executeSql( "ALTER TABLE reporttable DROP column existingtablename" );
+        executeSql( "ALTER TABLE reporttable DROP column docategoryoptioncombos" );
+        executeSql( "ALTER TABLE reporttable DROP column mode" );
         executeSql( "ALTER TABLE categoryoptioncombo DROP COLUMN displayorder" );
         executeSql( "ALTER TABLE dataelementcategoryoption DROP COLUMN shortname" );
         executeSql( "ALTER TABLE section DROP COLUMN label" );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java	2011-02-23 14:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/orgunitdistribution/impl/DefaultOrgUnitDistributionService.java	2011-02-28 02:42:12 +0000
@@ -91,7 +91,7 @@
     public JFreeChart getOrganisationUnitDistributionChart( OrganisationUnitGroupSet groupSet, OrganisationUnit organisationUnit )
     {
         Map<String, Double> categoryValues = new HashMap<String, Double>();
-                
+        
         Grid grid = getOrganisationUnitDistribution( groupSet, organisationUnit, true );
         
         Assert.isTrue( grid != null && grid.getHeight() == 1 );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-02-23 23:39:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-02-28 15:46:58 +0000
@@ -433,7 +433,7 @@
         }
         
         // ---------------------------------------------------------------------
-        // Sort first and then limit
+        // Sort and limit
         // ---------------------------------------------------------------------
 
         if ( reportTable.sortOrder() != ReportTable.NONE )
@@ -445,7 +445,7 @@
         {
             grid.limitGrid( reportTable.topLimit() );
         }
-                
+        
         return grid;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java	2011-02-25 04:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java	2011-02-28 02:43:24 +0000
@@ -1,7 +1,5 @@
 package org.hisp.dhis.web.api.resources;
 
-import java.net.URI;
-
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java	2011-02-25 18:08:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java	2011-02-28 02:43:24 +0000
@@ -1,8 +1,6 @@
 package org.hisp.dhis.web.api.resources;
 
 import java.net.URI;
-import java.util.Collection;
-import java.util.List;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -11,12 +9,9 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 
-import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.importexport.dxf2.model.DataSetLinks;
-import org.hisp.dhis.importexport.dxf2.model.Link;
-import org.hisp.dhis.importexport.dxf2.model.OrgUnitLinks;
 import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
 import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
 import org.hisp.dhis.web.api.UrlResourceListener;
@@ -31,7 +26,7 @@
     private DataSetService dataSetService;
 
     @Context
-    UriInfo uriInfo;
+    private UriInfo uriInfo;
 
     @GET
     @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-01-25 09:06:55 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-02-28 02:42:12 +0000
@@ -1250,6 +1250,19 @@
 	window.location.href = 'exportToPdf.action?type=' + type + activeIds;
 }
 
+/**
+ * Displays the div with the first argument id, and hides the divs with ids  in 
+ * the second array argument, except the id given in the first argument. 
+ */
+function displayDiv( divId, divIds ) {
+	$( "#" + divId ).show();
+	for ( i in divIds ) {
+		if ( divIds[i] != divId ) {
+			$( "#" + divIds[i] ).hide();
+		}
+	}
+}
+
 function isNumber( value )
 {
 	var regex = /^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-02-27 22:34:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-02-28 02:42:12 +0000
@@ -323,4 +323,4 @@
 none = None
 ascending = Low to high
 descending = High to low
-top_limit = Top limit
+top_limit = Top limit
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js	2010-12-26 23:25:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js	2011-02-28 02:42:12 +0000
@@ -1,6 +1,8 @@
 
 var selectedOrganisationUnit = null;
 
+var distributionDivs = ["chartDiv","tableDiv","loaderDiv"];
+
 function organisationUnitSelected( units ) {
 	if ( units && units[0] ) {	
 		selectedOrganisationUnit = units[0];
@@ -15,11 +17,14 @@
 		return false;
 	}
 	
-	$( "#chartDiv" ).hide();
-	$( "#tableDiv" ).show();	
+	displayDiv( "loaderDiv", distributionDivs );
+	
 	var groupSetId = $( "#groupSetId" ).val();
-	var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=html";
-	$( "#tableDiv" ).load( url, pageInit );
+	var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=html&r=" + getRandomNumber();
+	$( "#tableDiv" ).load( url, function() {
+		displayDiv( "tableDiv", distributionDivs );
+		pageInit();
+	} );
 }
 
 function getOrgUnitDistribution( type ) {	
@@ -28,7 +33,7 @@
 	}
 	
 	var groupSetId = $( "#groupSetId" ).val();
-	var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=" + type;
+	var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=" + type + "&r=" + getRandomNumber();
 	window.location.href = url;
 }
 
@@ -37,11 +42,10 @@
 		return false;
 	}
 	
-	$( "#tableDiv" ).hide();
-	$( "#chartDiv" ).show();
+	displayDiv( "chartDiv", distributionDivs );
+	$( "#chartImg" ).attr( "src", "../images/ajax-loader-circle.gif" );
 	var groupSetId = $( "#groupSetId" ).val();
-	var random = getRandomNumber();
-	var source = "getOrgUnitDistributionChart.action?groupSetId=" + groupSetId + "&r=" + random;
+	var source = "getOrgUnitDistributionChart.action?groupSetId=" + groupSetId + "&r=" + getRandomNumber();
 	$( "#chartImg" ).attr( "src", source );
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm	2011-01-24 19:40:35 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewOrgUnitDistribution.vm	2011-02-28 02:42:12 +0000
@@ -46,6 +46,8 @@
 var i18n_select_org_unit = '$encoder.jsEscape( $i18n.getString( "please_select_org_unit" ) , "'")';
 </script>
 
+#parse( "dhis-web-commons/loader/loader.vm" )
+
 <!-- Table -->
 
 <div id="tableDiv"></div>