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