Edit Page<ProgramReturnResponse>and populate values of leadlaisions property

PHOTO EMBED

Thu Mar 18 2021 04:39:15 GMT+0000 (UTC)

Saved by @pratikpadia #java

private Page<ProgramReturnResponse> populatingleadLiaisonsInResponse(
			Page<ProgramReturnResponse> pageProgramReturnResponse) {
		List<ProgramReturnResponse> programResponseList = pageProgramReturnResponse.getContent();
		List<ProgramReturnResponse> updatedProgramResponseList = new ArrayList<>();
		List<Long> programIdList =                      
                 programResponseList.stream().map(ProgramReturnResponse::getProgramId)
				.collect(Collectors.toList());
		// programIdList = [101,102]
  
        List<ProgramMember> programMemberList = programMemberRepository
				.findLeadLaisonMembersByProgramId(programIdList,10);
        //programMemberList = [e0909, e22, e3030]
		MultiValueMap multiValueMap = new MultiValueMap();
  
		programMemberList.stream().forEach(programMember -> multiValueMap
				.put(programMember.getProgram().getProgramId(),                  
                     programMember.getMemberEmployeeId()));
  
         // multiValueMap = [ {101, [e0909, e22] } , {102, [e3030]}]
  
		for (ProgramReturnResponse programReturnResponse : programResponseList) {
			List<String> memberEids = (List<String>)       
                                       multiValueMap.get(programReturnResponse.getProgramId());
          
            // [e0909, e22]
            // [e3030]
			programReturnResponse.setLeadLiaisons(memberEids);
			updatedProgramResponseList.add(programReturnResponse);
		}
		return new PageImpl<>(updatedProgramResponseList, pageProgramReturnResponse.getPageable(),
				pageProgramReturnResponse.getTotalElements());
	}
content_copyCOPY

Edit Page<ProgramReturnResponse>and populate values of leadlaisions property