Search in sources :

Example 16 with Transactional

use of javax.transaction.Transactional 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 17 with Transactional

use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.

the class ModelService method createSection.

@Transactional
public PostResult createSection(ModelSectionDto sectionDto, UUID parentSectionId, UUID parentViewId, UUID creatorId, boolean register) {
    ModelSection section = sectionDto.toEntity(null, sectionDto);
    section = modelSectionRepository.save(section);
    if (parentSectionId != null) {
        ModelSection parent = modelSectionRepository.findById(parentSectionId);
        if (parent == null)
            return new PostResult("error", "parent section not found", "");
        parent.getSubsections().add(section);
        section.setInitiative(parent.getInitiative());
        if (register)
            activityService.modelSectionCreatedOnSection(section, parent, appUserRepository.findByC1Id(creatorId));
        modelSectionRepository.save(parent);
    } else {
        ModelView view = modelViewRepository.findById(parentViewId);
        if (view == null)
            return new PostResult("error", "view not found", "");
        view.getSections().add(section);
        section.setInitiative(view.getInitiative());
        if (register)
            activityService.modelSectionCreatedOnView(section, view, appUserRepository.findByC1Id(creatorId));
        modelViewRepository.save(view);
    }
    return new PostResult("success", "section created", section.getId().toString());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) Transactional(javax.transaction.Transactional)

Example 18 with Transactional

use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.

the class ModelService method createView.

@Transactional
public PostResult createView(UUID initiativeId, ModelViewDto viewDto, UUID creatorId, boolean register) {
    Initiative initiative = initiativeRepository.findById(initiativeId);
    if (initiative == null)
        return new PostResult("error", "initiative not found", "");
    ModelView view = viewDto.toEntity(null, viewDto, initiative);
    view = modelViewRepository.save(view);
    initiative.getModelViews().add(view);
    initiativeRepository.save(initiative);
    if (register)
        activityService.modelViewCreated(view, appUserRepository.findByC1Id(creatorId));
    return new PostResult("success", "view created", view.getId().toString());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) Initiative(org.collectiveone.modules.initiatives.Initiative) Transactional(javax.transaction.Transactional)

Example 19 with Transactional

use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.

the class ModelService method getView.

@Transactional
public GetResult<ModelViewDto> getView(UUID viewId, UUID requestById, Integer level, UUID requestByUserId) {
    ModelView view = modelViewRepository.findById(viewId);
    ModelViewDto viewDto = view.toDto();
    viewDto = addViewSubElements(viewDto, view.getId(), level, requestByUserId);
    return new GetResult<ModelViewDto>("success", "view retrieved", viewDto);
}
Also used : ModelViewDto(org.collectiveone.modules.model.dto.ModelViewDto) GetResult(org.collectiveone.common.dto.GetResult) Transactional(javax.transaction.Transactional)

Example 20 with Transactional

use of javax.transaction.Transactional 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)

Aggregations

Transactional (javax.transaction.Transactional)314 Test (org.junit.Test)100 PostResult (org.collectiveone.common.dto.PostResult)29 ArrayList (java.util.ArrayList)25 UserDO (org.neusoft.neubbs.entity.UserDO)21 Timestamp (java.sql.Timestamp)18 TopicDO (org.neusoft.neubbs.entity.TopicDO)18 Initiative (org.collectiveone.modules.initiatives.Initiative)16 GetResult (org.collectiveone.common.dto.GetResult)15 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)13 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)13 HashMap (java.util.HashMap)12 Date (java.util.Date)11 AppUser (org.collectiveone.modules.users.AppUser)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 UUID (java.util.UUID)10 RolesAllowed (javax.annotation.security.RolesAllowed)10 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)10 IOException (java.io.IOException)9 Booking (org.apache.karaf.examples.jpa.Booking)9