use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method setLikeToCard.
@Transactional
public PostResult setLikeToCard(UUID cardWrapperId, UUID authorId, boolean likeStatus) {
ModelCardWrapper card = modelCardWrapperRepository.findById(cardWrapperId);
AppUser author = appUserRepository.findByC1Id(authorId);
CardLike like = cardLikeRepository.findByCardWrapperIdAndAuthor_c1Id(cardWrapperId, authorId);
/* add the like*/
if (likeStatus == true) {
if (like == null) {
like = new CardLike();
like.setAuthor(author);
like.setCardWrapper(card);
cardLikeRepository.save(like);
} else {
/* nothing to do, the like is already registered */
}
} else {
if (like != null) {
cardLikeRepository.delete(like);
} else {
/* nothing to do, the like is already absent */
}
}
return new PostResult("success", "like status changed", null);
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method moveView.
@Transactional
public PostResult moveView(UUID initiativeId, UUID viewId, UUID onViewId, UUID creatorId) {
if (onViewId.equals(viewId)) {
return new PostResult("warning", "cannot move on itself", null);
}
Initiative initiative = initiativeRepository.findById(initiativeId);
ModelView view = modelViewRepository.findById(viewId);
ModelView beforeView = modelViewRepository.findById(onViewId);
int index = initiative.getModelViews().indexOf(beforeView);
initiative.getModelViews().remove(view);
initiativeRepository.save(initiative);
initiative.getModelViews().add(index, view);
activityService.modelViewMoved(view, appUserRepository.findByC1Id(creatorId));
modelViewRepository.save(view);
initiativeRepository.save(initiative);
return new PostResult("success", "view moved", view.getId().toString());
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method editView.
@Transactional
public PostResult editView(UUID initiativeId, UUID viewId, ModelViewDto viewDto, UUID creatorId) {
Initiative initiative = initiativeRepository.findById(initiativeId);
if (initiative == null)
return new PostResult("error", "initiative not found", "");
ModelView view = modelViewRepository.findById(viewId);
view = viewDto.toEntity(view, viewDto, initiative);
view = modelViewRepository.save(view);
activityService.modelViewEdited(view, appUserRepository.findByC1Id(creatorId));
return new PostResult("success", "view edited", view.getId().toString());
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ModelService method moveCardWrapper.
@Transactional
public PostResult moveCardWrapper(UUID fromSectionId, UUID cardWrapperId, UUID toSectionId, UUID beforeCardWrapperId, UUID creatorId) {
if (cardWrapperId.equals(beforeCardWrapperId)) {
return new PostResult("error", "cannot move on itself", null);
}
ModelCardWrapper cardWrapper = modelCardWrapperRepository.findById(cardWrapperId);
if (cardWrapper == null)
return new PostResult("error", "card wrapper not found", "");
/* remove from section */
ModelSection fromSection = modelSectionRepository.findById(fromSectionId);
fromSection.getCardsWrappers().remove(cardWrapper);
modelSectionRepository.save(fromSection);
/* add to section */
ModelSection toSection = modelSectionRepository.findById(toSectionId);
if (beforeCardWrapperId != null) {
ModelCardWrapper beforeCardWrapper = modelCardWrapperRepository.findById(beforeCardWrapperId);
int index = toSection.getCardsWrappers().indexOf(beforeCardWrapper);
toSection.getCardsWrappers().add(index, cardWrapper);
} else {
toSection.getCardsWrappers().add(cardWrapper);
}
cardWrapper.setInitiative(toSection.getInitiative());
modelSectionRepository.save(toSection);
modelCardWrapperRepository.save(cardWrapper);
activityService.modelCardWrapperMoved(cardWrapper, fromSection, toSection, appUserRepository.findByC1Id(creatorId));
return new PostResult("success", "card moved", cardWrapper.getId().toString());
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class TokenService method getTokensOfHolderDto.
@Transactional
public AssetsDto getTokensOfHolderDto(UUID tokenTypeId, UUID holderId) {
AssetsDto assetsDto = getTokenDto(tokenTypeId);
/* Amount of tokens held by the input initiative */
assetsDto.setHolderId(holderId.toString());
assetsDto.setOwnedByThisHolder(getHolder(tokenTypeId, holderId).getTokens());
return assetsDto;
}
Aggregations