use of org.collectiveone.modules.activity.dto.ActivityDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelController method getActivityUnderView.
@RequestMapping(path = "/activity/model/view/{viewId}", method = RequestMethod.GET)
public GetResult<Page<ActivityDto>> getActivityUnderView(@PathVariable("viewId") String viewIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam(name = "onlyMessages", defaultValue = "false") Boolean onlyMessages) {
UUID viewId = UUID.fromString(viewIdStr);
Initiative initiative = modelService.getViewInitiative(viewId);
if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
return new GetResult<Page<ActivityDto>>("error", "access denied", null);
}
return modelService.getActivityResultUnderView(viewId, new PageRequest(page, size), onlyMessages);
}
use of org.collectiveone.modules.activity.dto.ActivityDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelController method getActivityUnderSection.
@RequestMapping(path = "/activity/model/section/{sectionId}", method = RequestMethod.GET)
public GetResult<Page<ActivityDto>> getActivityUnderSection(@PathVariable("sectionId") String sectionIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @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<Page<ActivityDto>>("error", "access denied", null);
}
return modelService.getActivityResultUnderSection(sectionId, new PageRequest(page, size), onlyMessages);
}
use of org.collectiveone.modules.activity.dto.ActivityDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method getActivityResultUnderCard.
@Transactional
public GetResult<Page<ActivityDto>> getActivityResultUnderCard(UUID cardWrapperId, PageRequest page, Boolean onlyMessages) {
Page<Activity> activities = getActivityUnderCard(cardWrapperId, page, onlyMessages);
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.modules.activity.dto.ActivityDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method getActivityResultUnderSection.
@Transactional
public GetResult<Page<ActivityDto>> getActivityResultUnderSection(UUID sectionId, PageRequest page, Boolean onlyMessages) {
Page<Activity> activities = getActivityUnderSection(sectionId, page, onlyMessages);
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.modules.activity.dto.ActivityDto 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);
}
Aggregations