dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21358
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10081: Analytics, simplification
------------------------------------------------------------
revno: 10081
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-08 15:51:55 +0100
message:
Analytics, simplification
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/DefaultQueryPlanner.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-03-08 13:39:50 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-03-08 14:51:55 +0000
@@ -74,7 +74,7 @@
public static final int MAX_DIM_OPT_PERM = 5000;
- private static final List<DimensionType> COMPLETENESS_DIMENSION_TYTPES = Arrays.asList( DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
+ private static final List<DimensionType> COMPLETENESS_DIMENSION_TYPES = Arrays.asList( DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
private static final DimensionItem[] DIM_OPT_ARR = new DimensionItem[0];
private static final DimensionItem[][] DIM_OPT_2D_ARR = new DimensionItem[0][];
@@ -83,6 +83,8 @@
private List<Dimension> filters = new ArrayList<Dimension>();
+ private ListMap<String, Dimension> filterMap = new ListMap<String, Dimension>();
+
private AggregationType aggregationType;
private Map<MeasureFilter, Double> measureCriteria = new HashMap<MeasureFilter, Double>();
@@ -188,7 +190,7 @@
for ( int i = 0; i < dimensions.size(); i++ )
{
- if ( COMPLETENESS_DIMENSION_TYTPES.contains( dimensions.get( i ).getType() ) )
+ if ( COMPLETENESS_DIMENSION_TYPES.contains( dimensions.get( i ).getType() ) )
{
indexes.add( i );
}
@@ -206,7 +208,7 @@
for ( int i = 0; i < filters.size(); i++ )
{
- if ( COMPLETENESS_DIMENSION_TYTPES.contains( filters.get( i ).getType() ) )
+ if ( COMPLETENESS_DIMENSION_TYPES.contains( filters.get( i ).getType() ) )
{
indexes.add( i );
}
@@ -707,6 +709,16 @@
this.filters = filters;
}
+ public ListMap<String, Dimension> getFilterMap()
+ {
+ return filterMap;
+ }
+
+ public void setFilterMap( ListMap<String, Dimension> filterMap )
+ {
+ this.filterMap = filterMap;
+ }
+
public AggregationType getAggregationType()
{
return aggregationType;
@@ -780,18 +792,6 @@
return getDimensionOptions( key ) != null ? getDimensionOptions( key ) : getFilterOptions( key );
}
- public void resetDimensionOrFilter( Dimension dimension, List<IdentifiableObject> options )
- {
- if ( dimensions.contains( dimension ) )
- {
- setDimensionOptions( dimension.getDimension(), dimension.getType(), dimension.getDimensionName(), options );
- }
- else if ( filters.contains( dimension ) )
- {
- setFilterOptions( dimension.getDimension(), dimension.getType(), dimension.getDimensionName(), options );
- }
- }
-
public boolean hasDimensionOrFilter( String key )
{
return dimensions.indexOf( new Dimension( key ) ) != -1 || filters.indexOf( new Dimension( key ) ) != -1;
=== 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-03-08 13:39:50 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-03-08 14:51:55 +0000
@@ -192,7 +192,7 @@
// Group by data element
// ---------------------------------------------------------------------
- queries = splitByDimensionOrFilter( queries, DataQueryParams.DATAELEMENT_DIM_ID, optimalQueries );
+ queries = splitByDimension( queries, DataQueryParams.DATAELEMENT_DIM_ID, optimalQueries );
if ( queries.size() >= optimalQueries )
{
@@ -203,7 +203,7 @@
// Group by organisation unit
// ---------------------------------------------------------------------
- queries = splitByDimensionOrFilter( queries, DataQueryParams.ORGUNIT_DIM_ID, optimalQueries );
+ queries = splitByDimension( queries, DataQueryParams.ORGUNIT_DIM_ID, optimalQueries );
return queries;
}
@@ -220,7 +220,7 @@
/**
* Splits the given list of queries in sub queries on the given dimension.
*/
- private List<DataQueryParams> splitByDimensionOrFilter( List<DataQueryParams> queries, String dimension, int optimalQueries )
+ private List<DataQueryParams> splitByDimension( List<DataQueryParams> queries, String dimension, int optimalQueries )
{
int optimalForSubQuery = MathUtils.divideToFloor( optimalQueries, queries.size() );
@@ -228,28 +228,32 @@
for ( DataQueryParams query : queries )
{
- List<IdentifiableObject> values = query.getDimensionOrFilter( dimension );
-
- if ( values == null || values.isEmpty() )
+ Dimension dim = query.getDimension( dimension );
+
+ List<IdentifiableObject> values = null;
+
+ if ( dim == null || ( values = dim.getItems() ) == null || values.isEmpty() )
{
subQueries.add( new DataQueryParams( query ) );
continue;
}
- Dimension dim = query.getDimension( dimension );
-
List<List<IdentifiableObject>> valuePages = new PaginatedList<IdentifiableObject>( values ).setNumberOfPages( optimalForSubQuery ).getPages();
for ( List<IdentifiableObject> valuePage : valuePages )
{
DataQueryParams subQuery = new DataQueryParams( query );
- subQuery.resetDimensionOrFilter( dim, valuePage );
+ subQuery.setDimensionOptions( dim.getDimension(), dim.getType(), dim.getDimensionName(), valuePage );
subQueries.add( subQuery );
}
}
return subQueries;
}
+
+ // -------------------------------------------------------------------------
+ // Supportive - group by methods
+ // -------------------------------------------------------------------------
/**
* Groups the given query into sub queries based on its periods and which
@@ -456,6 +460,10 @@
return queries;
}
+
+ // -------------------------------------------------------------------------
+ // Supportive - get mapping methods
+ // -------------------------------------------------------------------------
/**
* Creates a mapping between period type name and period for the given periods.