use of org.collectiveone.modules.assignations.dto.AssignationDto 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;
}
use of org.collectiveone.modules.assignations.dto.AssignationDto in project CollectiveOneWebapp by CollectiveOne.
the class AssignationService method getAssignationDto.
@Transactional
public GetResult<AssignationDto> getAssignationDto(UUID assignationId, UUID userId, Boolean addAllEvaluations) {
Assignation assignation = assignationRepository.findById(assignationId);
AssignationDto assignationDto = null;
if (assignation.getType() == AssignationType.PEER_REVIEWED) {
assignationDto = getPeerReviewedAssignation(assignation.getInitiative().getId(), assignation.getId(), userId, addAllEvaluations);
} else {
assignationDto = assignation.toDto();
}
return new GetResult<AssignationDto>("success", "assignation retreived", assignationDto);
}
use of org.collectiveone.modules.assignations.dto.AssignationDto in project CollectiveOneWebapp by CollectiveOne.
the class Assignation method toDto.
public AssignationDto toDto() {
AssignationDto dto = new AssignationDto();
dto.setId(id.toString());
dto.setType(type.toString());
dto.setMotive(motive);
dto.setNotes(notes);
dto.setState(state.toString());
dto.setInitiativeId(initiative.getId().toString());
dto.setInitiativeName(initiative.getMeta().getName());
dto.setCreationDate(creationDate.getTime());
dto.setConfig(config.toDto());
for (Bill bill : bills) {
dto.getAssets().add(bill.toDto());
}
for (Receiver receiver : receivers) {
dto.getReceivers().add(receiver.toDto());
}
return dto;
}
use of org.collectiveone.modules.assignations.dto.AssignationDto in project CollectiveOneWebapp by CollectiveOne.
the class AssignationController method getAssignations.
@RequestMapping(path = "/initiative/{initiativeId}/assignations", method = RequestMethod.GET)
public GetResult<List<AssignationDto>> getAssignations(@PathVariable("initiativeId") String initiativeIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam("sortDirection") String sortDirection, @RequestParam("sortProperty") String sortProperty) {
UUID initiativeId = UUID.fromString(initiativeIdStr);
if (!initiativeService.canAccess(initiativeId, getLoggedUserId())) {
return new GetResult<List<AssignationDto>>("error", "access denied", null);
}
Sort sort = new Sort(Sort.Direction.valueOf(sortDirection), sortProperty);
return assignationService.getAssignationsOfInitiative(initiativeId, getLoggedUserId(), new PageRequest(page, size, sort));
}
use of org.collectiveone.modules.assignations.dto.AssignationDto in project CollectiveOneWebapp by CollectiveOne.
the class AssignationController method getAssignationsOfSubinitiatives.
@RequestMapping(path = "/initiative/{initiativeId}/assignationsOfSubinitiatives", method = RequestMethod.GET)
public GetResult<List<AssignationDto>> getAssignationsOfSubinitiatives(@PathVariable("initiativeId") String initiativeIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam("sortDirection") String sortDirection, @RequestParam("sortProperty") String sortProperty) {
UUID initiativeId = UUID.fromString(initiativeIdStr);
if (!initiativeService.canAccess(initiativeId, getLoggedUserId())) {
return new GetResult<List<AssignationDto>>("error", "access denied", null);
}
Sort sort = new Sort(Sort.Direction.valueOf(sortDirection), sortProperty);
return assignationService.getAssignationsOfSubinitiatives(initiativeId, getLoggedUserId(), new PageRequest(page, size, sort));
}
Aggregations