Search in sources :

Example 16 with GetResult

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

the class AssignationController method getAssignations.

@RequestMapping(path = "/initiative/{initiativeId}/assignations", method = RequestMethod.GET)
public GetResult<List<AssignationDto>> getAssignations(@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<AssignationDto>>("error", "access denied", null);
    }
    Sort sort = new Sort(Sort.Direction.valueOf(sortDirection), sortProperty);
    return assignationService.getAssignationsOfInitiative(initiativeId, getLoggedUserId(), new PageRequest(page, size, sort));
}
Also used : AssignationDto(org.collectiveone.modules.assignations.dto.AssignationDto) PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) Sort(org.springframework.data.domain.Sort) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with GetResult

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

the class AssignationController method getAssignationOfUser.

@RequestMapping(path = "/assignation/{assignationId}", method = RequestMethod.GET)
public GetResult<AssignationDto> getAssignationOfUser(@PathVariable("assignationId") String assignationIdStr, @RequestParam(defaultValue = "false") Boolean addAllEvaluations) {
    UUID assignationId = UUID.fromString(assignationIdStr);
    UUID initiativeId = assignationService.findInitiativeId(assignationId);
    if (!initiativeService.canAccess(initiativeId, getLoggedUserId())) {
        return new GetResult<AssignationDto>("error", "access denied", null);
    }
    return assignationService.getAssignationDto(assignationId, getLoggedUserId(), addAllEvaluations);
}
Also used : GetResult(org.collectiveone.common.dto.GetResult) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with GetResult

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

the class AssignationController method getAssignationsOfSubinitiatives.

@RequestMapping(path = "/initiative/{initiativeId}/assignationsOfSubinitiatives", method = RequestMethod.GET)
public GetResult<List<AssignationDto>> getAssignationsOfSubinitiatives(@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<AssignationDto>>("error", "access denied", null);
    }
    Sort sort = new Sort(Sort.Direction.valueOf(sortDirection), sortProperty);
    return assignationService.getAssignationsOfSubinitiatives(initiativeId, getLoggedUserId(), new PageRequest(page, size, sort));
}
Also used : AssignationDto(org.collectiveone.modules.assignations.dto.AssignationDto) PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) Sort(org.springframework.data.domain.Sort) UUID(java.util.UUID) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with GetResult

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

the class AssignationService method getAssignationsOfSubinitiatives.

@Transactional
public GetResult<List<AssignationDto>> getAssignationsOfSubinitiatives(UUID initiativeId, UUID evaluatorAppUserId, PageRequest page) {
    /* add assignations of of this initiative */
    List<Assignation> assignationsOfSubinitiative = assignationRepository.findByAlsoInInitiatives_Id(initiativeId, page);
    List<AssignationDto> assignationsDto = new ArrayList<AssignationDto>();
    for (Assignation assignation : assignationsOfSubinitiative) {
        assignationsDto.add(getAssignationDto(assignation.getId(), evaluatorAppUserId, false).getData());
    }
    return new GetResult<List<AssignationDto>>("success", "assignations retrieved", assignationsDto);
}
Also used : AssignationDto(org.collectiveone.modules.assignations.dto.AssignationDto) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) PeerReviewedAssignation(org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation) Transactional(javax.transaction.Transactional)

Example 20 with GetResult

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

the class AssignationService method getAssignationsOfInitiative.

@Transactional
public GetResult<List<AssignationDto>> getAssignationsOfInitiative(UUID initiativeId, UUID evaluatorAppUserId, PageRequest page) {
    /* add assignations of of this initiative */
    List<Assignation> assignations = assignationRepository.findByInitiativeId(initiativeId, page);
    List<AssignationDto> assignationsDto = new ArrayList<AssignationDto>();
    for (Assignation assignation : assignations) {
        assignationsDto.add(getAssignationDto(assignation.getId(), evaluatorAppUserId, false).getData());
    }
    return new GetResult<List<AssignationDto>>("success", "assignations retrieved", assignationsDto);
}
Also used : AssignationDto(org.collectiveone.modules.assignations.dto.AssignationDto) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) PeerReviewedAssignation(org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation) 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