← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 766: Simplifed jdbc related code in DataMartStore.

 

------------------------------------------------------------
revno: 766
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-09-30 22:26:58 +0200
message:
  Simplifed jdbc related code in DataMartStore.
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/jdbc/JdbcDataMartStore.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/category/action/UpdateSortedDataElementGroupOrderAction.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/jdbc/JdbcDataMartStore.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/jdbc/JdbcDataMartStore.java	2009-09-14 19:02:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/jdbc/JdbcDataMartStore.java	2009-09-30 20:26:58 +0000
@@ -177,46 +177,18 @@
     public int deleteAggregatedDataValues( final Collection<Integer> dataElementIds, 
         final Collection<Integer> periodIds, final Collection<Integer> organisationUnitIds )
     {
-        final StatementHolder holder = statementManager.getHolder();
+        final String sql =
+            "DELETE FROM aggregateddatavalue " +
+            "WHERE dataelementid IN ( " + getCommaDelimitedString( dataElementIds ) + " ) " +
+            "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
+            "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " )";
         
-        try
-        {
-            final String sql =
-                "DELETE FROM aggregateddatavalue " +
-                "WHERE dataelementid IN ( " + getCommaDelimitedString( dataElementIds ) + " ) " +
-                "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
-                "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " )";
-            
-            return holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to delete aggregated data values", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        return statementManager.getHolder().executeUpdate( sql );        
     }
 
     public int deleteAggregatedDataValues()
     {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {
-            final String sql = "DELETE FROM aggregateddatavalue";
-            
-            return holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to delete aggregated data values", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        return statementManager.getHolder().executeUpdate( "DELETE FROM aggregateddatavalue" ); 
     }
 
     // -------------------------------------------------------------------------
@@ -312,46 +284,18 @@
     public int deleteAggregatedIndicatorValues( final Collection<Integer> indicatorIds, final Collection<Integer> periodIds,
         final Collection<Integer> organisationUnitIds )
     {
-        final StatementHolder holder = statementManager.getHolder();
+        final String sql =
+            "DELETE FROM aggregatedindicatorvalue " +
+            "WHERE indicatorid IN ( " + getCommaDelimitedString( indicatorIds ) + " ) " +
+            "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
+            "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " )";
         
-        try
-        {
-            final String sql =
-                "DELETE FROM aggregatedindicatorvalue " +
-                "WHERE indicatorid IN ( " + getCommaDelimitedString( indicatorIds ) + " ) " +
-                "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
-                "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " )";
-            
-            return holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to delete aggregated data values", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        return statementManager.getHolder().executeUpdate( sql );        
     }
     
     public int deleteAggregatedIndicatorValues()
     {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {
-            final String sql = "DELETE FROM aggregatedindicatorvalue";
-            
-            return holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to delete aggregated indicator values", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        return statementManager.getHolder().executeUpdate( "DELETE FROM aggregatedindicatorvalue" );
     }
 
     // -------------------------------------------------------------------------
@@ -597,22 +541,7 @@
 
     public int deleteRelativePeriods()
     {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        try
-        {
-            final String sql = statementBuilder.getDeleteRelativePeriods();
-            
-            return holder.getStatement().executeUpdate( sql );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to delete relative periods", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        return statementManager.getHolder().executeUpdate( statementBuilder.getDeleteRelativePeriods() );
     }
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java	2009-06-10 22:26:49 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java	2009-09-30 20:26:58 +0000
@@ -147,6 +147,9 @@
         }
     }
 
+    /**
+     * Binds a Hibernate Session to the current thread.
+     */
     private void bindSession()
     {        
         SessionFactory sessionFactory = (SessionFactory) getBean( "sessionFactory" );
@@ -156,6 +159,9 @@
         TransactionSynchronizationManager.bindResource( sessionFactory, new SessionHolder( session ) );     
     }
 
+    /**
+     * Unbinds and closes the bound Hibernate Session from the current thread.
+     */
     private void unbindSession()
     {
         SessionFactory sessionFactory = (SessionFactory) getBean( "sessionFactory" );

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java	2009-09-14 16:00:37 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/StreamActionSupport.java	2009-09-30 20:26:58 +0000
@@ -1,5 +1,32 @@
 package org.hisp.dhis.util;
 
+/*
+ * Copyright (c) 2004-2007, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 import java.io.OutputStream;
 
 import javax.servlet.http.HttpServletResponse;
@@ -9,6 +36,10 @@
 
 import com.opensymphony.xwork2.ActionSupport;
 
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
 public abstract class StreamActionSupport
     extends ActionSupport
 {

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/category/action/UpdateSortedDataElementGroupOrderAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/category/action/UpdateSortedDataElementGroupOrderAction.java	2009-09-18 07:09:19 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/category/action/UpdateSortedDataElementGroupOrderAction.java	2009-09-30 20:26:58 +0000
@@ -30,7 +30,6 @@
 import java.util.List;
 
 import org.hisp.dhis.reportexcel.DataElementGroupOrder;
-import org.hisp.dhis.reportexcel.ReportExcel;
 import org.hisp.dhis.reportexcel.ReportExcelCategory;
 import org.hisp.dhis.reportexcel.ReportExcelService;