dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23951
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11681: Analytics, supporting USER_ORGUNIT_GRANDCHILDREN as ou dimension keyword for including user org u...
------------------------------------------------------------
revno: 11681
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-08-16 15:09:16 +0200
message:
Analytics, supporting USER_ORGUNIT_GRANDCHILDREN as ou dimension keyword for including user org unit grand children in response
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.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/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2013-08-15 11:30:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2013-08-16 13:09:16 +0000
@@ -40,6 +40,7 @@
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_ORGUNIT_GROUP;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_CHILDREN;
+import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_GRANDCHILDREN;
import java.util.ArrayList;
import java.util.Arrays;
@@ -131,6 +132,8 @@
protected boolean userOrganisationUnit;
protected boolean userOrganisationUnitChildren;
+
+ protected boolean userOrganisationUnitGrandChildren;
@Scanned
protected List<Integer> organisationUnitLevels = new ArrayList<Integer>();
@@ -175,7 +178,7 @@
public boolean hasUserOrgUnit()
{
- return userOrganisationUnit || userOrganisationUnitChildren;
+ return userOrganisationUnit || userOrganisationUnitChildren || userOrganisationUnitGrandChildren;
}
public boolean hasRelativePeriods()
@@ -276,6 +279,11 @@
items.addAll( user.getOrganisationUnit().getSortedChildren() );
}
+ if ( userOrganisationUnitGrandChildren && user != null && user.hasOrganisationUnit() )
+ {
+ items.addAll( user.getOrganisationUnit().getSortedGrandChildren() );
+ }
+
if ( organisationUnitLevels != null && !organisationUnitLevels.isEmpty() && organisationUnitsAtLevel != null )
{
items.addAll( organisationUnitsAtLevel ); // Must be set externally
@@ -419,6 +427,11 @@
ouList.add( new BaseNameableObject( KEY_USER_ORGUNIT_CHILDREN, KEY_USER_ORGUNIT_CHILDREN, KEY_USER_ORGUNIT_CHILDREN ) );
}
+ if ( userOrganisationUnitGrandChildren )
+ {
+ ouList.add( new BaseNameableObject( KEY_USER_ORGUNIT_GRANDCHILDREN, KEY_USER_ORGUNIT_GRANDCHILDREN, KEY_USER_ORGUNIT_GRANDCHILDREN ) );
+ }
+
if ( organisationUnitLevels != null && !organisationUnitLevels.isEmpty() )
{
for ( Integer level : organisationUnitLevels )
@@ -780,6 +793,19 @@
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ public boolean isUserOrganisationUnitGrandChildren()
+ {
+ return userOrganisationUnitGrandChildren;
+ }
+
+ public void setUserOrganisationUnitGrandChildren( boolean userOrganisationUnitGrandChildren )
+ {
+ this.userOrganisationUnitGrandChildren = userOrganisationUnitGrandChildren;
+ }
+
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlElementWrapper( localName = "organisationUnitLevels", namespace = DxfNamespaces.DXF_2_0)
@JacksonXmlProperty( localName = "organisationUnitLevel", namespace = DxfNamespaces.DXF_2_0)
public List<Integer> getOrganisationUnitLevels()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2013-07-04 16:05:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2013-08-16 13:09:16 +0000
@@ -75,6 +75,7 @@
public static final String KEY_USER_ORGUNIT = "USER_ORGUNIT";
public static final String KEY_USER_ORGUNIT_CHILDREN = "USER_ORGUNIT_CHILDREN";
+ public static final String KEY_USER_ORGUNIT_GRANDCHILDREN = "USER_ORGUNIT_GRANDCHILDREN";
public static final String KEY_LEVEL = "LEVEL-";
public static final String KEY_ORGUNIT_GROUP = "OU_GROUP-";
@@ -306,6 +307,18 @@
return grandChildren;
}
+
+ public List<OrganisationUnit> getSortedGrandChildren()
+ {
+ List<OrganisationUnit> grandChildren = new ArrayList<OrganisationUnit>();
+
+ for ( OrganisationUnit child : getSortedChildren() )
+ {
+ grandChildren.addAll( child.getSortedChildren() );
+ }
+
+ return grandChildren;
+ }
public boolean hasChild()
{
=== 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-08-15 11:30:31 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-08-16 13:09:16 +0000
@@ -53,6 +53,7 @@
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_ORGUNIT_GROUP;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_CHILDREN;
+import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_GRANDCHILDREN;
import static org.hisp.dhis.period.PeriodType.getPeriodTypeFromIsoString;
import static org.hisp.dhis.reporttable.ReportTable.IRT2D;
import static org.hisp.dhis.reporttable.ReportTable.addIfEmpty;
@@ -817,6 +818,10 @@
{
ous.addAll( user.getOrganisationUnit().getSortedChildren() );
}
+ else if ( KEY_USER_ORGUNIT_GRANDCHILDREN.equals( ou ) && user != null && user.getOrganisationUnit() != null )
+ {
+ ous.addAll( user.getOrganisationUnit().getSortedGrandChildren() );
+ }
else if ( ou != null && ou.startsWith( KEY_LEVEL ) )
{
int level = DataQueryParams.getLevelFromLevelParam( ou );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2013-08-15 11:30:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2013-08-16 13:09:16 +0000
@@ -41,6 +41,7 @@
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_ORGUNIT_GROUP;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_CHILDREN;
+import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_GRANDCHILDREN;
import java.util.ArrayList;
import java.util.Collection;
@@ -285,6 +286,10 @@
{
object.setUserOrganisationUnitChildren( true );
}
+ else if ( KEY_USER_ORGUNIT_GRANDCHILDREN.equals( ou ) )
+ {
+ object.setUserOrganisationUnitGrandChildren( true );
+ }
else if ( ou != null && ou.startsWith( KEY_LEVEL ) )
{
int level = DimensionalObjectUtils.getLevelFromLevelParam( ou );