← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10247: Analytics, using statement builder for portable SQL

 

------------------------------------------------------------
revno: 10247
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-15 12:28:58 +0100
message:
  Analytics, using statement builder for portable SQL
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.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/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2013-03-15 11:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2013-03-15 11:28:58 +0000
@@ -69,8 +69,6 @@
     // Implementation
     // -------------------------------------------------------------------------
     
-    //TODO use statement builder for double column type
-    
     public boolean validState()
     {
         return jdbcTemplate.queryForRowSet( "select dataelementid from datavalue limit 1" ).next();
@@ -83,6 +81,8 @@
         
     public void createTable( String tableName )
     {
+        final String dbl = statementBuilder.getDoubleColumnType();
+        
         final String sqlDrop = "drop table " + tableName;
         
         executeSilently( sqlDrop );
@@ -94,7 +94,7 @@
             sqlCreate += col[0] + " " + col[1] + ",";
         }
         
-        sqlCreate += "daysxvalue double precision, daysno integer not null, value double precision)";
+        sqlCreate += "daysxvalue " + dbl + ", daysno integer not null, value " + dbl + ")";
         
         log.info( "Create SQL: " + sqlCreate );
         
@@ -104,6 +104,8 @@
     @Async
     public Future<?> populateTableAsync( ConcurrentLinkedQueue<String> tables )
     {
+        final String dbl = statementBuilder.getDoubleColumnType();
+        
         taskLoop : while ( true )
         {
             String table = tables.poll();
@@ -120,7 +122,7 @@
             
             String intClause = "dv.value != '' and dv.value != 'true' and dv.value != 'false' and dv.value not like '%-%'";
             
-            populateTable( table, startDate, endDate, "cast(dv.value as double precision)", "int", intClause );
+            populateTable( table, startDate, endDate, "cast(dv.value as " + dbl + ")", "int", intClause );
             
             populateTable( table, startDate, endDate, "1" , "bool", "dv.value = 'true'" );
     

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2012-10-29 11:18:39 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java	2013-03-15 11:28:58 +0000
@@ -38,7 +38,7 @@
     @Override
     public String getDoubleColumnType()
     {
-        return "DOUBLE";
+        return "double";
     }
 
     @Override

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2012-12-22 18:09:46 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2013-03-15 11:28:58 +0000
@@ -38,7 +38,7 @@
     @Override
     public String getDoubleColumnType()
     {
-        return "DECIMAL";
+        return "decimal";
     }
 
     @Override

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2012-10-29 11:18:39 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2013-03-15 11:28:58 +0000
@@ -38,7 +38,7 @@
     @Override
     public String getDoubleColumnType()
     {
-        return "DOUBLE PRECISION";
+        return "double precision";
     }
 
     @Override