use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method getActivityResultUnderView.
@Transactional
public GetResult<Page<ActivityDto>> getActivityResultUnderView(UUID viewId, PageRequest page, Boolean onlyMessages) {
Page<Activity> activities = getActivityUnderView(viewId, 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);
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method getCardWrapper.
@Transactional
public GetResult<ModelCardWrapperDto> getCardWrapper(UUID cardWrapperId, UUID requestByUserId) {
ModelCardWrapper cardWrapper = modelCardWrapperRepository.findById(cardWrapperId);
List<ModelSection> inSections = modelCardWrapperRepository.findParentSections(cardWrapper.getId());
ModelCardWrapperDto cardWrapperDto = cardWrapper.toDto();
cardWrapperDto.setnLikes(cardLikeRepository.countOfCard(cardWrapper.getId()));
if (requestByUserId != null) {
cardWrapperDto.setUserLiked(cardLikeRepository.findByCardWrapperIdAndAuthor_c1Id(cardWrapper.getId(), requestByUserId) != null);
}
for (ModelSection section : inSections) {
cardWrapperDto.getInSections().add(section.toDto());
}
return new GetResult<ModelCardWrapperDto>("success", "card retrieved", cardWrapperDto);
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class FilesController method getFileData.
@RequestMapping(value = "/files/{fileId}", method = RequestMethod.GET)
@ResponseBody
public GetResult<FileStoredDto> getFileData(@PathVariable("fileId") String fileIdStr) {
UUID fileId = UUID.fromString(fileIdStr);
Initiative initiative = fileService.getFileInitiative(fileId);
if (initiative != null) {
if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
return new GetResult<FileStoredDto>("error", "access denied", null);
}
}
return new GetResult<FileStoredDto>("success", "file retrieved", fileService.getFileData(fileId));
}
use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.
the class InitiativesController method getInitiative.
@RequestMapping(path = "/initiative/{initiativeId}", method = RequestMethod.GET)
public GetResult<InitiativeDto> getInitiative(@PathVariable("initiativeId") String initiativeIdStr, @RequestParam(defaultValue = "false") boolean addAssetsIds, @RequestParam(defaultValue = "false") boolean addSubinitiatives, @RequestParam(defaultValue = "false") boolean addParents, @RequestParam(defaultValue = "false") boolean addMembers, @RequestParam(defaultValue = "false") boolean addLoggedUser) {
UUID initiativeId = UUID.fromString(initiativeIdStr);
if (!initiativeService.canAccess(initiativeId, getLoggedUserId())) {
return new GetResult<InitiativeDto>("error", "access denied", null);
}
InitiativeDto initiativeDto = null;
initiativeDto = initiativeService.getLight(initiativeId);
if (addAssetsIds) {
initiativeDto.setAssets(initiativeService.getInitiativeAssetsDtoLight(initiativeId));
}
if (addSubinitiatives) {
initiativeDto.setSubInitiatives(initiativeService.getSubinitiativesTree(initiativeId, null));
}
if (addParents) {
initiativeDto.setParents(initiativeService.getParentInitiativesDtos(initiativeId));
}
if (addMembers) {
initiativeDto.setInitiativeMembers(initiativeService.getMembersAndSubmembers(initiativeId));
}
if (addLoggedUser) {
initiativeDto.setLoggedMembership(initiativeService.getMemberAndInParent(initiativeId, getLoggedUserId()));
}
return new GetResult<InitiativeDto>("success", "initiative retrieved", initiativeDto);
}
Aggregations