return participantBean;
}
private PhdParticipantBean getInternalPhdParticipantBean(final PhdIndividualProgramProcess individualProcess) {
final PhdParticipantBean participantBean = new PhdParticipantBean();
participantBean.setIndividualProgramProcess(individualProcess);
final Teacher teacher = User.findByUsername(getGuidingBean().getTeacherId()).getPerson().getTeacher();
if (teacher == null) {
throw new PhdMigrationGuidingNotFoundException("The guiding is not present in the system as a teacher");
}
for (PhdParticipant existingParticipant : individualProcess.getParticipantsSet()) {
if (!existingParticipant.isInternal()) {
continue;
}
final InternalPhdParticipant existingInternalParticipant = (InternalPhdParticipant) existingParticipant;
final Person existingInternalPerson = existingInternalParticipant.getPerson();
if (teacher.getPerson() == existingInternalPerson) {
// The guider is already associated with the process
participantBean.setInternalParticipant(teacher.getPerson());
participantBean.setParticipant(existingParticipant);
participantBean.setParticipantSelectType(PhdParticipantSelectType.EXISTING);
return participantBean;
}
}
// The guiding is in the system as teacher, but not yet associated with
// the process
participantBean.setParticipantSelectType(PhdParticipantSelectType.NEW);
participantBean.setInternalParticipant(teacher.getPerson());
participantBean.setInstitution(getInstitution());
participantBean.setWorkLocation(getInstitution());
return participantBean;
}