Search in sources :

Example 1 with Person

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;
}
Also used : PersonHierarchyRecord(com.khartec.waltz.schema.tables.records.PersonHierarchyRecord) Person(com.khartec.waltz.model.person.Person) LinkedList(java.util.LinkedList)

Example 2 with Person

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;
}
Also used : Person(com.khartec.waltz.model.person.Person)

Example 3 with Person

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());
}
Also used : Person(com.khartec.waltz.model.person.Person)

Example 4 with Person

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;
}
Also used : Person(com.khartec.waltz.model.person.Person)

Example 5 with Person

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());
}
Also used : Person(com.khartec.waltz.model.person.Person)

Aggregations

Person (com.khartec.waltz.model.person.Person)12 PersonDao (com.khartec.waltz.data.person.PersonDao)2 SurveyTemplateDao (com.khartec.waltz.data.survey.SurveyTemplateDao)2 com.khartec.waltz.model.survey (com.khartec.waltz.model.survey)2 LocalDate (java.time.LocalDate)2 Record1 (org.jooq.Record1)2 Select (org.jooq.Select)2 ArrayUtilities (com.khartec.waltz.common.ArrayUtilities)1 Checks.checkFalse (com.khartec.waltz.common.Checks.checkFalse)1 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)1 Checks.checkTrue (com.khartec.waltz.common.Checks.checkTrue)1 CollectionUtilities.isEmpty (com.khartec.waltz.common.CollectionUtilities.isEmpty)1 CollectionUtilities.randomPick (com.khartec.waltz.common.CollectionUtilities.randomPick)1 DateTimeUtilities.nowUtc (com.khartec.waltz.common.DateTimeUtilities.nowUtc)1 SetUtilities.fromCollection (com.khartec.waltz.common.SetUtilities.fromCollection)1 IdSelectorFactory (com.khartec.waltz.data.IdSelectorFactory)1 IdSelectorFactoryProvider (com.khartec.waltz.data.IdSelectorFactoryProvider)1 AppGroupDao (com.khartec.waltz.data.app_group.AppGroupDao)1 InvolvementDao (com.khartec.waltz.data.involvement.InvolvementDao)1 InvolvementKindDao (com.khartec.waltz.data.involvement_kind.InvolvementKindDao)1