Search in sources :

Example 1 with InitiativeMembersDto

use of org.collectiveone.modules.initiatives.dto.InitiativeMembersDto in project CollectiveOneWebapp by CollectiveOne.

the class InitiativeService method getMembersAndSubmembers.

public InitiativeMembersDto getMembersAndSubmembers(UUID initiativeId) {
    Initiative initiative = initiativeRepository.findById(initiativeId);
    InitiativeMembersDto initiativeMembers = new InitiativeMembersDto();
    initiativeMembers.setInitiativeId(initiative.getId().toString());
    initiativeMembers.setInitiativeName(initiative.getMeta().getName());
    List<TokenType> tokenTypes = tokenService.getTokenTypesHeldBy(initiative.getId());
    /* add members of this initiative */
    for (Member member : initiative.getMembers()) {
        MemberDto memberDto = new MemberDto();
        memberDto.setId(member.getId().toString());
        memberDto.setUser(member.getUser().toDtoLight());
        /* governance related data */
        DecisionMaker decisionMaker = governanceService.getDecisionMaker(initiative.getGovernance().getId(), member.getUser().getC1Id());
        if (decisionMaker != null) {
            memberDto.setRole(decisionMaker.getRole().toString());
        } else {
            memberDto.setRole(DecisionMakerRole.MEMBER.toString());
        }
        /* assets related data */
        for (TokenType token : tokenTypes) {
            memberDto.getReceivedAssets().add(tokenService.getTokensOfHolderDtoLight(token.getId(), member.getUser().getC1Id()));
        }
        initiativeMembers.getMembers().add(memberDto);
    }
    /* add the members of all sub-initiatives too */
    for (InitiativeDto subInitiative : getSubinitiativesTree(initiative.getId(), null)) {
        /* recursively call with subinitiatives */
        initiativeMembers.getSubinitiativesMembers().add(getMembersAndSubmembers(UUID.fromString(subInitiative.getId())));
    }
    return initiativeMembers;
}
Also used : TokenType(org.collectiveone.modules.tokens.TokenType) NewInitiativeDto(org.collectiveone.modules.initiatives.dto.NewInitiativeDto) InitiativeDto(org.collectiveone.modules.initiatives.dto.InitiativeDto) MemberDto(org.collectiveone.modules.initiatives.dto.MemberDto) InitiativeMembersDto(org.collectiveone.modules.initiatives.dto.InitiativeMembersDto) DecisionMaker(org.collectiveone.modules.governance.DecisionMaker)

Aggregations

DecisionMaker (org.collectiveone.modules.governance.DecisionMaker)1 InitiativeDto (org.collectiveone.modules.initiatives.dto.InitiativeDto)1 InitiativeMembersDto (org.collectiveone.modules.initiatives.dto.InitiativeMembersDto)1 MemberDto (org.collectiveone.modules.initiatives.dto.MemberDto)1 NewInitiativeDto (org.collectiveone.modules.initiatives.dto.NewInitiativeDto)1 TokenType (org.collectiveone.modules.tokens.TokenType)1