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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations