Search in sources :

Example 1 with Activity

use of org.collectiveone.modules.activity.Activity 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);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Activity(org.collectiveone.modules.activity.Activity) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Transactional(javax.transaction.Transactional)

Example 2 with Activity

use of org.collectiveone.modules.activity.Activity 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);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Activity(org.collectiveone.modules.activity.Activity) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Transactional(javax.transaction.Transactional)

Example 3 with Activity

use of org.collectiveone.modules.activity.Activity 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 4 with Activity

use of org.collectiveone.modules.activity.Activity in project CollectiveOneWebapp by CollectiveOne.

the class ModelService method getActivityResultUnderView.

@Transactional
public GetResult<Page<ActivityDto>> getActivityResultUnderView(UUID viewId, PageRequest page, Boolean onlyMessages) {
    Page<Activity> activities = getActivityUnderView(viewId, 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);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Activity(org.collectiveone.modules.activity.Activity) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Transactional(javax.transaction.Transactional)

Aggregations

ArrayList (java.util.ArrayList)4 Transactional (javax.transaction.Transactional)4 GetResult (org.collectiveone.common.dto.GetResult)4 Activity (org.collectiveone.modules.activity.Activity)4 ActivityDto (org.collectiveone.modules.activity.dto.ActivityDto)4 PageImpl (org.springframework.data.domain.PageImpl)4 UUID (java.util.UUID)1 InitiativeDto (org.collectiveone.modules.initiatives.dto.InitiativeDto)1 NewInitiativeDto (org.collectiveone.modules.initiatives.dto.NewInitiativeDto)1