Search in sources :

Example 11 with GetResult

use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.

the class AssignationService method getAssignationDto.

@Transactional
public GetResult<AssignationDto> getAssignationDto(UUID assignationId, UUID userId, Boolean addAllEvaluations) {
    Assignation assignation = assignationRepository.findById(assignationId);
    AssignationDto assignationDto = null;
    if (assignation.getType() == AssignationType.PEER_REVIEWED) {
        assignationDto = getPeerReviewedAssignation(assignation.getInitiative().getId(), assignation.getId(), userId, addAllEvaluations);
    } else {
        assignationDto = assignation.toDto();
    }
    return new GetResult<AssignationDto>("success", "assignation retreived", assignationDto);
}
Also used : AssignationDto(org.collectiveone.modules.assignations.dto.AssignationDto) GetResult(org.collectiveone.common.dto.GetResult) PeerReviewedAssignation(org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation) Transactional(javax.transaction.Transactional)

Example 12 with GetResult

use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.

the class InitiativeService method getActivityUnderInitiative.

@Transactional
public GetResult<Page<ActivityDto>> getActivityUnderInitiative(UUID initiativeId, PageRequest page, Boolean onlyMessages) {
    List<InitiativeDto> subinitiativesTree = getSubinitiativesTree(initiativeId, null);
    List<UUID> allInitiativesIds = new ArrayList<UUID>();
    allInitiativesIds.add(initiativeId);
    allInitiativesIds.addAll(extractAllIdsFromInitiativesTree(subinitiativesTree, new ArrayList<UUID>()));
    Page<Activity> activities = null;
    if (!onlyMessages) {
        activities = activityRepository.findOfInitiatives(allInitiativesIds, page);
    } else {
        activities = activityRepository.findOfInitiativesAndType(allInitiativesIds, ActivityType.MESSAGE_POSTED, page);
    }
    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) NewInitiativeDto(org.collectiveone.modules.initiatives.dto.NewInitiativeDto) InitiativeDto(org.collectiveone.modules.initiatives.dto.InitiativeDto) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Activity(org.collectiveone.modules.activity.Activity) UUID(java.util.UUID) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Transactional(javax.transaction.Transactional)

Example 13 with GetResult

use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.

the class TokenController method getToken.

@RequestMapping(path = "/token/{id}", method = RequestMethod.GET)
public GetResult<AssetsDto> getToken(@PathVariable("id") String id, @RequestParam(defaultValue = "false") Boolean includeSubinitiatives, @RequestParam(defaultValue = "") String initiativeIdStr) {
    UUID tokenTypeId = UUID.fromString(id);
    Initiative initiative = initiativeService.findByTokenType_Id(tokenTypeId);
    if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
        return new GetResult<AssetsDto>("error", "access denied", null);
    }
    AssetsDto assetDto = tokenService.getTokenDto(UUID.fromString(id));
    if (includeSubinitiatives) {
        UUID initiativeContextId = UUID.fromString(initiativeIdStr);
        if (!initiativeService.canAccess(initiativeContextId, getLoggedUserId())) {
            return new GetResult<AssetsDto>("error", "access denied", null);
        }
        assetDto = tokenTransferService.getTokenDistribution(tokenTypeId, initiativeContextId);
    }
    return new GetResult<AssetsDto>("success", "initiative retrieved", assetDto);
}
Also used : GetResult(org.collectiveone.common.dto.GetResult) AssetsDto(org.collectiveone.modules.tokens.dto.AssetsDto) UUID(java.util.UUID) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with GetResult

use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.

the class TokenController method getTransferFromSubinitiative.

@RequestMapping(path = "/initiative/{initiativeId}/transfersFromSubinitiatives", method = RequestMethod.GET)
public GetResult<List<TransferDto>> getTransferFromSubinitiative(@PathVariable("initiativeId") String initiativeIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam("sortDirection") String sortDirection, @RequestParam("sortProperty") String sortProperty) {
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    if (!initiativeService.canAccess(initiativeId, getLoggedUserId())) {
        return new GetResult<List<TransferDto>>("error", "access denied", null);
    }
    Sort sort = new Sort(Sort.Direction.valueOf(sortDirection), sortProperty);
    return tokenTransferService.getTransfersFromSubinitiatives(initiativeId, new PageRequest(page, size, sort));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) TransferDto(org.collectiveone.modules.tokens.dto.TransferDto) Sort(org.springframework.data.domain.Sort) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with GetResult

use of org.collectiveone.common.dto.GetResult in project CollectiveOneWebapp by CollectiveOne.

the class TokenController method getTransferFromInitiative.

@RequestMapping(path = "/initiative/{initiativeId}/transfersToInitiatives", method = RequestMethod.GET)
public GetResult<List<TransferDto>> getTransferFromInitiative(@PathVariable("initiativeId") String initiativeIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam("sortDirection") String sortDirection, @RequestParam("sortProperty") String sortProperty) {
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    if (!initiativeService.canAccess(initiativeId, getLoggedUserId())) {
        return new GetResult<List<TransferDto>>("error", "access denied", null);
    }
    Sort sort = new Sort(Sort.Direction.valueOf(sortDirection), sortProperty);
    return tokenTransferService.getTransfersFromInitiative(initiativeId, new PageRequest(page, size, sort));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) TransferDto(org.collectiveone.modules.tokens.dto.TransferDto) Sort(org.springframework.data.domain.Sort) 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