Search in sources :

Example 21 with Transactional

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);
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) AppUser(org.collectiveone.modules.users.AppUser) CardLike(org.collectiveone.modules.governance.CardLike) Transactional(javax.transaction.Transactional)

Example 22 with Transactional

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());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) Initiative(org.collectiveone.modules.initiatives.Initiative) Transactional(javax.transaction.Transactional)

Example 23 with Transactional

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());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) Initiative(org.collectiveone.modules.initiatives.Initiative) Transactional(javax.transaction.Transactional)

Example 24 with Transactional

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());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) Transactional(javax.transaction.Transactional)

Example 25 with Transactional

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;
}
Also used : AssetsDto(org.collectiveone.modules.tokens.dto.AssetsDto) Transactional(javax.transaction.Transactional)

Aggregations

Transactional (javax.transaction.Transactional)314 Test (org.junit.Test)100 PostResult (org.collectiveone.common.dto.PostResult)29 ArrayList (java.util.ArrayList)25 UserDO (org.neusoft.neubbs.entity.UserDO)21 Timestamp (java.sql.Timestamp)18 TopicDO (org.neusoft.neubbs.entity.TopicDO)18 Initiative (org.collectiveone.modules.initiatives.Initiative)16 GetResult (org.collectiveone.common.dto.GetResult)15 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)13 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)13 HashMap (java.util.HashMap)12 Date (java.util.Date)11 AppUser (org.collectiveone.modules.users.AppUser)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 UUID (java.util.UUID)10 RolesAllowed (javax.annotation.security.RolesAllowed)10 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)10 IOException (java.io.IOException)9 Booking (org.apache.karaf.examples.jpa.Booking)9