use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceViewService method findForUser.
public Set<SurveyInstanceUserInvolvement> findForUser(String userName) {
checkNotNull(userName, "userName cannot be null");
Person person = getPersonByUsername(userName);
Set<SurveyInstanceInfo> surveysOwned = surveyViewDao.findForOwner(person.id().get());
Set<SurveyInstanceInfo> surveysAssigned = surveyViewDao.findForRecipient(person.id().get());
return asSet(ImmutableSurveyInstanceUserInvolvement.builder().surveyInvolvementKind(SurveyInvolvementKind.OWNER).surveyInstances(surveysOwned).build(), ImmutableSurveyInstanceUserInvolvement.builder().surveyInvolvementKind(SurveyInvolvementKind.RECIPIENT).surveyInstances(surveysAssigned).build());
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyTemplateService method create.
public long create(String userName, SurveyTemplateChangeCommand command) {
checkNotNull(userName, "userName cannot be null");
checkNotNull(command, "command cannot be null");
Person owner = personDao.getActiveByUserEmail(userName);
checkNotNull(owner, "userName " + userName + " cannot be resolved");
long surveyTemplateId = surveyTemplateDao.create(ImmutableSurveyTemplate.builder().name(command.name()).description(command.description()).targetEntityKind(command.targetEntityKind()).ownerId(owner.id().get()).createdAt(DateTimeUtilities.nowUtc()).status(ReleaseLifecycleStatus.DRAFT).externalId(command.externalId()).build());
changeLogService.write(ImmutableChangeLog.builder().operation(Operation.ADD).userId(userName).parentReference(EntityReference.mkRef(EntityKind.SURVEY_TEMPLATE, surveyTemplateId)).message(format("Survey Template: '%s' added", command.name())).build());
return surveyTemplateId;
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method getPersonById.
private Person getPersonById(Long id) {
Person person = personDao.getById(id);
checkNotNull(person, "Person with id %d cannot be resolved", id);
return person;
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService 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 SurveyInstanceService method checkPersonIsRecipientOrOwnerOrAdmin.
public Person checkPersonIsRecipientOrOwnerOrAdmin(String userName, long instanceId) {
Person person = getPersonByUsername(userName);
boolean isPersonInstanceRecipient = surveyInstanceRecipientDao.isPersonInstanceRecipient(person.id().get(), instanceId);
checkTrue(isPersonInstanceRecipient || isAdmin(userName) || isOwner(instanceId, person) || hasOwningRole(instanceId, person), "Permission denied");
return person;
}
Aggregations