← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14911: Event analytics. Using PartitionManager.

 

------------------------------------------------------------
revno: 14911
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-04-19 12:55:51 +0200
message:
  Event analytics. Using PartitionManager.
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.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/event/EventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java	2014-04-19 08:06:02 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java	2014-04-19 10:55:51 +0000
@@ -28,10 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Set;
-
 import org.hisp.dhis.common.Grid;
-import org.hisp.dhis.program.Program;
 
 /**
  * @author Lars Helge Overland
@@ -43,6 +40,4 @@
     Grid getEvents( EventQueryParams params, Grid grid );
     
     int getEventCount( EventQueryParams params );
-    
-    public Set<String> getAnalyticsTables( Program program );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2014-04-19 08:06:02 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2014-04-19 10:55:51 +0000
@@ -40,6 +40,7 @@
 import org.hisp.dhis.analytics.event.EventAnalyticsService;
 import org.hisp.dhis.analytics.event.EventQueryParams;
 import org.hisp.dhis.analytics.event.EventQueryPlanner;
+import org.hisp.dhis.analytics.partition.PartitionManager;
 import org.hisp.dhis.analytics.table.PartitionUtils;
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.IllegalQueryException;
@@ -67,6 +68,9 @@
     
     @Autowired
     private OrganisationUnitService organisationUnitService;
+    
+    @Autowired
+    private PartitionManager partitionManager;
 
     // -------------------------------------------------------------------------
     // EventQueryPlanner implementation
@@ -124,7 +128,7 @@
     @Override
     public List<EventQueryParams> planAggregateQuery( EventQueryParams params )
     {
-        Set<String> validPartitions = analyticsManager.getAnalyticsTables( params.getProgram() );
+        Set<String> validPartitions = partitionManager.getEventAnalyticsPartitions();
 
         List<EventQueryParams> queries = new ArrayList<EventQueryParams>();
         
@@ -146,7 +150,7 @@
     @Override
     public EventQueryParams planEventQuery( EventQueryParams params )
     {
-        Set<String> validPartitions = analyticsManager.getAnalyticsTables( params.getProgram() );
+        Set<String> validPartitions = partitionManager.getEventAnalyticsPartitions();
 
         String tableSuffix = "_" + params.getProgram().getUid();
         

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-04-19 08:06:02 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-04-19 10:55:51 +0000
@@ -28,7 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.analytics.AnalyticsTableManager.EVENT_ANALYTICS_TABLE_NAME;
 import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID;
 import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
 import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
@@ -39,9 +38,7 @@
 import static org.hisp.dhis.system.util.TextUtils.trimEnd;
 
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -56,7 +53,6 @@
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.program.Program;
 import org.hisp.dhis.system.util.Timer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.BadSqlGrammarException;
@@ -298,19 +294,7 @@
         
         return count;
     }
-    
-    public Set<String> getAnalyticsTables( Program program )
-    {
-        final String sql = 
-            "select table_name from information_schema.tables " +
-            "where table_name like '" + EVENT_ANALYTICS_TABLE_NAME + "_%_" + program.getUid().toLowerCase() + "' " +
-            "and table_type = 'BASE TABLE'";
-        
-        log.info( "Information schema SQL: " + sql );
-        
-        return new HashSet<String>( jdbcTemplate.queryForList( sql, String.class ) );
-    }
-    
+        
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------