← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14884: minor bugfix, proper merging of dataSet + orgUnitGroup associations

 

------------------------------------------------------------
revno: 14884
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-17 11:48:57 +0700
message:
  minor bugfix, proper merging of dataSet + orgUnitGroup associations
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.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-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2014-03-24 09:51:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2014-04-17 04:48:57 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import com.google.common.collect.Maps;
 import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.common.IdentifiableObjectUtils;
 import org.hisp.dhis.dataset.DataSet;
@@ -553,8 +554,21 @@
 
     public OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet()
     {
-        Map<String, Set<String>> associationSet = organisationUnitStore.getOrganisationUnitDataSetAssocationMap();
-        associationSet.putAll( organisationUnitStore.getOrganisationUnitGroupDataSetAssocationMap() );
+        Map<String, Set<String>> associationSet = Maps.newHashMap( organisationUnitStore.getOrganisationUnitDataSetAssocationMap() );
+        Map<String, Set<String>> groupAssociationSet = organisationUnitStore.getOrganisationUnitGroupDataSetAssocationMap();
+
+        // merge maps
+        for ( String key : groupAssociationSet.keySet() )
+        {
+            if ( associationSet.containsKey( key ) )
+            {
+                associationSet.get( key ).addAll( groupAssociationSet.get( key ) );
+            }
+            else
+            {
+                associationSet.put( key, groupAssociationSet.get( key ) );
+            }
+        }
 
         filterUserDataSets( associationSet );
         filterChildOrganisationUnits( associationSet );