← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2816: Impl method for creating and dropping index on table aggregateddatasetcompleteness

 

------------------------------------------------------------
revno: 2816
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-02-03 21:42:05 +0100
message:
  Impl method for creating and dropping index on table aggregateddatasetcompleteness
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.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-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java	2011-02-03 20:15:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java	2011-02-03 20:42:05 +0000
@@ -114,4 +114,14 @@
      */
     DataSetCompletenessConfiguration getConfiguration()
         throws NoConfigurationFoundException;
+    
+    /**
+     * Creates an index on the aggregateddatasetcompleteness table.
+     */
+    void createIndex();
+
+    /**
+     * Drops the index on the aggregateddatasetcompleteness table.
+     */
+    void dropIndex();
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java	2010-08-27 07:07:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessStore.java	2011-02-03 20:42:05 +0000
@@ -71,4 +71,8 @@
     int getRegistrations( DataSet dataSet, Collection<? extends Source> children, Period period, Date deadline );
     
     int getNumberOfValues( DataSet dataSet, Collection<? extends Source> children, Period period, Date deadline );
+    
+    void createIndex();
+    
+    void dropIndex();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2011-02-03 20:31:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2011-02-03 20:42:05 +0000
@@ -300,7 +300,7 @@
             }
             catch ( Exception ex )
             {
-                log.debug( "Index already exists" );
+                log.debug( "Index does not exist" );
             }
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java	2011-02-03 20:15:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java	2011-02-03 20:42:05 +0000
@@ -366,4 +366,18 @@
             return null;
         }
     }
+    
+    // -------------------------------------------------------------------------
+    // Index
+    // -------------------------------------------------------------------------
+
+    public void createIndex()
+    {
+        completenessStore.createIndex();
+    }
+    
+    public void dropIndex()
+    {
+        completenessStore.dropIndex();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java	2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java	2011-02-03 20:42:05 +0000
@@ -33,6 +33,8 @@
 import java.util.Date;
 
 import org.amplecode.quick.StatementManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.completeness.DataSetCompletenessStore;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.period.Period;
@@ -48,6 +50,8 @@
 public class JDBCDataSetCompletenessStore
     implements DataSetCompletenessStore
 {
+    private static final Log log = LogFactory.getLog( JDBCDataSetCompletenessStore.class );
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -132,5 +136,31 @@
             "AND sourceid IN (" + childrenIds + ")";
 
         return statementManager.getHolder().queryForInteger( sql );
+    }    
+
+    public void createIndex()
+    {
+        try
+        {
+            final String sql = "CREATE INDEX aggregateddatasetcompleteness_index ON aggregateddatasetcompleteness (datasetid, periodid, organisationunitid)";        
+            statementManager.getHolder().executeUpdate( sql );
+        }
+        catch ( Exception ex )
+        {
+            log.debug( "Index already exists" );
+        }
+    }
+    
+    public void dropIndex()
+    {
+        try
+        {
+            final String sql = "DROP INDEX aggregateddatasetcompleteness_index";        
+            statementManager.getHolder().executeUpdate( sql );
+        }
+        catch ( Exception ex )
+        {
+            log.debug( "Index does not exist" );
+        }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java	2011-02-01 18:55:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java	2011-02-03 20:42:05 +0000
@@ -138,6 +138,9 @@
             aggregatedDataValueService.dropIndex( true, true );
             aggregatedDataValueService.createIndex( true, true );
             
+            completenessStore.dropIndex();
+            completenessStore.createIndex(); //TODO respect layering
+            
             log.info( "Rebuilt data mart indexes" );
         }