← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18933: Analytics tables, generating approval resource table as part of table generations step, not resou...

 

------------------------------------------------------------
revno: 18933
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-04-17 09:41:39 +0200
message:
  Analytics tables, generating approval resource table as part of table generations step, not resource table step.
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml


--
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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java	2015-01-23 17:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java	2015-04-17 07:41:39 +0000
@@ -74,7 +74,12 @@
      * Returns the temporary table name.
      */
     String getTempTableName();
-        
+    
+    /**
+     * Performs work before tables are being created.
+     */
+    void preCreateTables();
+    
     /**
      * Attempts to drop and then create analytics table.
      * 

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2015-03-20 14:25:50 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2015-04-17 07:41:39 +0000
@@ -49,6 +49,7 @@
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
+import org.hisp.dhis.resourcetable.ResourceTableService;
 import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.timer.SystemTimer;
 import org.hisp.dhis.system.timer.Timer;
@@ -85,6 +86,9 @@
     
     @Autowired
     protected DataApprovalLevelService dataApprovalLevelService;
+    
+    @Autowired
+    protected ResourceTableService resourceTableService;
    
     @Autowired
     protected StatementBuilder statementBuilder;
@@ -109,6 +113,14 @@
      */
     protected abstract List<String[]> getDimensionColumns( AnalyticsTable table );
     
+    /**
+     * Override to perform work before tables are being generated.
+     */
+    @Override
+    public void preCreateTables()
+    {
+    }
+    
     // -------------------------------------------------------------------------
     // Implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2015-04-16 21:17:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2015-04-17 07:41:39 +0000
@@ -112,8 +112,13 @@
         final List<AnalyticsTable> tables = tableManager.getTables( earliest );
         final String tableName = tableManager.getTableName();
         
-        clock.logTime( "Table update start: " + tableName + ", partitions: " + tables + ", last years: " + lastYears + ", earliest: " + earliest );        
-        notifier.notify( taskId, "Creating analytics tables, processes: " + processNo + ", org unit levels: " + orgUnitLevelNo );
+        clock.logTime( "Table update start: " + tableName + ", partitions: " + tables + ", last years: " + lastYears + ", earliest: " + earliest );
+        notifier.notify( taskId, "Performing pre-create table work, processes: " + processNo + ", org unit levels: " + orgUnitLevelNo );
+        
+        tableManager.preCreateTables();
+        
+        clock.logTime( "Performed pre-create table work" );
+        notifier.notify( taskId, "Creating analytics tables" );
         
         createTables( tables );
         
@@ -179,11 +184,6 @@
         resourceTableService.generateDatePeriodTable();
         resourceTableService.generateDataElementCategoryOptionComboTable();
         
-        if ( systemSettingManager.hideUnapprovedDataInAnalytics() )
-        {
-            resourceTableService.generateDataApprovalMinLevelTable();
-        }
-        
         resourceTableService.createAllSqlViews();
     }
     

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2015-04-16 21:17:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2015-04-17 07:41:39 +0000
@@ -105,6 +105,15 @@
     {
         return ANALYTICS_TABLE_NAME;
     }
+
+    @Override
+    public void preCreateTables()
+    {
+        if ( isApprovalEnabled() )
+        {
+            resourceTableService.generateDataApprovalMinLevelTable();
+        }        
+    }
     
     @Override
     public void createTable( AnalyticsTable table )

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml	2015-02-27 13:42:52 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml	2015-04-17 07:41:39 +0000
@@ -14,8 +14,6 @@
   
   <bean id="org.hisp.dhis.analytics.EventAnalyticsTableManager" class="org.hisp.dhis.analytics.table.JdbcEventAnalyticsTableManager" />
   
-  <bean id="org.hisp.dhis.analytics.partition.PartitionManager" class="org.hisp.dhis.analytics.partition.JdbcPartitionManager" />
-  
   <bean id="org.hisp.dhis.analytics.AnalyticsTableService" class="org.hisp.dhis.analytics.table.DefaultAnalyticsTableService">
     <property name="tableManager" ref="org.hisp.dhis.analytics.AnalyticsTableManager" />
   </bean>
@@ -36,6 +34,8 @@
     <property name="tableManager" ref="org.hisp.dhis.analytics.EventAnalyticsTableManager" />
   </bean>
   
+  <bean id="org.hisp.dhis.analytics.partition.PartitionManager" class="org.hisp.dhis.analytics.partition.JdbcPartitionManager" />
+    
   <!-- Routine analytics -->
   
   <bean id="org.hisp.dhis.analytics.AnalyticsManager" class="org.hisp.dhis.analytics.data.JdbcAnalyticsManager" />