Search in sources :

Example 21 with GetResult

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);
}
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 22 with GetResult

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);
}
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 23 with GetResult

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);
}
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 24 with GetResult

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);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) UUID(java.util.UUID) ModelCardWrapperDto(org.collectiveone.modules.model.dto.ModelCardWrapperDto) Transactional(javax.transaction.Transactional)

Example 25 with GetResult

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);
}
Also used : ModelDto(org.collectiveone.modules.model.dto.ModelDto) ModelViewDto(org.collectiveone.modules.model.dto.ModelViewDto) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Initiative(org.collectiveone.modules.initiatives.Initiative) 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