=== 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-26 10:05:22 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.java 2016-02-29 04:34:34 +0000 @@ -29,6 +29,7 @@ */ import com.google.common.collect.Lists; +import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.common.MergeMode; @@ -276,6 +277,22 @@ } } + if ( !uidMap.containsKey( Attribute.class ) ) uidMap.put( Attribute.class, new HashSet<>() ); + if ( !codeMap.containsKey( Attribute.class ) ) codeMap.put( Attribute.class, new HashSet<>() ); + + object.getAttributeValues().forEach( av -> { + Attribute attribute = av.getAttribute(); + + if ( attribute != null ) + { + if ( !StringUtils.isEmpty( attribute.getUid() ) ) uidMap.get( Attribute.class ).add( attribute.getUid() ); + if ( !StringUtils.isEmpty( attribute.getCode() ) ) codeMap.get( Attribute.class ).add( attribute.getCode() ); + } + } ); + + if ( uidMap.get( Attribute.class ).isEmpty() ) uidMap.remove( Attribute.class ); + if ( codeMap.get( Attribute.class ).isEmpty() ) codeMap.remove( Attribute.class ); + if ( !StringUtils.isEmpty( object.getUid() ) ) uidMap.get( objectClass ).add( object.getUid() ); if ( !StringUtils.isEmpty( object.getCode() ) ) codeMap.get( objectClass ).add( object.getCode() ); }