← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2888: Fixed annoying bug with data browser. Sorry about the code style.Need to figure out how to do thi...

 

------------------------------------------------------------
revno: 2888
committer: Jason P. Pickering <jason.p.pickering@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-02-21 16:56:14 +0200
message:
  Fixed annoying bug with data browser. Sorry about the code style.Need to figure out how to do this in NetBeans.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserTable.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.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/databrowser/DataBrowserTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserTable.java	2011-02-20 04:54:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/databrowser/DataBrowserTable.java	2011-02-21 14:56:14 +0000
@@ -66,6 +66,7 @@
      * has results from.
      */
     private int queryCount = 0;
+    private Integer numResults = 0;
 
     /**
      * 
@@ -322,6 +323,14 @@
     {
         this.counts = counts;
     }
+    public void setNumResults(Integer numResults)
+    {
+        this.numResults = numResults;
+    }
+    public Integer getNumResults()
+    {
+        return numResults;
+    }
 
     public List<MetaValue> getColumns()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java	2011-02-20 04:54:44 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/DefaultDataBrowserService.java	2011-02-21 14:56:14 +0000
@@ -165,27 +165,23 @@
 
         DataBrowserTable table = new DataBrowserTable();
 
-        dataBrowserStore.setDataElementGroupStructureForOrgUnitGroupBetweenPeriods( table, orgUnitGroupId,
-            betweenPeriodIds );
+        dataBrowserStore.setDataElementGroupStructureForOrgUnitGroupBetweenPeriods( table, orgUnitGroupId, betweenPeriodIds );
 
-        dataBrowserStore.setCountDataElementGroupsForOrgUnitGroupBetweenPeriods( table, orgUnitGroupId,
-            betweenPeriodIds );
+        dataBrowserStore.setCountDataElementGroupsForOrgUnitGroupBetweenPeriods( table, orgUnitGroupId, betweenPeriodIds );
 
         return table;
     }
 
-    public DataBrowserTable getCountDataElementsForOrgUnitInPeriod( Integer orgUnitGroupId, String startDate,
-        String endDate, PeriodType periodType, I18nFormat format )
+    public DataBrowserTable getCountDataElementsForOrgUnitInPeriod( Integer orgUnitId, String startDate,
+            String endDate, PeriodType periodType, I18nFormat format )
     {
         DataBrowserTable table = new DataBrowserTable();
 
-        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType,
-            format );
-
-        dataBrowserStore.setDataElementStructureForOrgUnitBetweenPeriods( table, orgUnitGroupId, betweenPeriodIds );
-
-        dataBrowserStore.setCountDataElementsForOrgUnitBetweenPeriods( table, orgUnitGroupId,
-            betweenPeriodIds );
+        List<Integer> betweenPeriodIds = getAllPeriodIdsBetweenDatesOnPeriodType( startDate, endDate, periodType, format );
+
+        dataBrowserStore.setDataElementStructureForOrgUnitBetweenPeriods( table, orgUnitId, betweenPeriodIds );
+
+        dataBrowserStore.setCountDataElementsForOrgUnitBetweenPeriods( table, orgUnitId, betweenPeriodIds );
 
 
         return table;

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java	2011-02-20 04:54:44 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/jdbc/StatementManagerDataBrowserStore.java	2011-02-21 14:56:14 +0000
@@ -251,8 +251,8 @@
 			table.addQueryTime(timer.getMilliSec());
 
 			table.incrementQueryCount();
-
 			numResults = table.addColumnToAllRows( resultSet, true );
+                        
 		} catch (SQLException e) {
 			throw new RuntimeException("Failed to get aggregated data value\n"
 					+ sqlsb.toString(), e);
@@ -287,7 +287,8 @@
 					: " UNION ");
 		}
 
-		return setCountFromSQL(table, sqlsb.toString());
+                Integer numResults = setCountFromSQL(table, sqlsb.toString());
+		return numResults;
 	}
 
 	public Integer setCountDataElementGroupsForOrgUnitGroupBetweenPeriods(
@@ -314,8 +315,8 @@
 			sqlsb.append(i == betweenPeriodIds.size() ? "ORDER BY ColumnHeader"
 					: " UNION ");
 		}
-
-		return setCountFromSQL(table, sqlsb.toString());
+                Integer numResults = setCountFromSQL(table, sqlsb.toString());
+		return numResults;
 	}
 
 	public Integer setCountOrgUnitsBetweenPeriods(DataBrowserTable table,
@@ -356,7 +357,6 @@
 		} finally {
 			holder.close();
 		}
-
 		return numResults;
 	}
 
@@ -484,7 +484,7 @@
 		Timer timer = new Timer();
 		timer.start();
 		try {
-			log.debug("getTableFromSQL: " + sqlsb.toString());
+
 			ResultSet resultSet = getScrollableResult(sqlsb.toString(), holder);
 			table.setQueryTime(timer.getMilliSec());
 			table.incrementQueryCount();
@@ -512,7 +512,7 @@
 		Timer timer = new Timer();
 		timer.start();
 		try {
-			log.debug("setTableStructure: " + sqlsb.toString());
+
 			ResultSet resultSet = getScrollableResult(sqlsb.toString(), holder);
 			table.setQueryTime(timer.getMilliSec());
 			table.incrementQueryCount();
@@ -549,7 +549,6 @@
 		try {
 			Timer timer = new Timer();
 			timer.start();
-			log.debug("setCountFromSQL: " + sql);
 			ResultSet resultSet = getScrollableResult(sql, holder);
 			table.addQueryTime(timer.getMilliSec());
 
@@ -563,6 +562,7 @@
 			holder.close();
 		}
 
+                table.setNumResults(numResults);
 		return numResults;
 	}
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java	2011-02-18 15:29:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/databrowser/SearchAction.java	2011-02-21 14:56:14 +0000
@@ -162,6 +162,12 @@
         return dataBrowserTable.getQueryCount();
     }
 
+    public Integer getNumResults()
+    {
+        return dataBrowserTable.getNumResults();
+
+    }
+
     public List<MetaValue> getAllColumns()
     {
         return dataBrowserTable.getColumns();
@@ -516,6 +522,7 @@
 
         requestTime = System.currentTimeMillis() - before;
 
+
         // Convert column date names
         convertColumnNames( dataBrowserTable );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm	2011-02-18 12:26:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserResult.vm	2011-02-21 14:56:14 +0000
@@ -21,6 +21,7 @@
 			$i18n.getString( "request_returned_in" ): ${requestTime} $i18n.getString( "ms" ). 
 			$i18n.getString( "query_took" ): ${queryTime} $i18n.getString( "ms" ). 
 			$i18n.getString( "number_of_queries_executed" ): ${queryCount}.
+                        $i18n.getString( "Number of results" ): ${numResults}.
 		</span>
 	</div>
 	
@@ -143,7 +144,7 @@
 	#end
 	</p>
 	
-#if ( $allCounts.isEmpty() )
+#if ( $allCounts.isEmpty()  || $numResults == "0" )
 	<br/><br/>
 	$i18n.getString( "no_data_found" )
 #else