use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceViewService method getPersonByUsername.
private Person getPersonByUsername(String userName) {
Person person = personDao.getActiveByUserEmail(userName);
checkNotNull(person, "userName %s cannot be resolved", userName);
return person;
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyTemplateService method findAll.
public List<SurveyTemplate> findAll(String userName) {
checkNotNull(userName, "userName cannot be null");
Person owner = personDao.getActiveByUserEmail(userName);
checkNotNull(owner, "userName " + userName + " cannot be resolved");
return surveyTemplateDao.findAll(owner.id().get());
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class InvolvementViewService method findAllByEmployeeId.
public Set<InvolvementViewItem> findAllByEmployeeId(String employeeId) {
List<Involvement> involvements = involvementService.findAllByEmployeeId(employeeId);
Set<String> employeeIds = map(involvements, Involvement::employeeId);
Set<Person> involvedPeople = personService.findByEmployeeIds(employeeIds);
Map<String, Person> peopleByEmployeeId = indexBy(involvedPeople, Person::employeeId);
return involvements.stream().map(d -> {
Person person = peopleByEmployeeId.getOrDefault(d.employeeId(), null);
if (person == null) {
return null;
}
return mkInvolvementViewItem(d, person);
}).filter(Objects::nonNull).collect(toSet());
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class UserRoleService method updateRoles.
public boolean updateRoles(String userName, String targetUserName, UpdateRolesCommand command) {
LOG.info("Updating roles for userName: {}, new roles: {}", targetUserName, command.roles());
Person person = personService.getPersonByUserId(targetUserName);
if (person == null) {
LOG.warn("{} does not exist, cannot create audit log for role updates", targetUserName);
} else {
ImmutableChangeLog logEntry = ImmutableChangeLog.builder().parentReference(mkRef(EntityKind.PERSON, person.id().get())).severity(Severity.INFORMATION).userId(userName).message(format("Roles for %s updated to %s. Comment: %s", targetUserName, sort(command.roles()), StringUtilities.ifEmpty(command.comment(), "none"))).childKind(Optional.empty()).operation(Operation.UPDATE).build();
changeLogService.write(logEntry);
}
return userRoleDao.updateRoles(targetUserName, command.roles());
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method getPermissions.
public SurveyInstancePermissions getPermissions(String userName, Long instanceId) {
Person person = personDao.getActiveByUserEmail(userName);
SurveyInstance instance = surveyInstanceDao.getById(instanceId);
SurveyRun run = surveyRunDao.getById(instance.surveyRunId());
boolean isAdmin = userRoleService.hasRole(userName, SystemRole.SURVEY_ADMIN);
boolean isParticipant = surveyInstanceRecipientDao.isPersonInstanceRecipient(person.id().get(), instanceId);
boolean isOwner = person.id().map(pid -> surveyInstanceOwnerDao.isPersonInstanceOwner(pid, instanceId) || Objects.equals(run.ownerId(), pid)).orElse(false);
boolean hasOwningRole = userRoleService.hasRole(person.email(), instance.owningRole());
boolean isLatest = instance.originalInstanceId() == null;
boolean editableStatus = instance.status() == SurveyInstanceStatus.NOT_STARTED || instance.status() == SurveyInstanceStatus.IN_PROGRESS;
return ImmutableSurveyInstancePermissions.builder().isAdmin(isAdmin).isParticipant(isParticipant).isOwner(isOwner).hasOwnerRole(hasOwningRole).isMetaEdit(isLatest && (isAdmin || isOwner || hasOwningRole)).canEdit(isLatest && isParticipant && editableStatus).build();
}
Aggregations