Search in sources :

Example 1 with ModelViewDto

use of org.collectiveone.modules.model.dto.ModelViewDto 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 2 with ModelViewDto

use of org.collectiveone.modules.model.dto.ModelViewDto in project CollectiveOneWebapp by CollectiveOne.

the class ModelView method toDto.

public ModelViewDto toDto() {
    ModelViewDto viewDto = new ModelViewDto();
    viewDto.setId(id.toString());
    viewDto.setInitiativeId(initiative.getId().toString());
    viewDto.setTitle(title);
    viewDto.setDescription(description);
    viewDto.setnSections(sections.size());
    if (initiative != null)
        viewDto.setInitiativeId(initiative.getId().toString());
    return viewDto;
}
Also used : ModelViewDto(org.collectiveone.modules.model.dto.ModelViewDto)

Example 3 with ModelViewDto

use of org.collectiveone.modules.model.dto.ModelViewDto in project CollectiveOneWebapp by CollectiveOne.

the class InitiativeService method initializeModel.

@Transactional
private PostResult initializeModel(UUID initiativeId, UUID creatorId) {
    ModelViewDto viewDto = new ModelViewDto();
    viewDto.setTitle("General View");
    viewDto.setDescription("Initial auto-generated sample view. You can edit or delete it at will.");
    PostResult result = modelService.createView(initiativeId, viewDto, creatorId, false);
    ModelSectionDto sectionDto = new ModelSectionDto();
    sectionDto.setTitle("Section");
    sectionDto.setDescription("Initial auto-generated sample section. You can edit or delete it at will.");
    PostResult result2 = modelService.createSection(sectionDto, null, UUID.fromString(result.getElementId()), creatorId, false);
    return result2;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) ModelViewDto(org.collectiveone.modules.model.dto.ModelViewDto) ModelSectionDto(org.collectiveone.modules.model.dto.ModelSectionDto) Transactional(javax.transaction.Transactional)

Example 4 with ModelViewDto

use of org.collectiveone.modules.model.dto.ModelViewDto in project CollectiveOneWebapp by CollectiveOne.

the class ModelService method getModel.

@Transactional
public GetResult<ModelDto> getModel(UUID initiativeId, Integer level, UUID requestById) {
    Initiative initiative = initiativeRepository.findById(initiativeId);
    if (initiative == null)
        return new GetResult<ModelDto>("error", "initiative not found", null);
    List<ModelViewDto> viewsDto = new ArrayList<ModelViewDto>();
    List<ModelView> views = initiative.getModelViews();
    for (ModelView view : views) {
        ModelViewDto viewDto = view.toDto();
        viewDto = addViewSubElements(viewDto, view.getId(), level, requestById);
        viewsDto.add(viewDto);
    }
    ModelDto modelDto = new ModelDto();
    modelDto.setViews(viewsDto);
    return new GetResult<ModelDto>("success", "model found", modelDto);
}
Also used : ModelDto(org.collectiveone.modules.model.dto.ModelDto) ModelViewDto(org.collectiveone.modules.model.dto.ModelViewDto) GetResult(org.collectiveone.common.dto.GetResult) ArrayList(java.util.ArrayList) Initiative(org.collectiveone.modules.initiatives.Initiative) Transactional(javax.transaction.Transactional)

Aggregations

ModelViewDto (org.collectiveone.modules.model.dto.ModelViewDto)4 Transactional (javax.transaction.Transactional)3 GetResult (org.collectiveone.common.dto.GetResult)2 ArrayList (java.util.ArrayList)1 PostResult (org.collectiveone.common.dto.PostResult)1 Initiative (org.collectiveone.modules.initiatives.Initiative)1 ModelDto (org.collectiveone.modules.model.dto.ModelDto)1 ModelSectionDto (org.collectiveone.modules.model.dto.ModelSectionDto)1