Search in sources :

Example 6 with Person

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

Example 7 with Person

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

Example 8 with Person

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

Example 9 with 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;
}
Also used : Person(org.finos.waltz.model.person.Person)

Example 10 with 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;
}
Also used : Person(org.finos.waltz.model.person.Person)

Aggregations

Person (org.finos.waltz.model.person.Person)34 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Service (org.springframework.stereotype.Service)5 LocalDate (java.time.LocalDate)4 java.util (java.util)4 PersonDao (org.finos.waltz.data.person.PersonDao)4 EntityKind (org.finos.waltz.model.EntityKind)4 org.finos.waltz.model.survey (org.finos.waltz.model.survey)4 Record1 (org.jooq.Record1)4 Select (org.jooq.Select)4 Collectors (java.util.stream.Collectors)3 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)3 ListUtilities.map (org.finos.waltz.common.ListUtilities.map)3 MapUtilities.indexBy (org.finos.waltz.common.MapUtilities.indexBy)3 ImmutableChangeLog (org.finos.waltz.model.changelog.ImmutableChangeLog)3 IOException (java.io.IOException)2 List (java.util.List)2 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)2 Collectors.toList (java.util.stream.Collectors.toList)2 Checks.checkTrue (org.finos.waltz.common.Checks.checkTrue)2