use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyRunService method validateUser.
private Person validateUser(String userName) {
Person owner = personDao.getActiveByUserEmail(userName);
checkNotNull(owner, "userName " + userName + " cannot be resolved");
return owner;
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class SurveyTemplateEndpoint method ensureUserIsOwnerOrAdmin.
private void ensureUserIsOwnerOrAdmin(Request request, Long templateId, String username) {
Person person = personService.getPersonByUserId(username);
if (person == null) {
throw new IllegalArgumentException("User not found");
}
SurveyTemplate template = surveyTemplateService.getById(templateId);
// if person record found id is always present
person.id().ifPresent(id -> {
if (template.ownerId().equals(id)) {
WebUtilities.requireRole(userRoleService, request, SystemRole.SURVEY_TEMPLATE_ADMIN);
} else {
WebUtilities.requireRole(userRoleService, request, SystemRole.ADMIN);
}
});
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class UserContributionService method findScoresForDirectReports.
public List<Tally<String>> findScoresForDirectReports(String userId) {
checkNotEmpty(userId, "userId cannot be empty");
Person person = personDao.getByUserEmail(userId);
if (person == null) {
return Collections.emptyList();
}
List<Person> directs = personDao.findDirectsByEmployeeId(person.employeeId());
List<String> directUserIds = map(directs, p -> p.userId());
return changeLogDao.getContributionScoresForUsers(directUserIds);
}
use of org.finos.waltz.model.person.Person in project waltz by khartec.
the class AttestationInstanceEndpoint method register.
@Override
public void register() {
String attestInstancePath = mkPath(BASE_URL, "attest", ":id");
String attestEntityForUserPath = mkPath(BASE_URL, "attest-entity");
String findByEntityRefPath = mkPath(BASE_URL, "entity", ":kind", ":id");
String findByRunIdPath = mkPath(BASE_URL, "run", ":id");
String findUnattestedByUserPath = mkPath(BASE_URL, "unattested", "user");
String findAllByUserPath = mkPath(BASE_URL, "all", "user");
String findHistoricalForPendingByUserPath = mkPath(BASE_URL, "historical", "user");
String findPersonsByInstancePath = mkPath(BASE_URL, ":id", "person");
String findBySelectorPath = mkPath(BASE_URL, "selector");
String findLatestMeasurableAttestationsPath = mkPath(BASE_URL, "latest", "measurable-category", "entity", ":kind", ":id");
String findApplicationAttestationInstancesForKindAndSelectorPath = mkPath(BASE_URL, "applications", "attested-entity", ":kind", ":id");
String findApplicationAttestationSummaryForSelectorPath = mkPath(BASE_URL, "app-summary");
String cleanupOrphansPath = mkPath(BASE_URL, "cleanup-orphans");
String reassignRecipientsPath = mkPath(BASE_URL, "reassign-recipients");
String getCountsOfRecipientsToReassignPath = mkPath(BASE_URL, "reassign-counts");
DatumRoute<Boolean> attestInstanceRoute = (req, res) -> attestationInstanceService.attestInstance(getId(req), getUsername(req));
ListRoute<AttestationInstance> findByEntityRefRoute = (req, res) -> attestationInstanceService.findByEntityReference(getEntityReference(req));
ListRoute<AttestationInstance> findUnattestedByRecipientRoute = (req, res) -> attestationInstanceService.findByRecipient(getUsername(req), true);
ListRoute<AttestationInstance> findAllByRecipientRoute = (req, res) -> attestationInstanceService.findByRecipient(getUsername(req), false);
ListRoute<AttestationInstance> findHistoricalForPendingByRecipientRoute = (req, res) -> attestationInstanceService.findHistoricalForPendingByUserId(getUsername(req));
ListRoute<AttestationInstance> findByRunIdRoute = (req, res) -> attestationInstanceService.findByRunId(getId(req));
ListRoute<Person> findPersonsByInstanceRoute = (request, response) -> {
long id = Long.valueOf(request.params("id"));
return attestationInstanceService.findPersonsByInstanceId(id);
};
ListRoute<AttestationInstance> findBySelectorRoute = ((request, response) -> attestationInstanceService.findByIdSelector(readIdSelectionOptionsFromBody(request)));
ListRoute<LatestMeasurableAttestationInfo> findLatestMeasurableAttestationsRoute = ((request, response) -> attestationInstanceService.findLatestMeasurableAttestations(getEntityReference(request)));
ListRoute<ApplicationAttestationInstanceSummary> findApplicationAttestationInstancesForKindAndSelectorRoute = ((request, response) -> {
EntityKind attestedKind = getKind(request);
Long attestedId = StringUtilities.parseLong(request.params("id"), null);
ApplicationAttestationInstanceInfo applicationAttestationInstanceInfo = readBody(request, ApplicationAttestationInstanceInfo.class);
return attestationInstanceService.findApplicationAttestationInstancesForKindAndSelector(attestedKind, attestedId, applicationAttestationInstanceInfo);
});
ListRoute<ApplicationAttestationSummaryCounts> findApplicationAttestationSummaryForSelectorRoute = ((request, response) -> attestationInstanceService.findAttestationInstanceSummaryForSelector(readBody(request, ApplicationAttestationInstanceInfo.class)));
DatumRoute<Boolean> attestEntityForUserRoute = (req, res) -> attestationInstanceService.attestForEntity(getUsername(req), readCreateCommand(req));
postForDatum(attestInstancePath, attestInstanceRoute);
postForDatum(attestEntityForUserPath, attestEntityForUserRoute);
getForList(findByEntityRefPath, findByEntityRefRoute);
getForList(findUnattestedByUserPath, findUnattestedByRecipientRoute);
getForList(findAllByUserPath, findAllByRecipientRoute);
getForList(findHistoricalForPendingByUserPath, findHistoricalForPendingByRecipientRoute);
getForList(findByRunIdPath, findByRunIdRoute);
getForList(findPersonsByInstancePath, findPersonsByInstanceRoute);
getForList(findLatestMeasurableAttestationsPath, findLatestMeasurableAttestationsRoute);
postForList(findBySelectorPath, findBySelectorRoute);
postForList(findApplicationAttestationInstancesForKindAndSelectorPath, findApplicationAttestationInstancesForKindAndSelectorRoute);
postForList(findApplicationAttestationSummaryForSelectorPath, findApplicationAttestationSummaryForSelectorRoute);
getForDatum(cleanupOrphansPath, this::cleanupOrphansRoute);
postForDatum(reassignRecipientsPath, this::reassignRecipientsRoute);
getForDatum(getCountsOfRecipientsToReassignPath, this::getCountsOfRecipientsToReassign);
}
use of org.finos.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(Node::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;
}
Aggregations