package org.xcolab.view.pages.contestmanagement.entities.massactions;

import org.xcolab.client.contest.ContestClientUtil;
import org.xcolab.client.contest.enums.ContestStatus;
import org.xcolab.client.contest.pojo.Contest;
import org.xcolab.client.contest.pojo.phases.ContestPhase;
import org.xcolab.client.contest.pojo.phases.ContestPhaseType;
import org.xcolab.client.proposals.ProposalClientUtil;
import org.xcolab.client.proposals.pojo.Proposal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MessageAllAuthorsMassAction extends MessageMassAction {

    public MessageAllAuthorsMassAction() {
        super("Message all proposal authors");
    }

    @Override
    List<Proposal> getProposalsToBeMessaged(Contest contest) {
        Long contestPK = contest.getContestPK();
        List<ContestPhase> allPhases = ContestClientUtil.getAllContestPhases(contestPK);
        Map<Long,Proposal> proposalsMap = new HashMap<>();
        for(ContestPhase cp : allPhases){
            ContestPhaseType cpt = ContestClientUtil.getContestPhaseType(cp.getContestPhaseType());
            if(cpt.getStatus().equals(ContestStatus.OPEN_FOR_SUBMISSION.name())){
                List<Proposal> proposals = ProposalClientUtil
                        .getActiveProposalsInContestPhase(cp.getContestPhasePK());
                for (Proposal p: proposals) {
                    proposalsMap.putIfAbsent(p.getProposalId(), p);
                }
            }
        }

        List<Proposal> ret = new ArrayList<>();
        ret.addAll(proposalsMap.values());
        return ret;
    }
}

@@ -944,16 +944,17 @@
 ap%3CLong,
+ 
 Proposal
@@ -998,16 +998,17 @@
      for
+ 
 (Contest
@@ -1028,16 +1028,17 @@
 lPhases)
+ 
 %7B%0A      
@@ -1145,16 +1145,17 @@
       if
+ 
 (cpt.get
@@ -1212,16 +1212,17 @@
 name()))
+ 
 %7B%0A      
@@ -1261,27 +1261,8 @@
 ls =
- ProposalClientUtil
 %0A   
@@ -1282,16 +1282,34 @@
         
+ProposalClientUtil
 .getActi
@@ -1390,16 +1390,17 @@
 oposal p
+ 
 : propos

clean up spacing