dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38106
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19459: Analytics, program indicator support, step 2
------------------------------------------------------------
revno: 19459
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-06-18 23:47:26 +0200
message:
Analytics, program indicator support, step 2
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java
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/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/dimension/DimensionServiceTest.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.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-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2015-06-18 10:54:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2015-06-18 21:47:26 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -158,7 +159,14 @@
*/
String filterIsValid( String filter );
- Set<DataElement> getDataElementsInIndicators( Set<ProgramIndicator> indicators );
+ /**
+ * Returns all {@link DataElement} part of the given collection
+ * of {@link ProgramIndicator}.
+ *
+ * @param indicators the ProgramIndicators.
+ * @return a set of DataElements.
+ */
+ Set<DataElement> getDataElementsInIndicators( Collection<ProgramIndicator> indicators );
/**
* Get all {@link ProgramStageDataElement} part of the expression.
@@ -167,8 +175,15 @@
* @return a set of ProgramStageDataElements.
*/
Set<ProgramStageDataElement> getProgramStageDataElementsInExpression( String expression );
-
- Set<TrackedEntityAttribute> getAttributesInIndicators( Set<ProgramIndicator> indicators );
+
+ /**
+ * Returns all {@link TrackedEntityAttribute} part of the given collection
+ * of {@link ProgramIndicator}.
+ *
+ * @param indicators the ProgramIndicators.
+ * @return a set of TrackedEntityAttributes.
+ */
+ Set<TrackedEntityAttribute> getAttributesInIndicators( Collection<ProgramIndicator> indicators );
/**
* Get all {@link TrackedEntityAttribute} part of the expression.
@@ -177,8 +192,15 @@
* @return a set of TrackedEntityAttributes.
*/
Set<TrackedEntityAttribute> getAttributesInExpression( String expression );
-
- Set<Constant> getConstantsInIndicators( Set<ProgramIndicator> indicators );
+
+ /**
+ * Returns all {@link Constant} part of the given collection of
+ * {@link ProgramIndicator}.
+ *
+ * @param indicators the ProgramIndicators.
+ * @return a set of Constants.
+ */
+ Set<Constant> getConstantsInIndicators( Collection<ProgramIndicator> indicators );
/**
* Get all {@link Constant} part of the expression of the expression.
=== 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-06-18 14:35:18 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-06-18 21:47:26 +0000
@@ -30,11 +30,11 @@
import static org.hisp.dhis.analytics.AggregationType.AVERAGE_INT_DISAGGREGATION;
import static org.hisp.dhis.analytics.AggregationType.AVERAGE_SUM_INT_DISAGGREGATION;
+import static org.hisp.dhis.common.DimensionType.CATEGORYOPTION_GROUPSET;
import static org.hisp.dhis.common.DimensionType.DATASET;
-import static org.hisp.dhis.common.DimensionType.PERIOD;
import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT;
import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT_GROUPSET;
-import static org.hisp.dhis.common.DimensionType.CATEGORYOPTION_GROUPSET;
+import static org.hisp.dhis.common.DimensionType.PERIOD;
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.DATAELEMENT_OPERAND_ID;
@@ -44,14 +44,13 @@
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.common.DimensionalObject.PROGRAM_ATTRIBUTE_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.PROGRAM_DATAELEMENT_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.PROGRAM_INDICATOR_DIM_ID;
-import static org.hisp.dhis.common.DimensionalObject.PROGRAM_DATAELEMENT_DIM_ID;
-import static org.hisp.dhis.common.DimensionalObject.PROGRAM_ATTRIBUTE_DIM_ID;
import static org.hisp.dhis.common.NameableObjectUtils.asList;
import static org.hisp.dhis.common.NameableObjectUtils.getList;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -72,6 +71,8 @@
import org.hisp.dhis.common.ListMap;
import org.hisp.dhis.common.MapMap;
import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.commons.collection.CollectionUtils;
+import org.hisp.dhis.commons.collection.ListUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -85,8 +86,6 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.system.util.MathUtils;
-import org.hisp.dhis.commons.collection.CollectionUtils;
-import org.hisp.dhis.commons.collection.ListUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -110,15 +109,15 @@
public static final int DX_INDEX = 0;
public static final int CO_IN_INDEX = 1;
- public static final List<String> DATA_DIMS = Arrays.asList(
+ public static final List<String> DATA_DIMS = Lists.newArrayList(
INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATAELEMENT_OPERAND_ID, DATASET_DIM_ID, PROGRAM_INDICATOR_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID, PROGRAM_ATTRIBUTE_DIM_ID );
- public static final List<String> FIXED_DIMS = Arrays.asList(
+ public static final List<String> FIXED_DIMS = Lists.newArrayList(
DATA_X_DIM_ID, INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, PROGRAM_INDICATOR_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID, PROGRAM_ATTRIBUTE_DIM_ID, PERIOD_DIM_ID, ORGUNIT_DIM_ID );
- private static final List<String> DIMENSION_PERMUTATION_IGNORE_DIMS = Arrays.asList(
+ private static final List<String> DIMENSION_PERMUTATION_IGNORE_DIMS = Lists.newArrayList(
INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, CATEGORYOPTIONCOMBO_DIM_ID, DATASET_DIM_ID, PROGRAM_INDICATOR_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID, PROGRAM_ATTRIBUTE_DIM_ID );
- public static final List<DimensionType> COMPLETENESS_DIMENSION_TYPES = Arrays.asList(
+ public static final List<DimensionType> COMPLETENESS_DIMENSION_TYPES = Lists.newArrayList(
DATASET, PERIOD, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET, CATEGORYOPTION_GROUPSET );
- private static final List<DimensionType> COMPLETENESS_TARGET_DIMENSION_TYPES = Arrays.asList(
+ private static final List<DimensionType> COMPLETENESS_TARGET_DIMENSION_TYPES = Lists.newArrayList(
DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
private static final DimensionItem[] DIM_OPT_ARR = new DimensionItem[0];
@@ -1022,7 +1021,7 @@
{
for ( String key : aggregatedDataMap.keySet() )
{
- List<String> keys = new ArrayList<>( Arrays.asList( key.split( DIMENSION_SEP ) ) );
+ List<String> keys = Lists.newArrayList( key.split( DIMENSION_SEP ) );
String de = keys.get( DX_INDEX );
String coc = cocEnabled ? keys.get( CO_IN_INDEX ) : null;
@@ -1038,6 +1037,32 @@
permutationMap.putEntry( permKey, operand, value );
}
}
+
+ /**
+ * Returns a mapping of permutation keys and mappings of identifiers and values
+ * based on the given mapping of dimension option keys and values.
+ */
+ public static Map<String, Map<String, Double>> getPermutationProgramValueMap( Map<String, Double> valueMap )
+ {
+ MapMap<String, String, Double> permutationMap = new MapMap<>();
+
+ for ( String key : valueMap.keySet() )
+ {
+ List<String> keys = Lists.newArrayList( key.split( DIMENSION_SEP ) );
+
+ String dxUid = keys.get( DX_INDEX );
+
+ keys.remove( DX_INDEX );
+
+ String permKey = StringUtils.join( keys, DIMENSION_SEP );
+
+ Double value = valueMap.get( key );
+
+ permutationMap.putEntry( permKey, dxUid, value );
+ }
+
+ return permutationMap;
+ }
/**
* Returns a mapping of permutations keys (org unit id or null) and mappings
@@ -1050,7 +1075,7 @@
for ( String key : orgUnitCountMap.keySet() )
{
- List<String> keys = new ArrayList<>( Arrays.asList( key.split( DIMENSION_SEP ) ) );
+ List<String> keys = Lists.newArrayList( key.split( DIMENSION_SEP ) );
// Org unit group always at last index, org unit potentially at first
=== 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 2015-06-18 15:20:32 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-06-18 21:47:26 +0000
@@ -264,7 +264,7 @@
addProgramIndicatorValues( params, grid );
- addProgramValues( params, grid );
+ addProgramDataElementAttributeValues( params, grid );
addDynamicDimensionValues( params, grid );
@@ -293,64 +293,6 @@
}
/**
- * Adds program indicator values to the given grid based on the given data query
- * parameters.
- *
- * @param params the data query parameters.
- * @param grid the grid.
- */
- private void addProgramIndicatorValues( DataQueryParams params, Grid grid )
- {
- if ( !params.getProgramIndicators().isEmpty() )
- {
- DataQueryParams dataSourceParams = params.instance();
- dataSourceParams.removeDimensions( INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID, PROGRAM_ATTRIBUTE_DIM_ID );
-
- List<ProgramIndicator> indicators = asTypedList( dataSourceParams.getProgramIndicators() );
-
- //TODO constants
-
- // -----------------------------------------------------------------
- // Get indicator values
- // -----------------------------------------------------------------
-
- List<List<DimensionItem>> dimensionItemPermutations = dataSourceParams.getDimensionItemPermutations();
-
- Map<String, Map<String, Double>> permutationOperandValueMap = Maps.newHashMap(); //TODO add values
-
- for ( ProgramIndicator indicator : indicators )
- {
- for ( List<DimensionItem> dimensionItems : dimensionItemPermutations )
- {
- String permKey = DimensionItem.asItemKey( dimensionItems );
-
- Map<String, Double> valueMap = permutationOperandValueMap.get( permKey );
-
- if ( valueMap == null )
- {
- continue;
- }
-
- Double value = programIndicatorService.getProgramIndicatorValue( indicator, valueMap );
-
- if ( value != null )
- {
- List<DimensionItem> row = new ArrayList<>( dimensionItems );
-
- row.add( DX_INDEX, new DimensionItem( PROGRAM_INDICATOR_DIM_ID, indicator ) );
-
- Double roundedValue = MathUtils.getRounded( value );
-
- grid.addRow();
- grid.addValues( DimensionItem.getItemIdentifiers( row ) );
- grid.addValue( dataSourceParams.isSkipRounding() ? value : roundedValue );
- }
- }
- }
- }
- }
-
- /**
* Adds indicator values to the given grid based on the given data query
* parameters.
*
@@ -524,18 +466,76 @@
}
/**
+ * Adds program indicator values to the given grid based on the given data query
+ * parameters.
+ *
+ * @param params the data query parameters.
+ * @param grid the grid.
+ */
+ private void addProgramIndicatorValues( DataQueryParams params, Grid grid )
+ {
+ if ( !params.getProgramIndicators().isEmpty() )
+ {
+ DataQueryParams dataSourceParams = params.instance();
+ dataSourceParams.removeDimensions( INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID, PROGRAM_ATTRIBUTE_DIM_ID );
+
+ List<ProgramIndicator> indicators = asTypedList( dataSourceParams.getProgramIndicators() );
+
+ //TODO constants
+
+ // -----------------------------------------------------------------
+ // Get indicator values
+ // -----------------------------------------------------------------
+
+ List<List<DimensionItem>> dimensionItemPermutations = dataSourceParams.getDimensionItemPermutations();
+
+ Map<String, Map<String, Double>> permutationOperandValueMap = getProgramPermutationOperandValueMap( dataSourceParams );
+
+ for ( ProgramIndicator indicator : indicators )
+ {
+ for ( List<DimensionItem> dimensionItems : dimensionItemPermutations )
+ {
+ String permKey = DimensionItem.asItemKey( dimensionItems );
+
+ Map<String, Double> valueMap = permutationOperandValueMap.get( permKey );
+
+ if ( valueMap == null )
+ {
+ continue;
+ }
+
+ Double value = programIndicatorService.getProgramIndicatorValue( indicator, valueMap );
+
+ if ( value != null )
+ {
+ List<DimensionItem> row = new ArrayList<>( dimensionItems );
+
+ row.add( DX_INDEX, new DimensionItem( PROGRAM_INDICATOR_DIM_ID, indicator ) );
+
+ Double roundedValue = MathUtils.getRounded( value );
+
+ grid.addRow();
+ grid.addValues( DimensionItem.getItemIdentifiers( row ) );
+ grid.addValue( dataSourceParams.isSkipRounding() ? value : roundedValue );
+ }
+ }
+ }
+ }
+ }
+
+ /**
* Adds program data element values to the given grid based on the given data
* query parameters.
*
* @param params the data query parameters.
* @param grid the grid.
*/
- private void addProgramValues( DataQueryParams params, Grid grid )
+ private void addProgramDataElementAttributeValues( DataQueryParams params, Grid grid )
{
if ( !params.getProgramDataElements().isEmpty() || !params.getProgramAttributes().isEmpty() )
{
DataQueryParams dataSourceParams = params.instance();
- dataSourceParams.removeDimensions( INDICATOR_DIM_ID, DATASET_DIM_ID, DATAELEMENT_DIM_ID );
+ dataSourceParams.removeDimensions( INDICATOR_DIM_ID, DATASET_DIM_ID, DATAELEMENT_DIM_ID, PROGRAM_INDICATOR_DIM_ID );
EventQueryParams eventQueryParams = EventQueryParams.fromDataQueryParams( dataSourceParams );
@@ -1073,7 +1073,7 @@
continue itemLoop;
}
- if ( de != null && DataElementDomain.TRACKER.equals( de.getDomainType() ) )
+ else if ( de != null && DataElementDomain.TRACKER.equals( de.getDomainType() ) )
{
programDataElements.add( de );
continue itemLoop;
@@ -1379,8 +1379,7 @@
/**
* Returns a mapping of permutation keys and mappings of data element operands
- * and values, based on the given mapping of dimension option keys and
- * aggregated values.
+ * and values based on the given query.
*
* @param params the data query parameters.
*/
@@ -1398,6 +1397,41 @@
}
/**
+ * Returns a mapping of permutation keys and mappings of program data elements
+ * / program attributes and values based on the given query.
+ *
+ * @param params the data query parameters.
+ */
+ private Map<String, Map<String, Double>> getProgramPermutationOperandValueMap( DataQueryParams params )
+ {
+ List<ProgramIndicator> programIndicators = asTypedList( params.getProgramIndicators() );
+ List<NameableObject> dataElements = asList( programIndicatorService.getDataElementsInIndicators( programIndicators ) );
+ List<NameableObject> attributes = asList( programIndicatorService.getAttributesInIndicators( programIndicators ) );
+
+ if ( !dataElements.isEmpty() || !attributes.isEmpty() )
+ {
+ DataQueryParams dataSourceParams = params.instance().removeDimensions( DataQueryParams.DATA_DIMS );
+
+ dataSourceParams.getDimensions().add( DX_INDEX, new BaseDimensionalObject(
+ PROGRAM_DATAELEMENT_DIM_ID, DimensionType.PROGRAM_DATAELEMENT, dataElements ) );
+ dataSourceParams.getDimensions().add( DX_INDEX, new BaseDimensionalObject(
+ PROGRAM_ATTRIBUTE_DIM_ID, DimensionType.PROGRAM_ATTRIBUTE, attributes ) );
+
+ EventQueryParams eventQueryParams = EventQueryParams.fromDataQueryParams( dataSourceParams );
+
+ Grid grid = eventAnalyticsService.getAggregatedEventData( eventQueryParams );
+
+ Map<String, Double> valueMap = grid.getAsMap( grid.getWidth() - 1, DIMENSION_SEP );
+
+ Map<String, Map<String, Double>> permutationMap = DataQueryParams.getPermutationProgramValueMap( valueMap );
+
+ return permutationMap;
+ }
+
+ return Maps.newHashMap();
+ }
+
+ /**
* Returns a mapping of dimension keys and aggregated values for the data
* element totals part of the indicators in the given query.
*
=== 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 2015-06-17 14:52:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2015-06-18 21:47:26 +0000
@@ -36,15 +36,14 @@
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.common.DimensionalObject.PROGRAM_ATTRIBUTE_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.PROGRAM_DATAELEMENT_DIM_ID;
-import static org.hisp.dhis.common.DimensionalObject.PROGRAM_ATTRIBUTE_DIM_ID;
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM;
import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_BOOL;
import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -66,6 +65,7 @@
import org.hisp.dhis.common.ListMap;
import org.hisp.dhis.common.MaintenanceModeException;
import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.commons.collection.PaginatedList;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -73,9 +73,10 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.util.MathUtils;
-import org.hisp.dhis.commons.collection.PaginatedList;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -84,7 +85,7 @@
{
private static final Log log = LogFactory.getLog( DefaultQueryPlanner.class );
- private static final List<String> AVERAGE_AGG_OPERATORS = Arrays.asList( AGGREGATION_OPERATOR_AVERAGE_SUM, AGGREGATION_OPERATOR_AVERAGE );
+ private static final List<String> AVERAGE_AGG_OPERATORS = Lists.newArrayList( AGGREGATION_OPERATOR_AVERAGE_SUM, AGGREGATION_OPERATOR_AVERAGE );
@Autowired
private OrganisationUnitService organisationUnitService;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-06-18 14:35:18 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-06-18 21:47:26 +0000
@@ -140,6 +140,8 @@
public static EventQueryParams fromDataQueryParams( DataQueryParams dataQueryParams )
{
+ //TODO indicator filter
+
EventQueryParams params = new EventQueryParams();
dataQueryParams.copyTo( params );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-06-18 21:47:26 +0000
@@ -43,7 +43,6 @@
import static org.hisp.dhis.organisationunit.OrganisationUnit.getParentGraphMap;
import static org.hisp.dhis.organisationunit.OrganisationUnit.getParentNameGraphMap;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -78,6 +77,7 @@
import org.hisp.dhis.common.QueryFilter;
import org.hisp.dhis.common.QueryItem;
import org.hisp.dhis.common.QueryOperator;
+import org.hisp.dhis.commons.collection.ListUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.i18n.I18nFormat;
@@ -92,7 +92,6 @@
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.grid.ListGrid;
import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.commons.collection.ListUtils;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.hisp.dhis.user.CurrentUserService;
@@ -101,6 +100,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.base.MoreObjects;
+import com.google.common.collect.Lists;
/**
* @author Lars Helge Overland
@@ -117,7 +117,7 @@
private static final String ITEM_ORG_UNIT_CODE = "oucode";
private static final String COL_NAME_EVENTDATE = "executiondate";
- private static final List<String> SORTABLE_ITEMS = Arrays.asList(
+ private static final List<String> SORTABLE_ITEMS = Lists.newArrayList(
ITEM_EXECUTION_DATE, ITEM_ORG_UNIT_NAME, ITEM_ORG_UNIT_CODE );
@Autowired
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2015-06-18 21:47:26 +0000
@@ -43,7 +43,6 @@
import static org.hisp.dhis.commons.util.TextUtils.removeLastOr;
import static org.hisp.dhis.commons.util.TextUtils.trimEnd;
-import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
@@ -68,6 +67,8 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
+import com.google.common.collect.Lists;
+
/**
* TODO could use row_number() and filtering for paging, but not supported on MySQL.
*
@@ -103,7 +104,7 @@
// Criteria
// ---------------------------------------------------------------------
- sql += getFromWhereClause( params, Arrays.asList( "psi" ) );
+ sql += getFromWhereClause( params, Lists.newArrayList( "psi" ) );
// ---------------------------------------------------------------------
// Group by
@@ -195,7 +196,7 @@
@Override
public Grid getEvents( EventQueryParams params, Grid grid, int maxLimit )
{
- List<String> fixedCols = Arrays.asList( "psi", "ps", "executiondate", "longitude", "latitude", "ouname", "oucode" );
+ List<String> fixedCols = Lists.newArrayList( "psi", "ps", "executiondate", "longitude", "latitude", "ouname", "oucode" );
String sql = "select " + getSelectString( fixedCols ) + getSelectColumns( params ) + " ";
@@ -281,7 +282,7 @@
{
String sql = "select count(psi) ";
- sql += getFromWhereClause( params, Arrays.asList( "psi" ) );
+ sql += getFromWhereClause( params, Lists.newArrayList( "psi" ) );
int count = 0;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2015-06-18 21:47:26 +0000
@@ -32,7 +32,6 @@
import static org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -55,6 +54,8 @@
import org.hisp.dhis.commons.util.TextUtils;
import org.springframework.scheduling.annotation.Async;
+import com.google.common.collect.Lists;
+
/**
* This class manages the analytics table. The analytics table is a denormalized
* table designed for analysis which contains raw data values. It has columns for
@@ -353,7 +354,7 @@
String[] ou = { quote( "ou" ), "character(11) not null", "ou.uid" };
String[] level = { quote( "level" ), "integer", "ous.level" };
- columns.addAll( Arrays.asList( de, co, ou, level ) );
+ columns.addAll( Lists.newArrayList( de, co, ou, level ) );
if ( isApprovalEnabled() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-06-18 21:47:26 +0000
@@ -31,7 +31,6 @@
import static org.hisp.dhis.commons.util.TextUtils.removeLast;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -56,6 +55,8 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.annotation.Transactional;
+import com.google.common.collect.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -324,7 +325,7 @@
String[] oun = { quote( "ouname" ), "character varying(230) not null", "ou.name" };
String[] ouc = { quote( "oucode" ), "character varying(50)", "ou.code" };
- columns.addAll( Arrays.asList( psi, pi, ps, ed, longitude, latitude, ou, oun, ouc ) );
+ columns.addAll( Lists.newArrayList( psi, pi, ps, ed, longitude, latitude, ou, oun, ouc ) );
if ( table.hasProgram() && table.getProgram().isRegistration() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java 2015-06-14 13:15:06 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryParamsTest.java 2015-06-18 21:47:26 +0000
@@ -35,7 +35,6 @@
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -66,7 +65,7 @@
@Test
public void testGetDimensionItemsFromParam()
{
- List<String> expected = new ArrayList<>( Arrays.asList( "D348asd782j", "kj78HnH6hgT", "9ds9dS98s2" ) );
+ List<String> expected = new ArrayList<>( Lists.newArrayList( "D348asd782j", "kj78HnH6hgT", "9ds9dS98s2" ) );
assertEquals( expected, DimensionalObjectUtils.getDimensionItemsFromParam( "de:D348asd782j;kj78HnH6hgT;9ds9dS98s2" ) );
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/dimension/DimensionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/dimension/DimensionServiceTest.java 2015-02-03 14:22:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/dimension/DimensionServiceTest.java 2015-06-18 21:47:26 +0000
@@ -34,8 +34,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.Arrays;
-
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.common.BaseDimensionalObject;
import org.hisp.dhis.common.BaseNameableObject;
@@ -54,6 +52,8 @@
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -169,9 +169,9 @@
{
ReportTable reportTable = new ReportTable();
- reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Arrays.asList( deA, deB ) ) );
- reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Arrays.asList( ouA, ouB, ouC, ouD, ouE ) ) );
- reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Arrays.asList( peA, peB ) ) );
+ reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Lists.newArrayList( deA, deB ) ) );
+ reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Lists.newArrayList( ouA, ouB, ouC, ouD, ouE ) ) );
+ reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList( peA, peB ) ) );
dimensionService.mergeAnalyticalObject( reportTable );
@@ -185,9 +185,9 @@
{
ReportTable reportTable = new ReportTable();
- reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Arrays.asList( deA, deB ) ) );
- reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Arrays.asList( ouUser ) ) );
- reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Arrays.asList( peA ) ) );
+ reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Lists.newArrayList( deA, deB ) ) );
+ reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Lists.newArrayList( ouUser ) ) );
+ reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList( peA ) ) );
dimensionService.mergeAnalyticalObject( reportTable );
@@ -202,9 +202,9 @@
{
ReportTable reportTable = new ReportTable();
- reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Arrays.asList( deA, deB ) ) );
- reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Arrays.asList( ouLevel2, ouA ) ) );
- reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Arrays.asList( peA ) ) );
+ reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Lists.newArrayList( deA, deB ) ) );
+ reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Lists.newArrayList( ouLevel2, ouA ) ) );
+ reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList( peA ) ) );
dimensionService.mergeAnalyticalObject( reportTable );
@@ -219,9 +219,9 @@
{
ReportTable reportTable = new ReportTable();
- reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Arrays.asList( deA, deB ) ) );
- reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Arrays.asList( ouA, ouB, ouC, ouD, ouE ) ) );
- reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Arrays.asList( peLast12Months ) ) );
+ reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Lists.newArrayList( deA, deB ) ) );
+ reportTable.getRows().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, Lists.newArrayList( ouA, ouB, ouC, ouD, ouE ) ) );
+ reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList( peLast12Months ) ) );
dimensionService.mergeAnalyticalObject( reportTable );
@@ -236,9 +236,9 @@
{
ReportTable reportTable = new ReportTable();
- reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Arrays.asList( deA, deB ) ) );
+ reportTable.getColumns().add( new BaseDimensionalObject( DimensionalObject.DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, Lists.newArrayList( deA, deB ) ) );
reportTable.getRows().add( ouGroupSetA );
- reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Arrays.asList( peA, peB ) ) );
+ reportTable.getFilters().add( new BaseDimensionalObject( DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList( peA, peB ) ) );
dimensionService.mergeAnalyticalObject( reportTable );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java 2015-06-18 21:47:26 +0000
@@ -30,7 +30,6 @@
import static org.junit.Assert.assertEquals;
-import java.util.Arrays;
import java.util.List;
import org.hisp.dhis.DhisSpringTest;
@@ -44,6 +43,8 @@
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Lists;
+
/**
* @author Lars Helge Overland
*/
@@ -83,7 +84,7 @@
params.setProgram( prA );
params.setStartDate( new DateTime( 2010, 6, 1, 0, 0 ).toDate() );
params.setEndDate( new DateTime( 2012, 3, 20, 0, 0 ).toDate() );
- params.setOrganisationUnits( Arrays.asList( ouA ) );
+ params.setOrganisationUnits( Lists.newArrayList( ouA ) );
List<EventQueryParams> queries = queryPlanner.planAggregateQuery( params );
@@ -109,7 +110,7 @@
params.setProgram( prA );
params.setStartDate( new DateTime( 2010, 3, 1, 0, 0 ).toDate() );
params.setEndDate( new DateTime( 2010, 9, 20, 0, 0 ).toDate() );
- params.setOrganisationUnits( Arrays.asList( ouA ) );
+ params.setOrganisationUnits( Lists.newArrayList( ouA ) );
List<EventQueryParams> queries = queryPlanner.planAggregateQuery( params );
@@ -133,7 +134,7 @@
params.setProgram( prA );
params.setStartDate( new DateTime( 2010, 6, 1, 0, 0 ).toDate() );
params.setEndDate( new DateTime( 2012, 3, 20, 0, 0 ).toDate() );
- params.setOrganisationUnits( Arrays.asList( ouA, ouB ) );
+ params.setOrganisationUnits( Lists.newArrayList( ouA, ouB ) );
List<EventQueryParams> queries = queryPlanner.planAggregateQuery( params );
@@ -149,7 +150,7 @@
params.setProgram( prA );
params.setStartDate( new DateTime( 2010, 6, 1, 0, 0 ).toDate() );
params.setEndDate( new DateTime( 2012, 3, 20, 0, 0 ).toDate() );
- params.setOrganisationUnits( Arrays.asList( ouA ) );
+ params.setOrganisationUnits( Lists.newArrayList( ouA ) );
params = queryPlanner.planEventQuery( params );
@@ -171,7 +172,7 @@
params.setProgram( prA );
params.setStartDate( new DateTime( 2010, 3, 1, 0, 0 ).toDate() );
params.setEndDate( new DateTime( 2010, 9, 20, 0, 0 ).toDate() );
- params.setOrganisationUnits( Arrays.asList( ouA ) );
+ params.setOrganisationUnits( Lists.newArrayList( ouA ) );
params = queryPlanner.planEventQuery( params );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-06-18 14:54:01 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-06-18 21:47:26 +0000
@@ -460,7 +460,7 @@
}
@Override
- public Set<DataElement> getDataElementsInIndicators( Set<ProgramIndicator> indicators )
+ public Set<DataElement> getDataElementsInIndicators( Collection<ProgramIndicator> indicators )
{
Set<DataElement> dataElements = new HashSet<>();
@@ -502,7 +502,7 @@
}
@Override
- public Set<TrackedEntityAttribute> getAttributesInIndicators( Set<ProgramIndicator> indicators )
+ public Set<TrackedEntityAttribute> getAttributesInIndicators( Collection<ProgramIndicator> indicators )
{
Set<TrackedEntityAttribute> attributes = new HashSet<>();
@@ -537,7 +537,7 @@
}
@Override
- public Set<Constant> getConstantsInIndicators( Set<ProgramIndicator> indicators )
+ public Set<Constant> getConstantsInIndicators( Collection<ProgramIndicator> indicators )
{
Set<Constant> constants = new HashSet<>();