← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9963: added new method to OrganisationUnit, getAllDataSets - return data-sets from both OU and all OU-g...

 

------------------------------------------------------------
revno: 9963
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-03-04 16:07:51 +0300
message:
  added new method to OrganisationUnit, getAllDataSets - return data-sets from both OU and all OU-groups
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.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/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2013-02-28 15:20:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2013-03-04 13:07:51 +0000
@@ -524,8 +524,8 @@
         return set;
     }
 
-    @JsonProperty("level")
-    @JacksonXmlProperty(localName = "level", isAttribute = true)
+    @JsonProperty( "level" )
+    @JacksonXmlProperty( localName = "level", isAttribute = true )
     public int getOrganisationUnitLevel()
     {
         int currentLevel = 1;
@@ -566,6 +566,18 @@
         return builder.toString();
     }
 
+    public Set<DataSet> getAllDataSets()
+    {
+        Set<DataSet> allDataSets = new HashSet<DataSet>( dataSets );
+
+        for ( OrganisationUnitGroup organisationUnitGroup : groups )
+        {
+            allDataSets.addAll( organisationUnitGroup.getDataSets() );
+        }
+
+        return allDataSets;
+    }
+
     // -------------------------------------------------------------------------
     // hashCode, equals and toString
     // -------------------------------------------------------------------------
@@ -836,10 +848,10 @@
     }
 
     @JsonProperty
-    @JsonSerialize(contentAs = BaseIdentifiableObject.class)
-    @JsonView({ DetailedView.class })
-    @JacksonXmlElementWrapper(localName = "dataSets", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty(localName = "dataSet", namespace = DxfNamespaces.DXF_2_0)
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class } )
+    @JacksonXmlElementWrapper( localName = "dataSets", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 )
     public Set<DataSet> getDataSets()
     {
         return dataSets;