dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25600
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12749: Event analytics, using Partitions object instead of plain string
------------------------------------------------------------
revno: 12749
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-16 20:47:07 +0200
message:
Event analytics, using Partitions object instead of plain string
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.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
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.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/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-10-04 12:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-10-16 18:47:07 +0000
@@ -180,7 +180,7 @@
params.hierarchyMeta = this.hierarchyMeta;
params.ignoreLimit = this.ignoreLimit;
- params.partitions = this.partitions;
+ params.partitions = new Partitions( this.partitions );
params.periodType = this.periodType;
params.dataPeriodType = this.dataPeriodType;
params.skipPartitioning = this.skipPartitioning;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java 2013-09-01 18:00:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/Partitions.java 2013-10-16 18:47:07 +0000
@@ -50,6 +50,11 @@
{
this.partitions = partitions;
}
+
+ public Partitions( Partitions partitions )
+ {
+ this.partitions = partitions != null ? new ArrayList<String>( partitions.getPartitions() ) : new ArrayList<String>();
+ }
// -------------------------------------------------------------------------
// Logic
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2013-10-14 20:58:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2013-10-16 18:47:07 +0000
@@ -35,6 +35,7 @@
import java.util.Set;
import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.analytics.Partitions;
import org.hisp.dhis.analytics.SortOrder;
import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.NameableObject;
@@ -70,9 +71,7 @@
private List<String> desc = new ArrayList<String>();
private String organisationUnitMode;
-
- private String tableName;
-
+
private Integer page;
private Integer pageSize;
@@ -104,7 +103,7 @@
params.filters = new ArrayList<DimensionalObject>( this.filters );
params.aggregationType = this.aggregationType;
- params.partitions = this.partitions;
+ params.partitions = new Partitions( this.partitions );
params.periodType = this.periodType;
params.program = this.program;
@@ -116,7 +115,6 @@
params.asc = new ArrayList<String>( this.asc );
params.desc = new ArrayList<String>( this.desc );
params.organisationUnitMode = this.organisationUnitMode;
- params.tableName = this.tableName;
params.page = this.page;
params.pageSize = this.pageSize;
params.sortOrder = this.sortOrder;
@@ -304,16 +302,6 @@
this.organisationUnitMode = organisationUnitMode;
}
- public String getTableName()
- {
- return tableName;
- }
-
- public void setTableName( String tableName )
- {
- this.tableName = tableName;
- }
-
public Integer getPage()
{
return page;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-10-14 20:58:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-10-16 18:47:07 +0000
@@ -132,7 +132,8 @@
//TODO order the event analytics tables up front to avoid default sorting in queries
//TODO filter items support
- //TODO remove org unit name / code columns and use names / codes from meta data
+
+ //TODO proper query when start/end period or period filter span multiple partitions
public Grid getAggregatedEventData( EventQueryParams params )
{
@@ -159,7 +160,7 @@
// ---------------------------------------------------------------------
// Data
// ---------------------------------------------------------------------
-
+
List<EventQueryParams> queries = queryPlanner.planQuery( params );
for ( EventQueryParams query : queries )
=== 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 2013-09-29 21:05:46 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2013-10-16 18:47:07 +0000
@@ -38,6 +38,7 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.analytics.DataQueryParams;
import org.hisp.dhis.analytics.IllegalQueryException;
+import org.hisp.dhis.analytics.Partitions;
import org.hisp.dhis.analytics.QueryPlanner;
import org.hisp.dhis.analytics.event.EventQueryParams;
import org.hisp.dhis.analytics.event.EventQueryPlanner;
@@ -163,8 +164,10 @@
else
{
//TODO implement properly
+
Period period = (Period) params.getDimensionOrFilter( PERIOD_DIM_ID ).get( 0 );
- params.setTableName( TABLE_BASE_NAME + year( period.getStartDate() ) + "_" + program.getUid() );
+ String tableName = TABLE_BASE_NAME + year( period.getStartDate() ) + "_" + program.getUid();
+ params.setPartitions( new Partitions().add( tableName ) );
params.setPeriodType( period.getPeriodType().getName() );
list.add( params );
}
@@ -177,7 +180,8 @@
EventQueryParams query = params.instance();
query.setStartDate( startDate );
query.setEndDate( endDate );
- query.setTableName( TABLE_BASE_NAME + year( startDate ) + "_" + program.getUid() );
+ String tableName = TABLE_BASE_NAME + year( startDate ) + "_" + program.getUid();
+ query.setPartitions( new Partitions().add( tableName ) );
return query;
}
=== 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 2013-10-14 20:58:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2013-10-16 18:47:07 +0000
@@ -313,7 +313,7 @@
{
String sql = "";
- sql += "from " + params.getTableName() + " ";
+ sql += "from " + params.getPartitions().getSinglePartition() + " ";
if ( params.hasStartEndDate() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java 2013-09-29 15:41:22 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java 2013-10-16 18:47:07 +0000
@@ -88,9 +88,9 @@
assertEquals( new Cal( 2012, 1, 1 ).time(), queries.get( 2 ).getStartDate() );
assertEquals( new Cal( 2012, 3, 20 ).time(), queries.get( 2 ).getEndDate() );
- assertEquals( "analytics_event_2010_programuidA", queries.get( 0 ).getTableName() );
- assertEquals( "analytics_event_2011_programuidA", queries.get( 1 ).getTableName() );
- assertEquals( "analytics_event_2012_programuidA", queries.get( 2 ).getTableName() );
+ assertEquals( "analytics_event_2010_programuidA", queries.get( 0 ).getPartitions().getSinglePartition() );
+ assertEquals( "analytics_event_2011_programuidA", queries.get( 1 ).getPartitions().getSinglePartition() );
+ assertEquals( "analytics_event_2012_programuidA", queries.get( 2 ).getPartitions().getSinglePartition() );
}
@Test
@@ -109,7 +109,7 @@
assertEquals( new Cal( 2010, 3, 1 ).time(), queries.get( 0 ).getStartDate() );
assertEquals( new Cal( 2010, 9, 20 ).time(), queries.get( 0 ).getEndDate() );
- assertEquals( "analytics_event_2010_programuidA", queries.get( 0 ).getTableName() );
+ assertEquals( "analytics_event_2010_programuidA", queries.get( 0 ).getPartitions().getSinglePartition() );
}
@Test