use of com.khartec.waltz.model.person.Person in project waltz by khartec.
the class PersonHierarchyService method toHierarchyRecords.
private List<PersonHierarchyRecord> toHierarchyRecords(Forest<Person, String> forest) {
List<PersonHierarchyRecord> records = new LinkedList<>();
for (Node<Person, String> node : forest.getAllNodes().values()) {
List<Person> ancestors = ListUtilities.reverse(HierarchyUtilities.parents(node).stream().map(n -> n.getData()).collect(Collectors.toList()));
for (int i = 0; i < ancestors.size(); i++) {
String ancestorId = ancestors.get(i).employeeId();
String selfId = node.getData().employeeId();
PersonHierarchyRecord record = new PersonHierarchyRecord(ancestorId, selfId, i + 1);
records.add(record);
}
}
return records;
}
use of com.khartec.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.getByUserName(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).build());
changeLogService.write(ImmutableChangeLog.builder().operation(Operation.ADD).userId(userName).parentReference(EntityReference.mkRef(EntityKind.SURVEY_TEMPLATE, surveyTemplateId)).message("Survey Template: '" + command.name() + "' added").build());
return surveyTemplateId;
}
use of com.khartec.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method findForRecipient.
public List<SurveyInstance> findForRecipient(String userName) {
checkNotNull(userName, "userName cannot be null");
Person person = personDao.getByUserName(userName);
checkNotNull(person, "userName " + userName + " cannot be resolved");
return surveyInstanceDao.findForRecipient(person.id().get());
}
use of com.khartec.waltz.model.person.Person in project waltz by khartec.
the class SurveyInstanceService method saveResponse.
public boolean saveResponse(String userName, long instanceId, SurveyQuestionResponse questionResponse) {
checkNotNull(userName, "userName cannot be null");
checkNotNull(questionResponse, "questionResponse cannot be null");
Person person = personDao.getByUserName(userName);
checkNotNull(person, "userName " + userName + " cannot be resolved");
boolean isPersonInstanceRecipient = surveyInstanceRecipientDao.isPersonInstanceRecipient(person.id().get(), instanceId);
checkTrue(isPersonInstanceRecipient, "Permission denied");
SurveyInstance surveyInstance = surveyInstanceDao.getById(instanceId);
checkTrue(surveyInstance.status() == SurveyInstanceStatus.NOT_STARTED || surveyInstance.status() == SurveyInstanceStatus.IN_PROGRESS, "Survey instance cannot be updated, current status: " + surveyInstance.status());
SurveyInstanceQuestionResponse instanceQuestionResponse = ImmutableSurveyInstanceQuestionResponse.builder().surveyInstanceId(instanceId).personId(person.id().get()).lastUpdatedAt(DateTimeUtilities.nowUtc()).questionResponse(questionResponse).build();
surveyQuestionResponseDao.saveResponse(instanceQuestionResponse);
return true;
}
use of com.khartec.waltz.model.person.Person in project waltz by khartec.
the class SurveyRunService method findForRecipient.
public List<SurveyRun> findForRecipient(String userName) {
checkNotNull(userName, "userName cannot be null");
Person person = personDao.getByUserName(userName);
checkNotNull(person, "userName " + userName + " cannot be resolved");
return surveyRunDao.findForRecipient(person.id().get());
}
Aggregations