use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.
the class InitiativesController method deleteTagFromInitiative.
@RequestMapping(path = "/initiative/{initiativeId}/tags/{tagId}", method = RequestMethod.DELETE)
public PostResult deleteTagFromInitiative(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("tagId") String tagIdStr) {
if (getLoggedUser() == null) {
return new PostResult("error", "endpoint enabled users only", null);
}
UUID initiativeId = UUID.fromString(initiativeIdStr);
DecisionVerdict verdict = governanceService.canEdit(initiativeId, getLoggedUser().getC1Id());
if (verdict == DecisionVerdict.DENIED) {
return new PostResult("error", "not authorized", "");
}
return initiativeService.deleteTagFromInitiative(initiativeId, UUID.fromString(tagIdStr));
}
use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.
the class AssignationService method openAssignation.
@Transactional
public PostResult openAssignation(UUID assignationId) {
Assignation assignation = assignationRepository.findById(assignationId);
if (assignation.getState() == AssignationState.ON_HOLD) {
assignation.setState(AssignationState.OPEN);
assignation.getConfig().setMinClosureDate(new Timestamp(System.currentTimeMillis()));
assignation.getConfig().setMaxClosureDate(new Timestamp(System.currentTimeMillis() + assignation.getConfig().getDurationDays() * DAYS_TO_MS));
}
assignationRepository.save(assignation);
return new PostResult("success", "success", assignation.getId().toString());
}
use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.
the class AssignationService method evaluateAndUpdateAssignation.
/**
* Non-transactional to evaluate and update assignation state in different transactions
*/
public PostResult evaluateAndUpdateAssignation(UUID evaluatorAppUserId, UUID assignationId, EvaluationDto evaluationDto) {
PostResult result = evaluateAssignation(evaluatorAppUserId, assignationId, evaluationDto);
updateAssignationState(assignationId);
return result;
}
use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.
the class AssignationService method evaluateAssignation.
@Transactional
private PostResult evaluateAssignation(UUID evaluatorUserId, UUID assignationId, EvaluationDto evaluationsDto) {
Assignation assignation = assignationRepository.findById(assignationId);
Evaluator evaluator = evaluatorRepository.findByAssignationIdAndUser_C1Id(assignation.getId(), evaluatorUserId);
if (evaluator != null) {
for (EvaluationGradeDto evaluationGradeDto : evaluationsDto.getEvaluationGrades()) {
UUID receiverUserId = UUID.fromString(evaluationGradeDto.getReceiverUser().getC1Id());
EvaluationGrade grade = evaluationGradeRepository.findByAssignation_IdAndReceiver_User_C1IdAndEvaluator_User_C1Id(assignation.getId(), receiverUserId, evaluatorUserId);
grade.setPercent(evaluationGradeDto.getPercent());
grade.setType(EvaluationGradeType.valueOf(evaluationGradeDto.getType()));
grade.setState(EvaluationGradeState.DONE);
evaluationGradeRepository.save(grade);
}
evaluator.setState(EvaluatorState.DONE);
evaluatorRepository.save(evaluator);
return new PostResult("success", "evaluation saved", evaluator.getId().toString());
} else {
return new PostResult("error", "evaluator not found", "");
}
}
use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.
the class AssignationService method approveRevertAssignation.
@Transactional
public PostResult approveRevertAssignation(UUID userId, UUID assignationId, Boolean value) {
Assignation assignation = assignationRepository.findById(assignationId);
if (assignation.getState() == AssignationState.REVERT_ORDERED) {
Receiver receiver = receiverRepository.findByAssignation_IdAndUser_C1Id(assignationId, userId);
if (receiver != null) {
if (value) {
receiver.setRevertApproval(true);
receiverRepository.save(receiver);
} else {
/* a single receiver that rejects will cancel the revert */
assignation.setState(AssignationState.DONE);
activityService.assignationRevertCancelled(assignation);
}
}
return new PostResult("success", "revert of assignation approved by this receiver", "");
} else {
return new PostResult("error", "assignation not in revert, cannot be approved", "");
}
}
Aggregations