← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22071: collect idObject.userGroupAccessses.userGroup IDs in preheater

 

------------------------------------------------------------
revno: 22071
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-02-29 11:45:21 +0700
message:
  collect idObject.userGroupAccessses.userGroup IDs in preheater
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.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/preheat/DefaultPreheatService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.java	2016-02-29 04:34:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.java	2016-02-29 04:45:21 +0000
@@ -44,6 +44,7 @@
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.user.UserGroup;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
@@ -290,9 +291,25 @@
                         }
                     } );
 
+                    if ( !uidMap.containsKey( UserGroup.class ) ) uidMap.put( UserGroup.class, new HashSet<>() );
+                    if ( !codeMap.containsKey( UserGroup.class ) ) codeMap.put( UserGroup.class, new HashSet<>() );
+
+                    object.getUserGroupAccesses().forEach( uga -> {
+                        UserGroup userGroup = uga.getUserGroup();
+
+                        if ( userGroup != null )
+                        {
+                            if ( !StringUtils.isEmpty( userGroup.getUid() ) ) uidMap.get( UserGroup.class ).add( userGroup.getUid() );
+                            if ( !StringUtils.isEmpty( userGroup.getCode() ) ) codeMap.get( UserGroup.class ).add( userGroup.getCode() );
+                        }
+                    } );
+
                     if ( uidMap.get( Attribute.class ).isEmpty() ) uidMap.remove( Attribute.class );
                     if ( codeMap.get( Attribute.class ).isEmpty() ) codeMap.remove( Attribute.class );
 
+                    if ( uidMap.get( UserGroup.class ).isEmpty() ) uidMap.remove( UserGroup.class );
+                    if ( codeMap.get( UserGroup.class ).isEmpty() ) codeMap.remove( UserGroup.class );
+
                     if ( !StringUtils.isEmpty( object.getUid() ) ) uidMap.get( objectClass ).add( object.getUid() );
                     if ( !StringUtils.isEmpty( object.getCode() ) ) codeMap.get( objectClass ).add( object.getCode() );
                 }