dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38860
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19749: Analytics. Fixed bug related to using data elements as filter.
------------------------------------------------------------
revno: 19749
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-08-07 19:59:15 +0200
message:
Analytics. Fixed bug related to using data elements as filter.
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/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/DefaultEventQueryPlanner.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/security/DefaultAnalyticsSecurityManager.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-05 14:08:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-08-07 17:59:15 +0000
@@ -654,7 +654,7 @@
if ( dataPeriodType != null )
{
- for ( NameableObject aggregatePeriod : getDimensionOrFilter( PERIOD_DIM_ID ) )
+ for ( NameableObject aggregatePeriod : getDimensionOrFilterItems( PERIOD_DIM_ID ) )
{
Period dataPeriod = dataPeriodType.createPeriod( ((Period) aggregatePeriod).getStartDate() );
@@ -760,6 +760,17 @@
return index != -1 ? dimensions.get( index ) : null;
}
+
+ /**
+ * Retrieves the dimension or filter with the given dimension identifier.
+ * Returns null if the dimension or filter is not present.
+ */
+ public DimensionalObject getDimensionOrFilter( String dimension )
+ {
+ DimensionalObject dim = getDimension( dimension );
+
+ return dim != null ? dim : getFilter( dimension );
+ }
/**
* Sets the options for the given dimension.
@@ -1490,7 +1501,7 @@
* Retrieves the options for the the dimension or filter with the given
* identifier. Returns an empty list if the dimension or filter is not present.
*/
- public List<NameableObject> getDimensionOrFilter( String key )
+ public List<NameableObject> getDimensionOrFilterItems( String key )
{
List<NameableObject> dimensionOptions = getDimensionOptions( key );
@@ -1555,7 +1566,7 @@
*/
public boolean hasDimensionOrFilterWithItems( String key )
{
- return !getDimensionOrFilter( key ).isEmpty();
+ return !getDimensionOrFilterItems( key ).isEmpty();
}
/**
@@ -1600,7 +1611,7 @@
{
return ImmutableList.copyOf( ListUtils.union( getDataSets(), getFilterDataSets() ) );
}
-
+
public List<NameableObject> getAllProgramAttributes()
{
return ImmutableList.copyOf( ListUtils.union( getProgramAttributes(), getFilterProgramAttributes() ) );
@@ -1611,9 +1622,14 @@
return ImmutableList.copyOf( ListUtils.union( getProgramDataElements(), getFilterProgramDataElements() ) );
}
+ public List<NameableObject> getAllProgramDataElementsAndAttributes()
+ {
+ return ListUtils.union( getAllProgramAttributes(), getAllProgramDataElements() );
+ }
+
public DataQueryParams retainDataDimension( DataDimensionItemType itemType )
{
- DimensionalObject dimension = getDimension( DATA_X_DIM_ID );
+ DimensionalObject dimension = getDimensionOrFilter( DATA_X_DIM_ID );
List<NameableObject> items = DimensionalObjectUtils.getByDataDimensionType( itemType, dimension.getItems() );
@@ -1625,7 +1641,7 @@
public DataQueryParams retainDataDimensions( DataDimensionItemType... itemTypes )
{
- DimensionalObject dimension = getDimension( DATA_X_DIM_ID );
+ DimensionalObject dimension = getDimensionOrFilter( DATA_X_DIM_ID );
List<NameableObject> items = new ArrayList<>();
@@ -1704,11 +1720,6 @@
return ImmutableList.copyOf( DimensionalObjectUtils.getByDataDimensionType( DataDimensionItemType.PROGRAM_ATTRIBUTE, getDimensionOptions( DATA_X_DIM_ID ) ) );
}
- public List<NameableObject> getProgramDataElementsAndAttributes()
- {
- return ListUtils.union( getProgramDataElements(), getProgramAttributes() );
- }
-
public void setProgramAttributes( List<? extends NameableObject> programAttributes )
{
setDataDimensionOptions( DataDimensionItemType.PROGRAM_ATTRIBUTE, programAttributes );
@@ -1789,7 +1800,7 @@
public boolean isCategoryOptionCombosEnabled()
{
- return !getDimensionOrFilter( CATEGORYOPTIONCOMBO_DIM_ID ).isEmpty();
+ return !getDimensionOrFilterItems( CATEGORYOPTIONCOMBO_DIM_ID ).isEmpty();
}
// -------------------------------------------------------------------------
=== 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-08-06 13:12:50 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-08-07 17:59:15 +0000
@@ -366,7 +366,7 @@
*/
private void addDataElementValues( DataQueryParams params, Grid grid )
{
- if ( !params.getDataElements().isEmpty() && !params.isSkipData() )
+ if ( !params.getAllDataElements().isEmpty() && !params.isSkipData() )
{
DataQueryParams dataSourceParams = params.instance();
dataSourceParams.retainDataDimension( DataDimensionItemType.AGGREGATE_DATA_ELEMENT );
@@ -584,7 +584,7 @@
*/
private void addProgramDataElementAttributeValues( DataQueryParams params, Grid grid )
{
- if ( !params.getProgramDataElementsAndAttributes().isEmpty() && !params.isSkipData() )
+ if ( !params.getAllProgramDataElementsAndAttributes().isEmpty() && !params.isSkipData() )
{
DataQueryParams dataSourceParams = params.instance();
dataSourceParams.retainDataDimensions( DataDimensionItemType.PROGRAM_DATA_ELEMENT, DataDimensionItemType.PROGRAM_ATTRIBUTE );
@@ -651,8 +651,8 @@
Calendar calendar = PeriodType.getCalendar();
List<String> periodUids = calendar.isIso8601() ?
- getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) :
- getLocalPeriodIdentifiers( params.getDimensionOrFilter( PERIOD_DIM_ID ), calendar );
+ getUids( params.getDimensionOrFilterItems( PERIOD_DIM_ID ) ) :
+ getLocalPeriodIdentifiers( params.getDimensionOrFilterItems( PERIOD_DIM_ID ), calendar );
metaData.put( PERIOD_DIM_ID, periodUids );
metaData.put( CATEGORYOPTIONCOMBO_DIM_ID, cocNameMap.keySet() );
@@ -671,7 +671,7 @@
User user = currentUserService.getCurrentUser();
- List<OrganisationUnit> organisationUnits = asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class );
+ List<OrganisationUnit> organisationUnits = asTypedList( params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ), OrganisationUnit.class );
Collection<OrganisationUnit> roots = user != null ? user.getOrganisationUnits() : null;
if ( params.isHierarchyMeta() )
=== 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-08-02 14:59:59 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-08-07 17:59:15 +0000
@@ -195,7 +195,7 @@
*/
public void replacePeriodsWithStartEndDates()
{
- List<Period> periods = NameableObjectUtils.asTypedList( getDimensionOrFilter( PERIOD_DIM_ID ), Period.class );
+ List<Period> periods = NameableObjectUtils.asTypedList( getDimensionOrFilterItems( PERIOD_DIM_ID ), Period.class );
for ( Period period : periods )
{
@@ -345,7 +345,7 @@
{
Set<OrganisationUnit> children = new HashSet<>();
- for ( NameableObject object : getDimensionOrFilter( DimensionalObject.ORGUNIT_DIM_ID ) )
+ for ( NameableObject object : getDimensionOrFilterItems( DimensionalObject.ORGUNIT_DIM_ID ) )
{
OrganisationUnit unit = (OrganisationUnit) object;
children.addAll( unit.getChildren() );
=== 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-08-04 11:09:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-08-07 17:59:15 +0000
@@ -253,12 +253,12 @@
Map<String, String> uidNameMap = getUidNameMap( params );
metaData.put( NAMES_META_KEY, uidNameMap );
- metaData.put( PERIOD_DIM_ID, getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) );
- metaData.put( ORGUNIT_DIM_ID, getUids( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ) );
+ metaData.put( PERIOD_DIM_ID, getUids( params.getDimensionOrFilterItems( PERIOD_DIM_ID ) ) );
+ metaData.put( ORGUNIT_DIM_ID, getUids( params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ) ) );
User user = currentUserService.getCurrentUser();
- List<OrganisationUnit> organisationUnits = asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class );
+ List<OrganisationUnit> organisationUnits = asTypedList( params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ), OrganisationUnit.class );
Collection<OrganisationUnit> roots = user != null ? user.getOrganisationUnits() : null;
if ( params.isHierarchyMeta() )
@@ -359,7 +359,7 @@
if ( params.isHierarchyMeta() )
{
metaData.put( OU_HIERARCHY_KEY, getParentGraphMap( asTypedList(
- params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ), roots ) );
+ params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ), OrganisationUnit.class ), roots ) );
}
if ( params.isPaging() )
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2015-06-18 14:35:18 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2015-08-07 17:59:15 +0000
@@ -196,7 +196,7 @@
if ( params.hasDimensionOrFilter( DimensionalObject.ORGUNIT_DIM_ID ) )
{
- for ( NameableObject object : params.getDimensionOrFilter( DimensionalObject.ORGUNIT_DIM_ID ) )
+ for ( NameableObject object : params.getDimensionOrFilterItems( DimensionalObject.ORGUNIT_DIM_ID ) )
{
OrganisationUnit unit = (OrganisationUnit) object;
unit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( unit.getId() ) );
=== 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-07-19 15:50:46 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2015-08-07 17:59:15 +0000
@@ -436,7 +436,7 @@
}
else // Periods
{
- sql += "where " + params.getPeriodType() + " in (" + getQuotedCommaDelimitedString( getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) ) + ") ";
+ sql += "where " + params.getPeriodType() + " in (" + getQuotedCommaDelimitedString( getUids( params.getDimensionOrFilterItems( PERIOD_DIM_ID ) ) ) + ") ";
}
// ---------------------------------------------------------------------
@@ -445,7 +445,7 @@
if ( params.isOrganisationUnitMode( DimensionalObject.OU_MODE_SELECTED ) )
{
- sql += "and ou in (" + getQuotedCommaDelimitedString( getUids( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ) ) + ") ";
+ sql += "and ou in (" + getQuotedCommaDelimitedString( getUids( params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ) ) ) + ") ";
}
else if ( params.isOrganisationUnitMode( DimensionalObject.OU_MODE_CHILDREN ) )
{
@@ -455,7 +455,7 @@
{
sql += "and (";
- for ( NameableObject object : params.getDimensionOrFilter( ORGUNIT_DIM_ID ) )
+ for ( NameableObject object : params.getDimensionOrFilterItems( ORGUNIT_DIM_ID ) )
{
OrganisationUnit unit = (OrganisationUnit) object;
sql += "uidlevel" + unit.getLevel() + " = '" + unit.getUid() + "' or ";
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/security/DefaultAnalyticsSecurityManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/security/DefaultAnalyticsSecurityManager.java 2015-06-14 17:51:03 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/security/DefaultAnalyticsSecurityManager.java 2015-08-07 17:59:15 +0000
@@ -89,7 +89,7 @@
User user = currentUserService.getCurrentUser();
- List<NameableObject> queryOrgUnits = params.getDimensionOrFilter( DimensionalObject.ORGUNIT_DIM_ID );
+ List<NameableObject> queryOrgUnits = params.getDimensionOrFilterItems( DimensionalObject.ORGUNIT_DIM_ID );
if ( queryOrgUnits.isEmpty() || user == null || !user.hasDataViewOrganisationUnit() )
{