dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33099
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16857: Event aggregate analytics. Added support for displayProperty query parameter.
------------------------------------------------------------
revno: 16857
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-09-29 19:13:01 +0200
message:
Event aggregate analytics. Added support for displayProperty query parameter.
modified:
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/data/DefaultEventAnalyticsService.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/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-09-29 16:28:57 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-09-29 17:13:01 +0000
@@ -1221,29 +1221,29 @@
Calendar calendar = PeriodType.getCalendar();
- for ( NameableObject idObject : items )
+ for ( NameableObject object : items )
{
- if ( !calendar.isIso8601() && Period.class.isInstance( idObject ) )
+ if ( !calendar.isIso8601() && Period.class.isInstance( object ) )
{
- Period period = (Period) idObject;
+ Period period = (Period) object;
DateTimeUnit dateTimeUnit = calendar.fromIso( period.getStartDate() );
- map.put( period.getPeriodType().getIsoDate( dateTimeUnit ), idObject.getDisplayName() );
+ map.put( period.getPeriodType().getIsoDate( dateTimeUnit ), period.getDisplayName() );
}
else
{
if ( DisplayProperty.SHORTNAME.equals( displayProperty ) )
{
- map.put( idObject.getUid(), idObject.getDisplayShortName() );
+ map.put( object.getUid(), object.getDisplayShortName() );
}
else // NAME
{
- map.put( idObject.getUid(), idObject.getDisplayName() );
+ map.put( object.getUid(), object.getDisplayName() );
}
}
if ( orgUnitHierarchy )
{
- OrganisationUnit unit = (OrganisationUnit) idObject;
+ OrganisationUnit unit = (OrganisationUnit) object;
if ( DisplayProperty.SHORTNAME.equals( displayProperty ) )
{
=== 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 2014-09-29 08:32:57 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2014-09-29 17:13:01 +0000
@@ -43,6 +43,7 @@
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -57,13 +58,14 @@
import org.hisp.dhis.common.AnalyticalObject;
import org.hisp.dhis.common.DimensionType;
import org.hisp.dhis.common.DimensionalObject;
+import org.hisp.dhis.common.DisplayProperty;
import org.hisp.dhis.common.EventAnalyticalObject;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.GridHeader;
-import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.common.IllegalQueryException;
import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.common.NameableObjectUtils;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.QueryFilter;
import org.hisp.dhis.common.QueryItem;
@@ -560,13 +562,13 @@
map.put( item.getItem().getUid(), item.getItem().getDisplayName() );
}
- map.putAll( getUidNameMap( params.getDimensions(), params.isHierarchyMeta() ) );
- map.putAll( getUidNameMap( params.getFilters(), params.isHierarchyMeta() ) );
+ map.putAll( getUidNameMap( params.getDimensions(), params.isHierarchyMeta(), params.getDisplayProperty() ) );
+ map.putAll( getUidNameMap( params.getFilters(), params.isHierarchyMeta(), params.getDisplayProperty() ) );
return map;
}
- private Map<String, String> getUidNameMap( List<DimensionalObject> dimensions, boolean hierarchyMeta )
+ private Map<String, String> getUidNameMap( List<DimensionalObject> dimensions, boolean hierarchyMeta, DisplayProperty displayProperty )
{
Map<String, String> map = new HashMap<>();
@@ -574,16 +576,26 @@
{
boolean hierarchy = hierarchyMeta && DimensionType.ORGANISATIONUNIT.equals( dimension.getDimensionType() );
- for ( IdentifiableObject idObject : dimension.getItems() )
+ for ( NameableObject object : dimension.getItems() )
{
- map.put( idObject.getUid(), idObject.getDisplayName() );
-
+ Set<NameableObject> objects = new HashSet<>();
+ objects.add( object );
+
if ( hierarchy )
{
- OrganisationUnit unit = (OrganisationUnit) idObject;
+ OrganisationUnit unit = (OrganisationUnit) object;
+ objects.addAll( unit.getAncestors() );
+ }
+
+ if ( DisplayProperty.SHORTNAME.equals( displayProperty ) )
+ {
+ map.putAll( NameableObjectUtils.getUidShortNameMap( objects ) );
+ }
+ else // NAME
+ {
+ map.putAll( IdentifiableObjectUtils.getUidNameMap( objects ) );
+ }
- map.putAll( IdentifiableObjectUtils.getUidNameMap( unit.getAncestors() ) );
- }
}
}