use of org.collectiveone.modules.assignations.dto.EvaluationDto in project CollectiveOneWebapp by CollectiveOne.
the class AssignationService method getPeerReviewedAssignation.
@Transactional
public AssignationDto getPeerReviewedAssignation(UUID initiativeId, UUID assignationId, UUID evaluatorAppUserId, Boolean addAllEvaluations) {
Assignation assignation = assignationRepository.findById(assignationId);
AssignationDto assignationDto = assignation.toDto();
/* add the evaluations of logged user */
Evaluator evaluator = evaluatorRepository.findByAssignationIdAndUser_C1Id(assignation.getId(), evaluatorAppUserId);
assignationDto.setEvaluationsPending(evaluatorRepository.countByAssignationIdAndState(assignation.getId(), EvaluatorState.PENDING));
if (evaluator != null) {
EvaluationDto evaluation = new EvaluationDto();
evaluation.setId(evaluator.getId().toString());
evaluation.setEvaluationState(evaluator.getState().toString());
for (EvaluationGrade grade : evaluator.getGrades()) {
evaluation.getEvaluationGrades().add(grade.toDto());
}
assignationDto.setThisEvaluation(evaluation);
}
/* add individual biases */
if (assignation.getConfig().getSelfBiasVisible()) {
if (assignation.getState() == AssignationState.DONE) {
for (Receiver receiver : assignation.getReceivers()) {
EvaluationGrade selfEvaluation = evaluationGradeRepository.findByAssignation_IdAndReceiver_User_C1IdAndEvaluator_User_C1Id(assignation.getId(), receiver.getUser().getC1Id(), receiver.getUser().getC1Id());
if (selfEvaluation != null) {
/* fill the receivers dtos selfBias */
for (ReceiverDto receiverDto : assignationDto.getReceivers()) {
if (receiverDto.getUser().getC1Id().equals(receiver.getUser().getC1Id().toString())) {
if (selfEvaluation.getState() == EvaluationGradeState.DONE) {
if (selfEvaluation.getType() == EvaluationGradeType.SET) {
receiverDto.setSelfBias(selfEvaluation.getPercent() - receiverDto.getEvaluatedPercent());
} else {
receiverDto.setSelfBias(999.9);
}
} else {
receiverDto.setSelfBias(999.9);
}
}
}
}
}
}
}
/* add all the evaluations */
if (addAllEvaluations) {
if (assignation.getConfig().getEvaluationsVisible()) {
if (assignation.getState() == AssignationState.DONE) {
for (Evaluator thisEvaluator : assignation.getEvaluators()) {
assignationDto.getEvaluators().add(thisEvaluator.toDto());
}
}
}
}
return assignationDto;
}
Aggregations