dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24977
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12296: Analytics, DataQueryParams, replaced constructor with instance method, easier to override
------------------------------------------------------------
revno: 12296
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-09-29 17:24:12 +0200
message:
Analytics, DataQueryParams, replaced constructor with instance method, easier to override
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/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.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-08-31 18:07:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-09-29 15:24:12 +0000
@@ -134,18 +134,24 @@
public DataQueryParams()
{
}
-
- public DataQueryParams( DataQueryParams params )
+
+ public DataQueryParams instance()
{
- this.dimensions = new ArrayList<DimensionalObject>( params.getDimensions() );
- this.filters = new ArrayList<DimensionalObject>( params.getFilters() );
- this.aggregationType = params.getAggregationType();
- this.measureCriteria = params.getMeasureCriteria();
-
- this.partitions = params.getPartitions();
- this.periodType = params.getPeriodType();
- this.dataPeriodType = params.getDataPeriodType();
- this.skipPartitioning = params.isSkipPartitioning();
+ DataQueryParams params = new DataQueryParams();
+
+ params.dimensions = new ArrayList<DimensionalObject>( this.dimensions );
+ params.filters = new ArrayList<DimensionalObject>( this.filters );
+ params.aggregationType = this.aggregationType;
+ params.measureCriteria = this.measureCriteria;
+ params.skipMeta = this.skipMeta;
+ params.ignoreLimit = this.ignoreLimit;
+
+ params.partitions = this.partitions;
+ params.periodType = this.periodType;
+ params.dataPeriodType = this.dataPeriodType;
+ params.skipPartitioning = this.skipPartitioning;
+
+ return params;
}
// -------------------------------------------------------------------------
@@ -424,7 +430,7 @@
{
int total = 1;
- DataQueryParams query = new DataQueryParams( this );
+ DataQueryParams query = this.instance();
query.getDimensions().add( new BaseDimensionalObject( DATA_X_DIM_ID ) );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-09-28 15:06:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-09-29 15:24:12 +0000
@@ -223,7 +223,7 @@
expressionService.explodeAndSubstituteExpressions( indicators, null );
- DataQueryParams dataSourceParams = new DataQueryParams( params );
+ DataQueryParams dataSourceParams = params.instance();
dataSourceParams.removeDimension( DATAELEMENT_DIM_ID );
dataSourceParams.removeDimension( DATASET_DIM_ID );
@@ -274,7 +274,7 @@
if ( params.getDataElements() != null )
{
- DataQueryParams dataSourceParams = new DataQueryParams( params );
+ DataQueryParams dataSourceParams = params.instance();
dataSourceParams.removeDimension( INDICATOR_DIM_ID );
dataSourceParams.removeDimension( DATASET_DIM_ID );
@@ -298,7 +298,7 @@
// Get complete data set registrations
// -----------------------------------------------------------------
- DataQueryParams dataSourceParams = new DataQueryParams( params );
+ DataQueryParams dataSourceParams = params.instance();
dataSourceParams.removeDimension( INDICATOR_DIM_ID );
dataSourceParams.removeDimension( DATAELEMENT_DIM_ID );
dataSourceParams.setAggregationType( AggregationType.COUNT );
@@ -312,7 +312,7 @@
List<Integer> completenessDimIndexes = dataSourceParams.getCompletenessDimensionIndexes();
List<Integer> completenessFilterIndexes = dataSourceParams.getCompletenessFilterIndexes();
- DataQueryParams targetParams = new DataQueryParams( dataSourceParams );
+ DataQueryParams targetParams = dataSourceParams.instance();
targetParams.setDimensions( ListUtils.getAtIndexes( targetParams.getDimensions(), completenessDimIndexes ) );
targetParams.setFilters( ListUtils.getAtIndexes( targetParams.getFilters(), completenessFilterIndexes ) );
@@ -361,7 +361,7 @@
if ( params.getIndicators() == null && params.getDataElements() == null && params.getDataSets() == null )
{
- Map<String, Double> aggregatedDataMap = getAggregatedDataValueMap( new DataQueryParams( params ) );
+ Map<String, Double> aggregatedDataMap = getAggregatedDataValueMap( params.instance() );
for ( Map.Entry<String, Double> entry : aggregatedDataMap.entrySet() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-09-28 16:27:09 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-09-29 15:24:12 +0000
@@ -198,7 +198,7 @@
// Group queries by partition, period type and organisation unit level
// ---------------------------------------------------------------------
- params = new DataQueryParams( params );
+ params = params.instance();
List<DataQueryParams> queries = new ArrayList<DataQueryParams>();
@@ -307,7 +307,7 @@
if ( dim == null || ( values = dim.getItems() ) == null || values.isEmpty() )
{
- subQueries.add( new DataQueryParams( query ) );
+ subQueries.add( query.instance() );
continue;
}
@@ -315,7 +315,7 @@
for ( List<NameableObject> valuePage : valuePages )
{
- DataQueryParams subQuery = new DataQueryParams( query );
+ DataQueryParams subQuery = query.instance();
subQuery.setDimensionOptions( dim.getDimension(), dim.getType(), dim.getDimensionName(), valuePage );
subQueries.add( subQuery );
}
@@ -354,7 +354,7 @@
for ( Partitions partitions : partitionPeriodMap.keySet() )
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setPeriods( partitionPeriodMap.get( partitions ) );
query.setPartitions( partitions );
queries.add( query );
@@ -362,7 +362,7 @@
}
else if ( params.getFilterPeriods() != null && !params.getFilterPeriods().isEmpty() )
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setPartitions( PartitionUtils.getPartitions( params.getFilterPeriods(), tableName ) );
queries.add( query );
}
@@ -400,7 +400,7 @@
for ( String periodType : periodTypePeriodMap.keySet() )
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setDimensionOptions( PERIOD_DIM_ID, DimensionType.PERIOD, periodType, periodTypePeriodMap.get( periodType ) );
query.setPeriodType( periodType );
queries.add( query );
@@ -451,7 +451,7 @@
for ( Integer level : levelOrgUnitMap.keySet() )
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setDimensionOptions( ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, LEVEL_PREFIX + level, levelOrgUnitMap.get( level ) );
queries.add( query );
}
@@ -473,7 +473,7 @@
}
else
{
- queries.add( new DataQueryParams( params ) );
+ queries.add( params.instance() );
return queries;
}
@@ -511,7 +511,7 @@
if ( params.getAggregationType() != null )
{
- queries.add( new DataQueryParams( params ) );
+ queries.add( params.instance() );
return queries;
}
@@ -523,7 +523,7 @@
for ( AggregationType aggregationType : aggregationTypeDataElementMap.keySet() )
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setDataElements( aggregationTypeDataElementMap.get( aggregationType ) );
query.setAggregationType( aggregationType );
queries.add( query );
@@ -534,7 +534,7 @@
DimensionalObject degs = params.getDataElementGroupSets().get( 0 );
DataElementGroup deg = (DataElementGroup) ( degs.hasItems() ? degs.getItems().get( 0 ) : null );
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
if ( deg != null && !deg.getMembers().isEmpty() )
{
@@ -550,7 +550,7 @@
}
else
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setAggregationType( SUM );
queries.add( query );
}
@@ -573,7 +573,7 @@
if ( params.getDataElements() == null || params.getDataElements().isEmpty() )
{
- queries.add( new DataQueryParams( params ) );
+ queries.add( params.instance() );
return queries;
}
@@ -581,7 +581,7 @@
for ( PeriodType periodType : periodTypeDataElementMap.keySet() )
{
- DataQueryParams query = new DataQueryParams( params );
+ DataQueryParams query = params.instance();
query.setDataElements( periodTypeDataElementMap.get( periodType ) );
query.setDataPeriodType( periodType );
queries.add( query );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java 2013-08-31 18:07:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java 2013-09-29 15:24:12 +0000
@@ -221,7 +221,7 @@
paramsA.setOrganisationUnits( ousA );
paramsA.setPeriods( pesA );
- DataQueryParams paramsB = new DataQueryParams( paramsA );
+ DataQueryParams paramsB = paramsA.instance();
paramsB.setOrganisationUnits( ousB );
paramsB.setPeriods( pesB );