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