use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method findForRecipient.
public Set<SurveyInstance> findForRecipient(String userName) {
checkNotNull(userName, "userName cannot be null");
Person person = getPersonByUsername(userName);
return surveyInstanceDao.findForRecipient(person.id().get());
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method checkPersonIsOwnerOrAdmin.
public Person checkPersonIsOwnerOrAdmin(String userName, long instanceId) {
Person person = getPersonByUsername(userName);
checkTrue(isAdmin(userName) || isOwner(instanceId, person) || hasOwningRole(instanceId, person), "Permission denied");
return person;
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method checkPersonIsRecipient.
public Person checkPersonIsRecipient(String userName, long instanceId) {
Person person = getPersonByUsername(userName);
boolean isPersonInstanceRecipient = surveyInstanceRecipientDao.isPersonInstanceRecipient(person.id().get(), instanceId);
checkTrue(isPersonInstanceRecipient, "Permission denied");
return person;
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyRunService method generateSurveyInstanceRecipients.
public List<SurveyInstanceRecipient> generateSurveyInstanceRecipients(InstancesAndRecipientsCreateCommand command) {
SurveyRun surveyRun = surveyRunDao.getById(command.surveyRunId());
checkNotNull(surveyRun, "surveyRun " + command.surveyRunId() + " not found");
SurveyTemplate surveyTemplate = surveyTemplateDao.getById(surveyRun.surveyTemplateId());
checkNotNull(surveyTemplate, "surveyTemplate " + surveyRun.surveyTemplateId() + " not found");
GenericSelector genericSelector = genericSelectorFactory.applyForKind(surveyTemplate.targetEntityKind(), surveyRun.selectionOptions());
Map<EntityReference, List<Person>> entityRefToPeople = involvementDao.findPeopleByEntitySelectorAndInvolvement(surveyTemplate.targetEntityKind(), genericSelector.selector(), surveyRun.involvementKindIds());
return entityRefToPeople.entrySet().stream().flatMap(e -> e.getValue().stream().map(p -> ImmutableSurveyInstanceRecipient.builder().surveyInstance(ImmutableSurveyInstance.builder().surveyEntity(e.getKey()).surveyRunId(surveyRun.id().get()).status(SurveyInstanceStatus.NOT_STARTED).dueDate(command.dueDate()).approvalDueDate(command.approvalDueDate()).owningRole(command.owningRole()).build()).person(p).build())).distinct().collect(toList());
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyRunService method validateSurveyRunUpdate.
private void validateSurveyRunUpdate(String userName, long surveyRunId) {
Person owner = validateUser(userName);
SurveyRun surveyRun = validateSurveyRun(surveyRunId);
checkTrue(Objects.equals(surveyRun.ownerId(), owner.id().get()), "Permission denied");
checkTrue(surveyRun.status() == SurveyRunStatus.DRAFT, "survey run can only be updated when it's still in DRAFT mode");
}
Aggregations