← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18445: Analyitcs tables, extra validation

 

------------------------------------------------------------
revno: 18445
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-02-27 12:50:10 +0100
message:
  Analyitcs tables, extra validation
modified:
  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/JdbcAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.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-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-02-24 23:41:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2015-02-27 11:50:10 +0000
@@ -286,12 +286,14 @@
      * @throws IllegalStateException if not valid.
      */
     protected void validateDimensionColumns( List<String[]> dimensions )
-    {
+    {        
         if ( dimensions == null || dimensions.isEmpty() )
         {
             throw new IllegalStateException( "Analytics table dimensions are empty" );
         }
         
+        dimensions = new ArrayList<>( dimensions );
+        
         List<String> columns = new ArrayList<>();
         
         for ( String[] dimension : dimensions )

=== 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-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2015-02-27 11:50:10 +0000
@@ -115,13 +115,13 @@
         final String sqlDrop = "drop table " + tableName;
         
         executeSilently( sqlDrop );
-        
+
         String sqlCreate = "create table " + tableName + " (";
 
         List<String[]> columns = getDimensionColumns( table );
         
         validateDimensionColumns( columns );
-        
+
         for ( String[] col : columns )
         {
             sqlCreate += col[0] + " " + col[1] + ",";
@@ -187,17 +187,21 @@
         final String start = DateUtils.getMediumDateString( table.getPeriod().getStartDate() );
         final String end = DateUtils.getMediumDateString( table.getPeriod().getEndDate() );
         final String tableName = table.getTempTableName();
-        
+
         String sql = "insert into " + table.getTempTableName() + " (";
+
+        List<String[]> columns = getDimensionColumns( table );
         
-        for ( String[] col : getDimensionColumns( table ) )
+        validateDimensionColumns( columns );
+
+        for ( String[] col : columns )
         {
             sql += col[0] + ",";
         }
         
         sql += "daysxvalue, daysno, value, textvalue) select ";
         
-        for ( String[] col : getDimensionColumns( table ) )
+        for ( String[] col : columns )
         {
             sql += col[2] + ",";
         }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java	2015-02-27 08:35:35 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java	2015-02-27 11:50:10 +0000
@@ -75,13 +75,13 @@
         final String sqlDrop = "drop table " + tableName;
         
         executeSilently( sqlDrop );
-        
+
         String sqlCreate = "create table " + tableName + " (";
 
         List<String[]> columns = getDimensionColumns( table );
         
         validateDimensionColumns( columns );
-        
+
         for ( String[] col : columns )
         {
             sqlCreate += col[0] + " " + col[1] + ",";
@@ -114,10 +114,14 @@
             final String start = DateUtils.getMediumDateString( table.getPeriod().getStartDate() );
             final String end = DateUtils.getMediumDateString( table.getPeriod().getEndDate() );
             final String tableName = table.getTempTableName();
-        
+
             String insert = "insert into " + table.getTempTableName() + " (";
+
+            List<String[]> columns = getDimensionColumns( table );
             
-            for ( String[] col : getDimensionColumns( table ) )
+            validateDimensionColumns( columns );
+
+            for ( String[] col : columns )
             {
                 insert += col[0] + ",";
             }
@@ -126,7 +130,7 @@
             
             String select = "select ";
             
-            for ( String[] col : getDimensionColumns( table ) )
+            for ( String[] col : columns )
             {
                 select += col[2] + ",";
             }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java	2015-01-23 17:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java	2015-02-27 11:50:10 +0000
@@ -119,17 +119,21 @@
             }
 
             final String tableName = table.getTempTableName();
+
+            String sql = "insert into " + table.getTempTableName() + " (";
+
+            List<String[]> columns = getDimensionColumns( table );
             
-            String sql = "insert into " + table.getTempTableName() + " (";
-    
-            for ( String[] col : getDimensionColumns( table ) )
+            validateDimensionColumns( columns );
+
+            for ( String[] col : columns )
             {
                 sql += col[0] + ",";
             }
     
             sql += "value) select ";
     
-            for ( String[] col : getDimensionColumns( table ) )
+            for ( String[] col : columns )
             {
                 sql += col[2] + ",";
             }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2015-02-27 08:35:35 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2015-02-27 11:50:10 +0000
@@ -181,14 +181,18 @@
 
             String sql = "insert into " + table.getTempTableName() + " (";
 
-            for ( String[] col : getDimensionColumns( table ) )
+            List<String[]> columns = getDimensionColumns( table );
+            
+            validateDimensionColumns( columns );
+
+            for ( String[] col : columns )
             {
                 sql += col[0] + ",";
             }
 
             sql = removeLast( sql, 1 ) + ") select ";
 
-            for ( String[] col : getDimensionColumns( table ) )
+            for ( String[] col : columns )
             {
                 sql += col[2] + ",";
             }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java	2015-01-23 17:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java	2015-02-27 11:50:10 +0000
@@ -87,7 +87,7 @@
         List<String[]> columns = getDimensionColumns( table );
         
         validateDimensionColumns( columns );
-        
+
         for ( String[] col : columns )
         {
             sqlCreate += col[0] + " " + col[1] + ",";
@@ -118,17 +118,21 @@
             }
 
             final String tableName = table.getTempTableName();
-            
+
             String sql = "insert into " + table.getTempTableName() + " (";
     
-            for ( String[] col : getDimensionColumns( table ) )
+            List<String[]> columns = getDimensionColumns( table );
+            
+            validateDimensionColumns( columns );
+            
+            for ( String[] col : columns )
             {
                 sql += col[0] + ",";
             }
     
             sql += "value) select ";
     
-            for ( String[] col : getDimensionColumns( table ) )
+            for ( String[] col : columns )
             {
                 sql += col[2] + ",";
             }