Search in sources :

Example 11 with PostResult

use of org.collectiveone.common.dto.PostResult 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 12 with PostResult

use of org.collectiveone.common.dto.PostResult 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 13 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class TokenTransferService method transferFromInitiativeToInitiative.

@Transactional
public PostResult transferFromInitiativeToInitiative(UUID fromInitiativeId, UUID toInitiativeId, UUID orderByUserId, UUID assetId, double value, String motive, String notes) {
    TokenType tokenType = tokenService.getTokenType(assetId);
    Initiative from = initiativeRepository.findById(fromInitiativeId);
    Initiative to = initiativeRepository.findById(toInitiativeId);
    String result = tokenService.transfer(tokenType.getId(), from.getId(), to.getId(), value, TokenHolderType.INITIATIVE);
    if (result.equals("success")) {
        /* register the transfer to the initiative  */
        InitiativeTransfer transfer = new InitiativeTransfer();
        transfer.setTokenType(tokenType);
        transfer.setFrom(from);
        transfer.setTo(to);
        transfer.setMotive(motive);
        transfer.setNotes(notes);
        transfer.setValue(value);
        transfer.setOrderDate(new Timestamp(System.currentTimeMillis()));
        transfer.setOrderedBy(appUserRepository.findByC1Id(orderByUserId));
        transfer = initiativeTransferRepository.save(transfer);
        activityService.transferToSubinitiative(transfer);
        return new PostResult("success", "transfer done", transfer.getId().toString());
    } else {
        return new PostResult("success", "error making the transfer:" + result, "");
    }
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) Initiative(org.collectiveone.modules.initiatives.Initiative) Timestamp(java.sql.Timestamp) Transactional(javax.transaction.Transactional)

Example 14 with PostResult

use of org.collectiveone.common.dto.PostResult 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 15 with PostResult

use of org.collectiveone.common.dto.PostResult in project CollectiveOneWebapp by CollectiveOne.

the class InitiativesController method addTagToInitiative.

@RequestMapping(path = "/initiative/{initiativeId}/tags", method = RequestMethod.POST)
public PostResult addTagToInitiative(@PathVariable("initiativeId") String initiativeIdStr, @RequestBody InitiativeTagDto tagDto) {
    if (getLoggedUser() == null) {
        return new PostResult("error", "endpoint enabled users only", null);
    }
    UUID initiativeId = UUID.fromString(initiativeIdStr);
    DecisionVerdict verdict = governanceService.canEdit(initiativeId, getLoggedUser().getC1Id());
    if (verdict == DecisionVerdict.DENIED) {
        return new PostResult("error", "not authorized", "");
    }
    return initiativeService.addTagToInitiative(initiativeId, tagDto);
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PostResult (org.collectiveone.common.dto.PostResult)47 Transactional (javax.transaction.Transactional)28 UUID (java.util.UUID)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 Initiative (org.collectiveone.modules.initiatives.Initiative)11 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)7 DecisionVerdict (org.collectiveone.modules.governance.DecisionVerdict)5 AppUser (org.collectiveone.modules.users.AppUser)5 Timestamp (java.sql.Timestamp)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 FileStored (org.collectiveone.modules.files.FileStored)3 TokenType (org.collectiveone.modules.tokens.TokenType)3 DecisionMaker (org.collectiveone.modules.governance.DecisionMaker)2 ModelSectionDto (org.collectiveone.modules.model.dto.ModelSectionDto)2 TokenMint (org.collectiveone.modules.tokens.TokenMint)2 ArrayList (java.util.ArrayList)1 WantToContributeNotification (org.collectiveone.modules.activity.WantToContributeNotification)1 BillDto (org.collectiveone.modules.assignations.dto.BillDto)1 EvaluationGradeDto (org.collectiveone.modules.assignations.dto.EvaluationGradeDto)1