← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3833: Simplification

 

------------------------------------------------------------
revno: 3833
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-06-02 14:50:56 +0200
message:
  Simplification
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.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-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.java	2011-04-19 07:06:57 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.java	2011-06-02 12:50:56 +0000
@@ -64,52 +64,26 @@
 
     public void createCrossTabTable( final Collection<DataElementOperand> operands, String key )
     {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {
-            final StringBuffer sql = new StringBuffer( "CREATE TABLE " + TABLE_PREFIX + key + " ( " );
-            
-            sql.append( "periodid INTEGER NOT NULL, " );
-            sql.append( "sourceid INTEGER NOT NULL, " );
-            
-            for ( DataElementOperand operand : operands )
-            {
-                sql.append( operand.getColumnName() ).append( " VARCHAR(30), " );
-            }
-            
-            sql.append( "PRIMARY KEY ( periodid, sourceid ) );" );
-            
-            holder.getStatement().executeUpdate( sql.toString() );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to create datavalue crosstab table", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        final StringBuffer sql = new StringBuffer( "CREATE TABLE " + TABLE_PREFIX + key + " ( " );
+        
+        sql.append( "periodid INTEGER NOT NULL, " );
+        sql.append( "sourceid INTEGER NOT NULL, " );
+        
+        for ( DataElementOperand operand : operands )
+        {
+            sql.append( operand.getColumnName() ).append( " VARCHAR(30), " );
+        }
+        
+        sql.append( "PRIMARY KEY ( periodid, sourceid ) );" );
+        
+        statementManager.getHolder().executeUpdate( sql.toString() );
     }
     
     public void dropCrossTabTable( String key )
     {
-        final StatementHolder holder = statementManager.getHolder();
+        final String sql = "DROP TABLE IF EXISTS " + TABLE_PREFIX + key;
         
-        try
-        {
-            final String sql = "DROP TABLE IF EXISTS " + TABLE_PREFIX + key;
-            
-            holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to drop datavalue crosstab table", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        statementManager.getHolder().executeUpdate( sql );
     }
         
     // -------------------------------------------------------------------------