Search in sources :

Example 1 with Initiative

use of org.collectiveone.modules.initiatives.Initiative in project CollectiveOneWebapp by CollectiveOne.

the class ModelController method getActivityUnderView.

@RequestMapping(path = "/activity/model/view/{viewId}", method = RequestMethod.GET)
public GetResult<Page<ActivityDto>> getActivityUnderView(@PathVariable("viewId") String viewIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam(name = "onlyMessages", defaultValue = "false") Boolean onlyMessages) {
    UUID viewId = UUID.fromString(viewIdStr);
    Initiative initiative = modelService.getViewInitiative(viewId);
    if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
        return new GetResult<Page<ActivityDto>>("error", "access denied", null);
    }
    return modelService.getActivityResultUnderView(viewId, new PageRequest(page, size), onlyMessages);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) UUID(java.util.UUID) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Initiative

use of org.collectiveone.modules.initiatives.Initiative in project CollectiveOneWebapp by CollectiveOne.

the class ModelController method countCardLikes.

@RequestMapping(path = "/initiative/{initiativeId}/model/card/{cardWrapperId}/countLikes", method = RequestMethod.GET)
public GetResult<Integer> countCardLikes(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("cardWrapperId") String cardWrapperIdStr, @RequestParam(name = "onlyMessages", defaultValue = "false") Boolean onlyMessages) {
    UUID cardWrapperId = UUID.fromString(cardWrapperIdStr);
    Initiative initiative = modelService.getCardWrapperInitiative(cardWrapperId);
    if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
        return new GetResult<Integer>("error", "access denied", null);
    }
    return modelService.countCardLikes(cardWrapperId);
}
Also used : GetResult(org.collectiveone.common.dto.GetResult) UUID(java.util.UUID) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Initiative

use of org.collectiveone.modules.initiatives.Initiative in project CollectiveOneWebapp by CollectiveOne.

the class ModelController method countMessagesUnderView.

@RequestMapping(path = "/initiative/{initiativeId}/model/view/{viewId}/countMessages", method = RequestMethod.GET)
public GetResult<Long> countMessagesUnderView(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("viewId") String viewIdStr, @RequestParam(name = "onlyMessages", defaultValue = "false") Boolean onlyMessages) {
    UUID viewId = UUID.fromString(viewIdStr);
    Initiative initiative = modelService.getViewInitiative(viewId);
    if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
        return new GetResult<Long>("error", "access denied", null);
    }
    return modelService.countMessagesUnderView(viewId);
}
Also used : GetResult(org.collectiveone.common.dto.GetResult) UUID(java.util.UUID) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Initiative

use of org.collectiveone.modules.initiatives.Initiative 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 Initiative

use of org.collectiveone.modules.initiatives.Initiative in project CollectiveOneWebapp by CollectiveOne.

the class ModelController method getActivityUnderSection.

@RequestMapping(path = "/activity/model/section/{sectionId}", method = RequestMethod.GET)
public GetResult<Page<ActivityDto>> getActivityUnderSection(@PathVariable("sectionId") String sectionIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam(name = "onlyMessages", defaultValue = "false") Boolean onlyMessages) {
    UUID sectionId = UUID.fromString(sectionIdStr);
    Initiative initiative = modelService.getSectionInitiative(sectionId);
    if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
        return new GetResult<Page<ActivityDto>>("error", "access denied", null);
    }
    return modelService.getActivityResultUnderSection(sectionId, new PageRequest(page, size), onlyMessages);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) UUID(java.util.UUID) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Initiative (org.collectiveone.modules.initiatives.Initiative)32 Transactional (javax.transaction.Transactional)15 UUID (java.util.UUID)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 PostResult (org.collectiveone.common.dto.PostResult)11 GetResult (org.collectiveone.common.dto.GetResult)10 ArrayList (java.util.ArrayList)4 TransferDto (org.collectiveone.modules.tokens.dto.TransferDto)4 ActivityDto (org.collectiveone.modules.activity.dto.ActivityDto)3 PageRequest (org.springframework.data.domain.PageRequest)3 Email (com.sendgrid.Email)2 Personalization (com.sendgrid.Personalization)2 Timestamp (java.sql.Timestamp)2 Assignation (org.collectiveone.modules.assignations.Assignation)2 ModelCardWrapper (org.collectiveone.modules.model.ModelCardWrapper)2 ModelSection (org.collectiveone.modules.model.ModelSection)2 ModelView (org.collectiveone.modules.model.ModelView)2 TokenMint (org.collectiveone.modules.tokens.TokenMint)2 TokenType (org.collectiveone.modules.tokens.TokenType)2 AssetsDto (org.collectiveone.modules.tokens.dto.AssetsDto)2