dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22768
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11047: Analytics, fixed bug with validation
------------------------------------------------------------
revno: 11047
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-05-28 13:35:56 +0200
message:
Analytics, fixed bug with 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
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.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-05-28 10:45:55 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-05-28 11:35:56 +0000
@@ -753,7 +753,7 @@
if ( param.split( DIMENSION_NAME_SEP ).length > 1 )
{
- return Arrays.asList( param.split( DIMENSION_NAME_SEP )[1].split( OPTION_SEP ) );
+ return new ArrayList<String>( Arrays.asList( param.split( DIMENSION_NAME_SEP )[1].split( OPTION_SEP ) ) );
}
return new ArrayList<String>();
@@ -812,7 +812,7 @@
return null;
}
- return Arrays.asList( param.split( OPTION_SEP ) );
+ return new ArrayList<String>( Arrays.asList( param.split( OPTION_SEP ) ) );
}
/**
=== 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-05-28 11:04:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-05-28 11:35:56 +0000
@@ -386,6 +386,9 @@
return getAggregatedDataValues( params );
}
+ ListUtils.removeEmptys( columns );
+ ListUtils.removeEmptys( rows );
+
queryPlanner.validateTableLayout( params, columns, rows );
Map<String, Double> valueMap = getAggregatedDataValueMapping( params );
=== 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-05-28 11:14:16 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-05-28 11:35:56 +0000
@@ -33,26 +33,30 @@
import static org.hisp.dhis.analytics.AggregationType.SUM;
import static org.hisp.dhis.analytics.DataQueryParams.LEVEL_PREFIX;
import static org.hisp.dhis.analytics.DataQueryParams.MAX_DIM_OPT_PERM;
+import static org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.DATAELEMENT_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.DATASET_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.INDICATOR_DIM_ID;
+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.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_BOOL;
-import static org.hisp.dhis.common.DimensionalObject.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.analytics.DataQueryGroups;
import org.hisp.dhis.analytics.DataQueryParams;
-import org.hisp.dhis.common.DimensionType;
import org.hisp.dhis.analytics.IllegalQueryException;
import org.hisp.dhis.analytics.QueryPlanner;
import org.hisp.dhis.analytics.table.PartitionUtils;
import org.hisp.dhis.common.BaseDimensionalObject;
+import org.hisp.dhis.common.DimensionType;
import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.ListMap;
import org.hisp.dhis.common.NameableObject;
@@ -154,7 +158,7 @@
{
for ( String column : columns )
{
- if ( !StringUtils.isEmpty( column ) && !params.hasDimensionCollapseDx( column ) )
+ if ( !params.hasDimensionCollapseDx( column ) )
{
violation = "Column must be present as dimension in query: " + column;
}
@@ -165,7 +169,7 @@
{
for ( String row : rows )
{
- if ( !StringUtils.isEmpty( row ) && !params.hasDimensionCollapseDx( row ) )
+ if ( !params.hasDimensionCollapseDx( row ) )
{
violation = "Row must be present as dimension in query: " + row;
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2013-05-27 19:21:48 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2013-05-28 11:35:56 +0000
@@ -33,9 +33,12 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
+
/**
* @author Lars Helge Overland
*/
@@ -166,4 +169,25 @@
return list;
}
+
+ /**
+ * Removes empty strings from the given list. Empty includes null.
+ *
+ * @param list the list of strings.
+ */
+ public static void removeEmptys( List<String> list )
+ {
+ if ( list != null && !list.isEmpty() )
+ {
+ Iterator<String> iterator = list.iterator();
+
+ while ( iterator.hasNext() )
+ {
+ if ( StringUtils.isEmpty( iterator.next() ) )
+ {
+ iterator.remove();
+ }
+ }
+ }
+ }
}