← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1600: Impl method reportTableIsGenerated

 

------------------------------------------------------------
revno: 1600
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-03-09 16:40:42 +0100
message:
  Impl method reportTableIsGenerated
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
  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/jdbc/JDBCReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.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/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2009-12-11 08:01:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2010-03-09 15:40:42 +0000
@@ -158,4 +158,12 @@
      * @return a ReportTableData object.
      */
     ReportTableData getReportTableData( int id, I18nFormat format );
+
+    /**
+     * Tests whether the report table has been generated in the database.
+     * 
+     * @param id the ReportTable id.
+     * @return true if the report table has been generated, false it not.
+     */
+    boolean reportTableIsGenerated( int id );
 }

=== 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	2009-12-11 08:01:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2010-03-09 15:40:42 +0000
@@ -529,6 +529,11 @@
         return reportTableManager.getDisplayReportTableData( reportTable );
     }
     
+    public boolean reportTableIsGenerated( int id )
+    {
+        return reportTableManager.reportTableIsGenerated( getReportTable( id ) );
+    }
+    
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2009-12-10 10:03:53 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2010-03-09 15:40:42 +0000
@@ -132,6 +132,20 @@
         }
     }
     
+    public boolean reportTableIsGenerated( ReportTable reportTable )
+    {
+        try
+        {
+            statementManager.getHolder().getStatement().executeQuery( "SELECT count(*) FROM " + reportTable.getTableName() );
+            
+            return true;
+        }
+        catch ( Exception ex )
+        {
+            return false;
+        }
+    }
+    
     public Map<String, Double> getAggregatedValueMap( ReportTable reportTable,
         IdentifiableObject metaObject, DataElementCategoryOptionCombo categoryOptionCombo, Period period, OrganisationUnit unit )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java	2009-10-06 00:20:18 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/ReportTableManager.java	2010-03-09 15:40:42 +0000
@@ -59,6 +59,14 @@
     void removeReportTable( ReportTable reportTable );
     
     /**
+     * Tests whether the report table has been generated in the database.
+     * 
+     * @param reportTable the ReportTable.
+     * @return true if the report table has been generated, false it not.
+     */
+    boolean reportTableIsGenerated( ReportTable reportTable );
+    
+    /**
      * Returns an AggregatedValueMap.
      * 
      * @param reportTable the ReportTable.