Search in sources :

Example 1 with ModelDto

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

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