Search in sources :

Example 1 with GetResult

use of org.collectiveone.common.dto.GetResult 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 GetResult

use of org.collectiveone.common.dto.GetResult 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 GetResult

use of org.collectiveone.common.dto.GetResult 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 GetResult

use of org.collectiveone.common.dto.GetResult 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)

Example 5 with GetResult

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

the class ModelService method getActivityResultUnderCard.

@Transactional
public GetResult<Page<ActivityDto>> getActivityResultUnderCard(UUID cardWrapperId, PageRequest page, Boolean onlyMessages) {
    Page<Activity> activities = getActivityUnderCard(cardWrapperId, page, onlyMessages);
    List<ActivityDto> activityDtos = new ArrayList<ActivityDto>();
    for (Activity activity : activities.getContent()) {
        activityDtos.add(activity.toDto());
    }
    Page<ActivityDto> dtosPage = new PageImpl<ActivityDto>(activityDtos, page, activities.getNumberOfElements());
    return new GetResult<Page<ActivityDto>>("succes", "actvity returned", dtosPage);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Activity(org.collectiveone.modules.activity.Activity) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Transactional(javax.transaction.Transactional)

Aggregations

GetResult (org.collectiveone.common.dto.GetResult)29 UUID (java.util.UUID)18 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 Transactional (javax.transaction.Transactional)14 ArrayList (java.util.ArrayList)10 Initiative (org.collectiveone.modules.initiatives.Initiative)10 ActivityDto (org.collectiveone.modules.activity.dto.ActivityDto)7 PageRequest (org.springframework.data.domain.PageRequest)7 AssignationDto (org.collectiveone.modules.assignations.dto.AssignationDto)5 PageImpl (org.springframework.data.domain.PageImpl)5 Activity (org.collectiveone.modules.activity.Activity)4 InitiativeDto (org.collectiveone.modules.initiatives.dto.InitiativeDto)4 NewInitiativeDto (org.collectiveone.modules.initiatives.dto.NewInitiativeDto)4 Sort (org.springframework.data.domain.Sort)4 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)3 ModelCardWrapperDto (org.collectiveone.modules.model.dto.ModelCardWrapperDto)2 ModelViewDto (org.collectiveone.modules.model.dto.ModelViewDto)2 TransferDto (org.collectiveone.modules.tokens.dto.TransferDto)2 AppUser (org.collectiveone.modules.users.AppUser)2 Timestamp (java.sql.Timestamp)1