← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4977: Data mart, fixed issue with db connections

 

------------------------------------------------------------
revno: 4977
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-10-18 22:48:23 +0200
message:
  Data mart, fixed issue with db connections
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java
  dhis-2/dhis-services/dhis-service-datamart-default/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-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java	2011-09-11 09:37:07 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java	2011-10-18 20:48:23 +0000
@@ -38,6 +38,7 @@
 
 import org.amplecode.quick.BatchHandler;
 import org.amplecode.quick.BatchHandlerFactory;
+import org.amplecode.quick.StatementManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.aggregation.AggregatedDataValue;
@@ -130,6 +131,13 @@
         this.averageBoolAggregator = averageBooleanDataElementAggregator;
     }
     
+    private StatementManager statementManager;
+
+    public void setStatementManager( StatementManager statementManager )
+    {
+        this.statementManager = statementManager;
+    }
+
     // -------------------------------------------------------------------------
     // DataMart functionality
     // -------------------------------------------------------------------------
@@ -138,6 +146,8 @@
     public Future<?> exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods, 
         Collection<OrganisationUnit> organisationUnits, DataElementOperandList operandList, String key )
     {
+        statementManager.initialise(); // Running in separate thread
+        
         final BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
         
         final BatchHandler<Object> cacheHandler = inMemoryBatchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).setTableName( AGGREGATEDDATA_CACHE_PREFIX + key ).init();
@@ -203,6 +213,8 @@
         
         cacheHandler.flush();
 
+        statementManager.destroy();
+        
         log.info( "Data element export task done" );
         
         return null;

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-09-11 09:37:07 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-10-18 20:48:23 +0000
@@ -39,6 +39,7 @@
 
 import org.amplecode.quick.BatchHandler;
 import org.amplecode.quick.BatchHandlerFactory;
+import org.amplecode.quick.StatementManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
@@ -114,7 +115,14 @@
     {
         this.batchHandlerFactory = batchHandlerFactory;
     }
-    
+
+    private StatementManager statementManager;
+
+    public void setStatementManager( StatementManager statementManager )
+    {
+        this.statementManager = statementManager;
+    }
+
     // -------------------------------------------------------------------------
     // IndicatorDataMart implementation
     // -------------------------------------------------------------------------
@@ -123,6 +131,8 @@
     public Future<?> exportIndicatorValues( final Collection<Indicator> indicators, final Collection<Period> periods, 
         final Collection<OrganisationUnit> organisationUnits, final Collection<DataElementOperand> operands, String key )
     {
+        statementManager.initialise(); // Running in separate thread
+        
         final BatchHandler<AggregatedIndicatorValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedIndicatorValueBatchHandler.class ).init();
 
         final boolean omitZeroNumerator = (Boolean) systemSettingManager.getSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, false );
@@ -185,6 +195,8 @@
         
         batchHandler.flush();
         
+        statementManager.destroy();
+        
         log.info( "Indicator export task done" );
         
         return null;

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2011-08-02 10:55:30 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2011-10-18 20:48:23 +0000
@@ -101,6 +101,7 @@
     <property name="averageIntSingleValueAggregator" ref="org.hisp.dhis.datamart.aggregation.dataelement.AverageIntSingleValueAggregator" />
     <property name="sumBoolAggregator" ref="org.hisp.dhis.datamart.aggregation.dataelement.SumBoolAggregator" />
     <property name="averageBoolAggregator" ref="org.hisp.dhis.datamart.aggregation.dataelement.AverageBoolAggregator" />
+	<property name="statementManager" ref="inMemoryStatementManager" />
   </bean>
   
   <!-- IndicatorDataMart -->
@@ -112,6 +113,7 @@
     <property name="crossTabService" ref="org.hisp.dhis.datamart.crosstab.CrossTabService" />
 	<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
     <property name="batchHandlerFactory" ref="batchHandlerFactory" />
+	<property name="statementManager" ref="inMemoryStatementManager" />
   </bean>
     
   <!-- DeletionHandler -->