private void injectExistingEntityTypeAttributeIdentifiers ( List < ? extends EntityType > entityTypes ) { Map < String , EntityType > existingEntityTypeMap = dataService . findAll ( ENTITY_TYPE_META_DATA , EntityType . class ) . collect ( toMap ( EntityType :: getId , entityType -> entityType ) ) ; entityTypes . forEach ( entityType -> { EntityType existingEntityType = existingEntityTypeMap . get ( entityType . getId ( ) ) ; if ( existingEntityType != null ) { entityType . setId ( existingEntityType . getId ( ) ) ; Map < String , Attribute > existingAttrs = stream ( existingEntityType . getOwnAllAttributes ( ) ) . collect ( toMap ( Attribute :: getName , Function . identity ( ) ) ) ; entityType . getOwnAllAttributes ( ) . forEach ( attr -> { Attribute existingAttr = existingAttrs . get ( attr . getName ( ) ) ; if ( existingAttr != null ) { // inject existing attribute identifier attr . setIdentifier ( existingAttr . getIdentifier ( ) ) ; } } ) ; } } ) ; }
Inject existing attribute identifiers in system entity types