dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21095
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9897: Analytics, validation
------------------------------------------------------------
revno: 9897
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-02-25 14:58:25 +0100
message:
Analytics, validation
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
--
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-02-25 12:37:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-02-25 13:58:25 +0000
@@ -34,9 +34,11 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.common.CombinationGenerator;
@@ -301,11 +303,11 @@
* Returns the dimensions which are part of dimensions and filters. If any
* such dimensions exist this object is in an illegal state.
*/
- public Collection<Dimension> dimensionsAsFilters()
+ public Collection<Dimension> getDimensionsAsFilters()
{
return CollectionUtils.intersection( dimensions, filters );
}
-
+
/**
* Indicates whether periods are present as a dimension or as a filter. If
* not this object is in an illegal state.
@@ -334,6 +336,25 @@
}
/**
+ * Returns a list of dimensions which occur more than once.
+ */
+ public List<Dimension> getDuplicateDimensions()
+ {
+ Set<Dimension> dims = new HashSet<Dimension>();
+ List<Dimension> duplicates = new ArrayList<Dimension>();
+
+ for ( Dimension dim : dimensions )
+ {
+ if ( !dims.add( dim ) )
+ {
+ duplicates.add( dim );
+ }
+ }
+
+ return duplicates;
+ }
+
+ /**
* Returns a mapping between identifier and period type for all data sets
* in this query.
*/
@@ -807,6 +828,11 @@
}
}
+ public boolean hasDimensionOrFilter( String key )
+ {
+ return dimensions.indexOf( new Dimension( key ) ) != -1 || filters.indexOf( new Dimension( key ) ) != -1;
+ }
+
// -------------------------------------------------------------------------
// Get and set helpers for dimensions
// -------------------------------------------------------------------------
@@ -873,6 +899,8 @@
}
}
+ //TODO filters?
+
return list;
}
=== 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-02-25 12:37:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-02-25 13:58:25 +0000
@@ -110,7 +110,6 @@
//TODO completeness on time
//TODO make sure data x dims are successive
- //TODO max value limit, 5000?
@Autowired
private AnalyticsManager analyticsManager;
=== 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-02-25 12:37:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-02-25 13:58:25 +0000
@@ -81,9 +81,9 @@
throw new IllegalQueryException( "At least one dimension must be specified" );
}
- if ( !params.dimensionsAsFilters().isEmpty() )
+ if ( !params.getDimensionsAsFilters().isEmpty() )
{
- throw new IllegalQueryException( "Dimensions cannot be specified as dimension and filter simultaneously: " + params.dimensionsAsFilters() );
+ throw new IllegalQueryException( "Dimensions cannot be specified as dimension and filter simultaneously: " + params.getDimensionsAsFilters() );
}
if ( !params.hasPeriods() && !params.isSkipPartitioning() )
@@ -106,7 +106,15 @@
throw new IllegalQueryException( "Table exceeds max number of cells: " + MAX_DIM_OPT_PERM );
}
- //TODO check if any dimension occur more than once
+ if ( !params.getDuplicateDimensions().isEmpty() )
+ {
+ throw new IllegalQueryException( "Dimensions cannot be specified more than once: " + params.getDuplicateDimensions() );
+ }
+
+ if ( params.hasDimensionOrFilter( DataQueryParams.DATASET_DIM_ID ) && !params.getDataElementGroupSets().isEmpty() )
+ {
+ throw new IllegalQueryException( "Data sets and data element group sets cannot be specified simultaneously" );
+ }
}
public List<DataQueryParams> planQuery( DataQueryParams params, int optimalQueries, String tableName )