Search in sources :

Example 1 with EvaluationGradeDto

use of org.collectiveone.modules.assignations.dto.EvaluationGradeDto 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", "");
    }
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) EvaluationGradeDto(org.collectiveone.modules.assignations.dto.EvaluationGradeDto) PeerReviewedAssignation(org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation) UUID(java.util.UUID) Transactional(javax.transaction.Transactional)

Example 2 with EvaluationGradeDto

use of org.collectiveone.modules.assignations.dto.EvaluationGradeDto in project CollectiveOneWebapp by CollectiveOne.

the class EvaluationGrade method toDto.

public EvaluationGradeDto toDto() {
    EvaluationGradeDto dto = new EvaluationGradeDto();
    dto.setId(id.toString());
    if (evaluator != null)
        dto.setEvaluatorUser(evaluator.getUser().toDtoLight());
    if (receiver != null)
        dto.setReceiverUser(receiver.getUser().toDtoLight());
    if (type != null)
        dto.setType(type.toString());
    if (state != null)
        dto.setState(state.toString());
    dto.setPercent(percent);
    return dto;
}
Also used : EvaluationGradeDto(org.collectiveone.modules.assignations.dto.EvaluationGradeDto)

Aggregations

EvaluationGradeDto (org.collectiveone.modules.assignations.dto.EvaluationGradeDto)2 UUID (java.util.UUID)1 Transactional (javax.transaction.Transactional)1 PostResult (org.collectiveone.common.dto.PostResult)1 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)1