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