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());
}
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());
}
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, "");
}
}
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;
}
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);
}
Aggregations