class RepositoryUserService implements UserService {

    List<UserData> initializeThumbnailPhotos(@NonNull List<UserData> userData) {
        var uninitializedUserIds = userData.stream()
                .filter(Predicate.not(UserData::isPictureInitialized))
                .map(data -> data.getUser().getId())
                .collect(Collectors.toList());

        var userIdDataMap = userData.stream()
                .collect(Collectors.toMap(
                            data -> data.getUser().getId(),
                            Function.identity()
                        ));

        var idPhotoMap = ldapAdapter.getThumbnailPhotos(uninitializedUserIds);
        var newlyInitialized = uninitializedUserIds.stream()
                .map(userId -> {
                    var thumbnailPhoto = idPhotoMap.get(userId);
                    var uninitialized = userIdDataMap.get(userId);
                    return copyAndSetThumbnailPhoto(uninitialized, thumbnailPhoto);
                })
                .collect(Collectors.toList());

        var allData = new ArrayList<>(userData);

        dataRepo.saveAll(newlyInitialized)
                .forEach(newlyInit -> {
                    var newlyInitializedUserId = newlyInit.getUser().getId();
                    var uninitializedIndex = allData.indexOf(userIdDataMap.get(newlyInitializedUserId));

                    allData.set(uninitializedIndex, newlyInit);
                });

        return allData;
    }

    public  RepositoryUserService(UserRepository userRepo,
                                 UserDataRepository dataRepo,
                                 LdapAdapter ldapAdapter,
                                 HierarchyTreeNodeRepository hierarchyTreeNodeRepo,
                                 HibernateSearchService hibernateSearchService);

}