Search in sources :

Example 31 with Initiative

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;
}
Also used : ModelCardWrapper(org.collectiveone.modules.model.ModelCardWrapper) ModelSection(org.collectiveone.modules.model.ModelSection) ModelView(org.collectiveone.modules.model.ModelView) Initiative(org.collectiveone.modules.initiatives.Initiative) Transactional(javax.transaction.Transactional)

Example 32 with Initiative

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;
}
Also used : ArrayList(java.util.ArrayList) Bill(org.collectiveone.modules.assignations.Bill) TransferDto(org.collectiveone.modules.tokens.dto.TransferDto) Assignation(org.collectiveone.modules.assignations.Assignation) Initiative(org.collectiveone.modules.initiatives.Initiative) Transactional(javax.transaction.Transactional)

Aggregations

Initiative (org.collectiveone.modules.initiatives.Initiative)32 Transactional (javax.transaction.Transactional)15 UUID (java.util.UUID)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 PostResult (org.collectiveone.common.dto.PostResult)11 GetResult (org.collectiveone.common.dto.GetResult)10 ArrayList (java.util.ArrayList)4 TransferDto (org.collectiveone.modules.tokens.dto.TransferDto)4 ActivityDto (org.collectiveone.modules.activity.dto.ActivityDto)3 PageRequest (org.springframework.data.domain.PageRequest)3 Email (com.sendgrid.Email)2 Personalization (com.sendgrid.Personalization)2 Timestamp (java.sql.Timestamp)2 Assignation (org.collectiveone.modules.assignations.Assignation)2 ModelCardWrapper (org.collectiveone.modules.model.ModelCardWrapper)2 ModelSection (org.collectiveone.modules.model.ModelSection)2 ModelView (org.collectiveone.modules.model.ModelView)2 TokenMint (org.collectiveone.modules.tokens.TokenMint)2 TokenType (org.collectiveone.modules.tokens.TokenType)2 AssetsDto (org.collectiveone.modules.tokens.dto.AssetsDto)2