Search in sources :

Example 1 with PostResult

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

the class ModelController method moveSectionSubsection.

@RequestMapping(path = "/initiative/{initiativeId}/model/section/{sectionId}/moveSubsection/{subsectionId}", method = RequestMethod.PUT)
public PostResult moveSectionSubsection(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("sectionId") String sectionIdStr, @PathVariable("subsectionId") String subsectionIdStr, @RequestParam(name = "onViewId", defaultValue = "") String onViewIdStr, @RequestParam(name = "onSectionId", defaultValue = "") String onSectionIdStr, @RequestParam(name = "onSubsectionId") String onSubsectionIdStr) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    if (governanceService.canEditModel(initiativeId, getLoggedUser().getC1Id()) == DecisionVerdict.DENIED) {
        return new PostResult("error", "not authorized", "");
    }
    /* dropped on view can be empty */
    UUID onViewId = onViewIdStr.equals("") ? null : UUID.fromString(onViewIdStr);
    /* dropped on section can be empty */
    UUID onSectionId = onSectionIdStr.equals("") ? null : UUID.fromString(onSectionIdStr);
    /* dropped on subsection can be empty */
    UUID onSubsectionId = onSubsectionIdStr.equals("") ? null : UUID.fromString(onSubsectionIdStr);
    return modelService.moveSubsection(UUID.fromString(sectionIdStr), UUID.fromString(subsectionIdStr), onViewId, onSectionId, onSubsectionId, getLoggedUserId());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PostResult

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

the class ModelController method moveViewSection.

@RequestMapping(path = "/initiative/{initiativeId}/model/view/{viewId}/moveSection/{sectionId}", method = RequestMethod.PUT)
public PostResult moveViewSection(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("viewId") String viewIdStr, @PathVariable("sectionId") String sectionIdStr, @RequestParam(name = "onViewSectionId", defaultValue = "") String onViewSectionIdStr, @RequestParam(name = "onSectionId", defaultValue = "") String onSectionIdStr, @RequestParam(name = "onSubsectionId", defaultValue = "") String beforeSubsectionIdStr) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    if (governanceService.canEditModel(initiativeId, getLoggedUser().getC1Id()) == DecisionVerdict.DENIED) {
        return new PostResult("error", "not authorized", "");
    }
    /* dropped on viewSection can be empty*/
    UUID onViewSectionId = onViewSectionIdStr.equals("") ? null : UUID.fromString(onViewSectionIdStr);
    /* dropped on section can be empty*/
    UUID onSectionId = onSectionIdStr.equals("") ? null : UUID.fromString(onSectionIdStr);
    /* dropped on subsection can be empty*/
    UUID onSubsectionId = beforeSubsectionIdStr.equals("") ? null : UUID.fromString(beforeSubsectionIdStr);
    return modelService.moveSection(UUID.fromString(viewIdStr), UUID.fromString(sectionIdStr), onViewSectionId, onSectionId, onSubsectionId, getLoggedUserId());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PostResult

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

the class ModelController method moveView.

@RequestMapping(path = "/initiative/{initiativeId}/model/moveView/{viewId}", method = RequestMethod.PUT)
public PostResult moveView(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("viewId") String viewIdStr, @RequestParam(name = "onViewId", defaultValue = "") String onViewIdStr) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    if (governanceService.canEditModel(initiativeId, getLoggedUser().getC1Id()) == DecisionVerdict.DENIED) {
        return new PostResult("error", "not authorized", "");
    }
    /* dropped on viewSection can be empty*/
    UUID onViewId = onViewIdStr.equals("") ? null : UUID.fromString(onViewIdStr);
    return modelService.moveView(initiativeId, UUID.fromString(viewIdStr), onViewId, getLoggedUserId());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PostResult

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

the class ModelController method setCardLike.

@RequestMapping(path = "/initiative/{initiativeId}/model/card/{cardWrapperId}/like", method = RequestMethod.PUT)
public PostResult setCardLike(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("cardWrapperId") String cardWrapperIdStr, @RequestParam("likeStatus") Boolean likeStatus) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    // UUID initiativeId = UUID.fromString(initiativeIdStr);
    UUID cardWrapperId = UUID.fromString(cardWrapperIdStr);
    Initiative initiative = modelService.getCardWrapperInitiative(cardWrapperId);
    if (!initiativeService.isMemberOfEcosystem(initiative.getId(), getLoggedUserId())) {
        return new PostResult("error", "not authorized", "");
    }
    return modelService.setLikeToCard(cardWrapperId, getLoggedUserId(), likeStatus);
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PostResult

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

the class ModelController method moveExistingCard.

@RequestMapping(path = "/initiative/{initiativeId}/model/section/{sectionId}/moveCard/{cardWrapperId}", method = RequestMethod.PUT)
public PostResult moveExistingCard(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("sectionId") String fromSectionIdStr, @PathVariable("cardWrapperId") String cardWrapperIdStr, @RequestParam(name = "onSectionId") String onSectionIdStr, @RequestParam(name = "onCardWrapperId") String onCardWrapperIdStr) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    if (governanceService.canEditModel(initiativeId, getLoggedUser().getC1Id()) == DecisionVerdict.DENIED) {
        return new PostResult("error", "not authorized", "");
    }
    /* dropped on card can be empty */
    UUID onCardWrapperID = null;
    if (!onCardWrapperIdStr.equals("")) {
        onCardWrapperID = UUID.fromString(onCardWrapperIdStr);
    }
    return modelService.moveCardWrapper(UUID.fromString(fromSectionIdStr), UUID.fromString(cardWrapperIdStr), UUID.fromString(onSectionIdStr), onCardWrapperID, getLoggedUserId());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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