use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelController method getActivityUnderCard.
@RequestMapping(path = "/activity/model/card/{cardWrapperId}", method = RequestMethod.GET)
public GetResult<Page<ActivityDto>> getActivityUnderCard(@PathVariable("cardWrapperId") String cardWrapperIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @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<Page<ActivityDto>>("error", "access denied", null);
}
return modelService.getActivityResultUnderCard(cardWrapperId, new PageRequest(page, size), onlyMessages);
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelController method countMessagesUnderSection.
@RequestMapping(path = "/initiative/{initiativeId}/model/section/{sectionId}/countMessages", method = RequestMethod.GET)
public GetResult<Long> countMessagesUnderSection(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("sectionId") String sectionIdStr, @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<Long>("error", "access denied", null);
}
return modelService.countMessagesUnderSection(sectionId);
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelController method countMessagesUnderCard.
@RequestMapping(path = "/initiative/{initiativeId}/model/card/{cardWrapperId}/countMessages", method = RequestMethod.GET)
public GetResult<Long> countMessagesUnderCard(@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<Long>("error", "access denied", null);
}
return modelService.countMessagesUnderCard(cardWrapperId, onlyMessages);
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method searchCardWrapper.
@Transactional
public GetResult<Page<ModelCardWrapperDto>> searchCardWrapper(String query, PageRequest page, UUID initiativeId) {
List<UUID> initiativeEcosystemIds = initiativeService.findAllInitiativeEcosystemIds(initiativeId);
Page<ModelCardWrapper> enititiesPage = modelCardWrapperRepository.searchBy("%" + query.toLowerCase() + "%", initiativeEcosystemIds, page);
List<ModelCardWrapperDto> cardsDtos = new ArrayList<ModelCardWrapperDto>();
for (ModelCardWrapper cardWrapper : enititiesPage.getContent()) {
List<ModelSection> inSections = modelCardWrapperRepository.findParentSections(cardWrapper.getId());
ModelCardWrapperDto cardWrapperDto = cardWrapper.toDto();
for (ModelSection section : inSections) {
cardWrapperDto.getInSections().add(section.toDto());
}
cardsDtos.add(cardWrapperDto);
}
Page<ModelCardWrapperDto> dtosPage = new PageImpl<ModelCardWrapperDto>(cardsDtos, page, enititiesPage.getNumberOfElements());
return new GetResult<Page<ModelCardWrapperDto>>("succes", "cards returned", dtosPage);
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method getModel.
@Transactional
public GetResult<ModelDto> getModel(UUID initiativeId, Integer level, UUID requestById) {
Initiative initiative = initiativeRepository.findById(initiativeId);
if (initiative == null)
return new GetResult<ModelDto>("error", "initiative not found", null);
List<ModelViewDto> viewsDto = new ArrayList<ModelViewDto>();
List<ModelView> views = initiative.getModelViews();
for (ModelView view : views) {
ModelViewDto viewDto = view.toDto();
viewDto = addViewSubElements(viewDto, view.getId(), level, requestById);
viewsDto.add(viewDto);
}
ModelDto modelDto = new ModelDto();
modelDto.setViews(viewsDto);
return new GetResult<ModelDto>("success", "model found", modelDto);
}
Aggregations