=== 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-23 10:38:41 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.java 2016-02-23 10:58:58 +0000 @@ -31,7 +31,6 @@ import com.google.common.collect.Lists; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.query.Query; import org.hisp.dhis.query.QueryService; import org.hisp.dhis.query.Restrictions; @@ -41,6 +40,7 @@ import org.hisp.dhis.schema.SchemaService; import org.hisp.dhis.system.util.ReflectionUtils; import org.hisp.dhis.user.User; +import org.hisp.dhis.user.UserCredentials; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; @@ -199,31 +199,35 @@ return map; } - for ( Class objectClass : objects.keySet() ) + Map, List> scanObjects = new HashMap<>(); + scanObjects.putAll( objects ); // clone objects list, we don't want to modify it + + if ( scanObjects.containsKey( User.class ) ) + { + List users = scanObjects.get( User.class ); + List userCredentials = new ArrayList<>(); + + for ( IdentifiableObject identifiableObject : users ) + { + User user = (User) identifiableObject; + + if ( user.getUserCredentials() != null ) + { + userCredentials.add( user.getUserCredentials() ); + } + } + + scanObjects.put( UserCredentials.class, userCredentials ); + } + + for ( Class objectClass : scanObjects.keySet() ) { Schema schema = schemaService.getDynamicSchema( objectClass ); List properties = schema.getProperties().stream() .filter( p -> p.isPersisted() && p.isOwner() && (PropertyType.REFERENCE == p.getPropertyType() || PropertyType.REFERENCE == p.getItemPropertyType()) ) .collect( Collectors.toList() ); - List identifiableObjects = objects.get( objectClass ); - - if ( User.class.isAssignableFrom( objectClass ) ) - { - List userCredentials = new ArrayList<>(); - - for ( IdentifiableObject identifiableObject : identifiableObjects ) - { - User user = (User) identifiableObject; - - if ( user.getUserCredentials() != null ) - { - userCredentials.add( user.getUserCredentials() ); - } - } - - // identifiableObjects.addAll( userCredentials ); - } + List identifiableObjects = scanObjects.get( objectClass ); if ( !uidMap.containsKey( objectClass ) ) uidMap.put( objectClass, new HashSet<>() ); if ( !codeMap.containsKey( objectClass ) ) codeMap.put( objectClass, new HashSet<>() );