dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39493
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19996: Analytics, streams for filtering
------------------------------------------------------------
revno: 19996
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-09-04 15:51:59 +0200
message:
Analytics, streams for filtering
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/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.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 2015-08-21 03:14:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-09-04 13:51:59 +0000
@@ -51,6 +51,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.common.BaseDimensionalObject;
@@ -1473,12 +1474,7 @@
if ( !des.isEmpty() )
{
- Set<DataElementCategoryCombo> categoryCombos = new HashSet<>();
-
- for ( NameableObject de : des )
- {
- categoryCombos.add( ((DataElement) de).getCategoryCombo() );
- }
+ Set<DataElementCategoryCombo> categoryCombos = des.stream().map( d -> ((DataElement) d).getCategoryCombo() ).collect( Collectors.toSet() );
for ( DataElementCategoryCombo cc : categoryCombos )
{
@@ -1707,25 +1703,8 @@
public List<DimensionalObject> getDataElementGroupSets()
{
- List<DimensionalObject> list = new ArrayList<>();
-
- for ( DimensionalObject dimension : dimensions )
- {
- if ( DimensionType.DATAELEMENT_GROUPSET.equals( dimension.getDimensionType() ) )
- {
- list.add( dimension );
- }
- }
-
- for ( DimensionalObject filter : filters )
- {
- if ( DimensionType.DATAELEMENT_GROUPSET.equals( filter.getDimensionType() ) )
- {
- list.add( filter );
- }
- }
-
- return list;
+ return ListUtils.union( dimensions, filters ).stream().
+ filter( d -> DimensionType.DATAELEMENT_GROUPSET.equals( d.getDimensionType() ) ).collect( Collectors.toList() );
}
public void setDataElementGroupSet( DataElementGroupSet groupSet )
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java 2015-09-04 10:49:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java 2015-09-04 13:51:59 +0000
@@ -78,7 +78,7 @@
deB = createDataElement( 'B', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
deC = createDataElement( 'C', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
deD = createDataElement( 'D', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
- deE = createDataElement( 'E', ValueType.INTEGER.INTEGER, AGGREGATION_OPERATOR_SUM );
+ deE = createDataElement( 'E', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
deF = createDataElement( 'F', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM );
deG = createDataElement( 'G', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM );