class UserProfilePopulator {

    public UserProfileViewModel populate(UserResource user) {
        List<OrganisationResource> organisations = organisationRestService.getAllByUserId(user.getId()).getSuccess();
        Set<OrganisationProfileViewModel> organisationViewModels = simpleMapSet(organisations, this::toOrganisationViewModel);
        String name;
        if (user.getTitle() != null) {
            name = user.getTitle() + " " + user.getName().trim();
        } else {
            name = user.getName();
        }
        return new UserProfileViewModel(name, user.getPhoneNumber(), user.getEmail(), user.getAllowMarketingEmails(), organisationViewModels, user.hasAnyRoles(MONITORING_OFFICER));
    }

}