Search in sources :

Example 26 with GetResult

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

Example 27 with GetResult

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);
}
Also used : GetResult(org.collectiveone.common.dto.GetResult) ModelCardWrapperDto(org.collectiveone.modules.model.dto.ModelCardWrapperDto) Transactional(javax.transaction.Transactional)

Example 28 with GetResult

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));
}
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) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 29 with GetResult

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);
}
Also used : GetResult(org.collectiveone.common.dto.GetResult) InitiativeDto(org.collectiveone.modules.initiatives.dto.InitiativeDto) NewInitiativeDto(org.collectiveone.modules.initiatives.dto.NewInitiativeDto) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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