Search in sources :

Example 26 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class AssignationController method revertAssignation.

@RequestMapping(path = "/assignation/{assignationId}/revert", method = RequestMethod.PUT)
public PostResult revertAssignation(@PathVariable("assignationId") String assignationId) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    DecisionVerdict canRevert = governanceService.canRevertAssignation(assignationService.getInitiativeIdOf(UUID.fromString(assignationId)), getLoggedUser().getC1Id());
    if (canRevert == DecisionVerdict.DENIED) {
        return new PostResult("error", "revert of assignation not authorized", "");
    }
    PostResult result = assignationService.revertAssignation(UUID.fromString(assignationId), getLoggedUser().getC1Id());
    return result;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class AssignationController method approveRevertAssignation.

@RequestMapping(path = "/assignation/{assignationId}/approveRevert", method = RequestMethod.PUT)
public PostResult approveRevertAssignation(@PathVariable("assignationId") String assignationId, @RequestParam Boolean approveFlag) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    PostResult result = assignationService.approveRevertAssignation(getLoggedUser().getC1Id(), UUID.fromString(assignationId), approveFlag);
    /* update assignation state in case all receivers have approved */
    assignationService.checkRevertStatus(UUID.fromString(assignationId));
    return result;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class AssignationController method deleteAssignation.

@RequestMapping(path = "/assignation/{assignationId}/delete", method = RequestMethod.PUT)
public PostResult deleteAssignation(@PathVariable("assignationId") String assignationId) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    DecisionVerdict canDelete = governanceService.canDeleteAssignation(assignationService.getInitiativeIdOf(UUID.fromString(assignationId)), getLoggedUser().getC1Id());
    if (canDelete == DecisionVerdict.DENIED) {
        return new PostResult("error", "delete of assignation not authorized", "");
    }
    PostResult result = assignationService.deleteAssignation(UUID.fromString(assignationId), getLoggedUser().getC1Id());
    return result;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class AssignationController method openAssignation.

@RequestMapping(path = "/assignation/{assignationId}/open", method = RequestMethod.PUT)
public PostResult openAssignation(@PathVariable("assignationId") String assignationIdStr) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    UUID assignationId = UUID.fromString(assignationIdStr);
    UUID initiativeId = assignationService.findInitiativeId(assignationId);
    if (governanceService.canCreateAssignation(initiativeId, getLoggedUserId()) == DecisionVerdict.DENIED) {
        return new PostResult("error", "creation of assignation not authorized", "");
    }
    PostResult result = assignationService.openAssignation(assignationId);
    return result;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class InitiativeService method deleteTagFromInitiative.

@Transactional
public PostResult deleteTagFromInitiative(UUID initiativeId, UUID tagId) {
    Initiative initiative = initiativeRepository.findById(initiativeId);
    if (initiative == null)
        return new PostResult("error", "initiative not found", "");
    InitiativeTag tag = initiativeTagRepository.findById(tagId);
    if (tag == null)
        return new PostResult("error", "tag not found", "");
    initiative.getMeta().getTags().remove(tag);
    return new PostResult("success", "tag added to initiative", initiative.getId().toString());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) 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