Search in sources :

Example 16 with PostResult

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));
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with PostResult

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());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) PeerReviewedAssignation(org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation) Timestamp(java.sql.Timestamp) Transactional(javax.transaction.Transactional)

Example 18 with PostResult

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;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult)

Example 19 with PostResult

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", "");
    }
}
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 20 with PostResult

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

Aggregations

PostResult (org.collectiveone.common.dto.PostResult)47 Transactional (javax.transaction.Transactional)28 UUID (java.util.UUID)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 Initiative (org.collectiveone.modules.initiatives.Initiative)11 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)7 DecisionVerdict (org.collectiveone.modules.governance.DecisionVerdict)5 AppUser (org.collectiveone.modules.users.AppUser)5 Timestamp (java.sql.Timestamp)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 FileStored (org.collectiveone.modules.files.FileStored)3 TokenType (org.collectiveone.modules.tokens.TokenType)3 DecisionMaker (org.collectiveone.modules.governance.DecisionMaker)2 ModelSectionDto (org.collectiveone.modules.model.dto.ModelSectionDto)2 TokenMint (org.collectiveone.modules.tokens.TokenMint)2 ArrayList (java.util.ArrayList)1 WantToContributeNotification (org.collectiveone.modules.activity.WantToContributeNotification)1 BillDto (org.collectiveone.modules.assignations.dto.BillDto)1 EvaluationGradeDto (org.collectiveone.modules.assignations.dto.EvaluationGradeDto)1