use of org.collectiveone.modules.initiatives.Initiative in project CollectiveOneWebapp by CollectiveOne.
the class MessageService method getOrCreateThreadFromElementId.
@Transactional
private MessageThread getOrCreateThreadFromElementId(MessageThreadContextType contextType, UUID elementId) {
MessageThread thread = getThreadFromElementId(contextType, elementId);
if (thread == null) {
thread = new MessageThread();
thread.setContextType(contextType);
thread = messageThreadRepository.save(thread);
switch(contextType) {
case MODEL_CARD:
ModelCardWrapper card = modelCardWrapperRepository.findById(elementId);
thread.setModelCardWrapper(card);
card.setMessageThread(thread);
modelCardWrapperRepository.save(card);
break;
case MODEL_SECTION:
ModelSection section = modelSectionRepository.findById(elementId);
thread.setModelSection(section);
section.setMessageThread(thread);
modelSectionRepository.save(section);
break;
case MODEL_VIEW:
ModelView view = modelViewRepository.findById(elementId);
thread.setModelView(view);
view.setMessageThread(thread);
modelViewRepository.save(view);
break;
case INITIATIVE:
Initiative initiative = initiativeRepository.findById(elementId);
thread.setInitiative(initiative);
initiative.setMessageThread(thread);
initiativeRepository.save(initiative);
break;
}
}
return thread;
}
use of org.collectiveone.modules.initiatives.Initiative in project CollectiveOneWebapp by CollectiveOne.
the class TokenTransferService method getTransfersPending.
@Transactional
public List<TransferDto> getTransfersPending(UUID initiativeId) {
Initiative initiative = initiativeRepository.findById(initiativeId);
List<TransferDto> transfersPending = new ArrayList<TransferDto>();
List<Assignation> assignations = assignationService.getOpenAssignations(initiativeId);
for (Assignation assignation : assignations) {
for (Bill bill : assignation.getBills()) {
TransferDto dto = new TransferDto();
dto.setAssetId(bill.getTokenType().getId().toString());
dto.setAssetName(bill.getTokenType().getName());
dto.setSenderId(initiative.getId().toString());
dto.setSenderName(initiative.getMeta().getName());
dto.setValue(bill.getValue());
transfersPending.add(dto);
}
}
return transfersPending;
}
Aggregations