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