Search in sources :

Example 6 with ActivityDto

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

the class Activity method toDto.

/* Dto */
public ActivityDto toDto() {
    ActivityDto dto = new ActivityDto();
    dto.setId(id.toString());
    dto.setType(type.toString());
    if (timestamp != null)
        dto.setTimestamp(timestamp.getTime());
    if (triggerUser != null)
        dto.setTriggerUser(triggerUser.toDtoLight());
    if (initiative != null)
        dto.setInitiative(initiative.toDto());
    if (subInitiative != null)
        dto.setSubInitiative(subInitiative.toDto());
    dto.setOldName(oldName);
    dto.setOldDriver(oldDriver);
    if (mint != null)
        dto.setMint(mint.toDto());
    if (assignation != null)
        dto.setAssignation(assignation.toDto());
    if (initiativeTransfer != null)
        dto.setTransfer(initiativeTransfer.toDto());
    if (modelView != null)
        dto.setModelView(modelView.toDto());
    if (modelSection != null)
        dto.setModelSection(modelSection.toDto());
    if (modelCardWrapper != null)
        dto.setModelCardWrapper(modelCardWrapper.toDto());
    if (onSection != null)
        dto.setOnSection(onSection.toDto());
    if (onView != null)
        dto.setOnView(onView.toDto());
    if (fromSection != null)
        dto.setFromSection(fromSection.toDto());
    if (fromView != null)
        dto.setFromView(fromView.toDto());
    if (message != null)
        dto.setMessage(message.toDto());
    return dto;
}
Also used : ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto)

Example 7 with ActivityDto

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

the class ModelController method getActivityUnderCard.

@RequestMapping(path = "/activity/model/card/{cardWrapperId}", method = RequestMethod.GET)
public GetResult<Page<ActivityDto>> getActivityUnderCard(@PathVariable("cardWrapperId") String cardWrapperIdStr, @RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam(name = "onlyMessages", defaultValue = "false") Boolean onlyMessages) {
    UUID cardWrapperId = UUID.fromString(cardWrapperIdStr);
    Initiative initiative = modelService.getCardWrapperInitiative(cardWrapperId);
    if (!initiativeService.canAccess(initiative.getId(), getLoggedUserId())) {
        return new GetResult<Page<ActivityDto>>("error", "access denied", null);
    }
    return modelService.getActivityResultUnderCard(cardWrapperId, new PageRequest(page, size), onlyMessages);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) GetResult(org.collectiveone.common.dto.GetResult) UUID(java.util.UUID) ActivityDto(org.collectiveone.modules.activity.dto.ActivityDto) Initiative(org.collectiveone.modules.initiatives.Initiative) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with ActivityDto

use of org.collectiveone.modules.activity.dto.ActivityDto 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

ActivityDto (org.collectiveone.modules.activity.dto.ActivityDto)8 GetResult (org.collectiveone.common.dto.GetResult)7 ArrayList (java.util.ArrayList)4 UUID (java.util.UUID)4 Transactional (javax.transaction.Transactional)4 Activity (org.collectiveone.modules.activity.Activity)4 PageImpl (org.springframework.data.domain.PageImpl)4 Initiative (org.collectiveone.modules.initiatives.Initiative)3 PageRequest (org.springframework.data.domain.PageRequest)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 InitiativeDto (org.collectiveone.modules.initiatives.dto.InitiativeDto)1 NewInitiativeDto (org.collectiveone.modules.initiatives.dto.NewInitiativeDto)1