use of org.collectiveone.modules.model.dto.ModelCardWrapperDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelCardWrapper method toDto.
public ModelCardWrapperDto toDto() {
ModelCardWrapperDto cardWrapperDto = new ModelCardWrapperDto();
cardWrapperDto.setId(id.toString());
cardWrapperDto.setCard(card.toDto());
cardWrapperDto.setStateControl(stateControl);
if (state != null)
cardWrapperDto.setState(state.toString());
if (initiative != null)
cardWrapperDto.setInitiativeId(initiative.getId().toString());
if (targetDate != null)
cardWrapperDto.setTargetDate(targetDate.getTime());
return cardWrapperDto;
}
use of org.collectiveone.modules.model.dto.ModelCardWrapperDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method addSectionSubElements.
@Transactional
public ModelSectionDto addSectionSubElements(ModelSectionDto sectionDto, UUID sectionId, Integer level, UUID requestByUserId) {
ModelSection section = modelSectionRepository.findById(sectionId);
if (level >= 1) {
sectionDto.setSubElementsLoaded(true);
for (ModelCardWrapper cardWrapper : section.getCardsWrappers()) {
ModelCardWrapperDto cardWrapperDto = cardWrapper.toDto();
cardWrapperDto.setnLikes(cardLikeRepository.countOfCard(cardWrapper.getId()));
if (requestByUserId != null) {
cardWrapperDto.setUserLiked(cardLikeRepository.findByCardWrapperIdAndAuthor_c1Id(cardWrapper.getId(), requestByUserId) != null);
}
List<ModelSection> inSections = modelCardWrapperRepository.findParentSections(cardWrapper.getId());
for (ModelSection inSection : inSections) {
cardWrapperDto.getInSections().add(inSection.toDto());
}
sectionDto.getCardsWrappers().add(cardWrapperDto);
}
for (ModelSection subsection : section.getSubsections()) {
sectionDto.getSubsections().add(addSectionSubElements(subsection.toDto(), subsection.getId(), level - 1, requestByUserId));
}
} else {
sectionDto.setSubElementsLoaded(false);
}
return sectionDto;
}
use of org.collectiveone.modules.model.dto.ModelCardWrapperDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method searchCardWrapper.
@Transactional
public GetResult<Page<ModelCardWrapperDto>> searchCardWrapper(String query, PageRequest page, UUID initiativeId) {
List<UUID> initiativeEcosystemIds = initiativeService.findAllInitiativeEcosystemIds(initiativeId);
Page<ModelCardWrapper> enititiesPage = modelCardWrapperRepository.searchBy("%" + query.toLowerCase() + "%", initiativeEcosystemIds, page);
List<ModelCardWrapperDto> cardsDtos = new ArrayList<ModelCardWrapperDto>();
for (ModelCardWrapper cardWrapper : enititiesPage.getContent()) {
List<ModelSection> inSections = modelCardWrapperRepository.findParentSections(cardWrapper.getId());
ModelCardWrapperDto cardWrapperDto = cardWrapper.toDto();
for (ModelSection section : inSections) {
cardWrapperDto.getInSections().add(section.toDto());
}
cardsDtos.add(cardWrapperDto);
}
Page<ModelCardWrapperDto> dtosPage = new PageImpl<ModelCardWrapperDto>(cardsDtos, page, enititiesPage.getNumberOfElements());
return new GetResult<Page<ModelCardWrapperDto>>("succes", "cards returned", dtosPage);
}
use of org.collectiveone.modules.model.dto.ModelCardWrapperDto in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method getCardWrapper.
@Transactional
public GetResult<ModelCardWrapperDto> getCardWrapper(UUID cardWrapperId, UUID requestByUserId) {
ModelCardWrapper cardWrapper = modelCardWrapperRepository.findById(cardWrapperId);
List<ModelSection> inSections = modelCardWrapperRepository.findParentSections(cardWrapper.getId());
ModelCardWrapperDto cardWrapperDto = cardWrapper.toDto();
cardWrapperDto.setnLikes(cardLikeRepository.countOfCard(cardWrapper.getId()));
if (requestByUserId != null) {
cardWrapperDto.setUserLiked(cardLikeRepository.findByCardWrapperIdAndAuthor_c1Id(cardWrapper.getId(), requestByUserId) != null);
}
for (ModelSection section : inSections) {
cardWrapperDto.getInSections().add(section.toDto());
}
return new GetResult<ModelCardWrapperDto>("success", "card retrieved", cardWrapperDto);
}
Aggregations