final ExecutionCourse executionCourseTo) throws ExcepcaoPersistencia {
final ExecutionCourse executionCourseTo) throws ExcepcaoPersistencia, FenixServiceException { while (!executionCourseFrom.getAttends().isEmpty()) { final Attends attends = executionCourseFrom.getAttends().get(0); final Attends otherAttends = executionCourseTo.getAttendsByStudent(attends.getAluno()); if (otherAttends == null) { attends.setDisciplinaExecucao(executionCourseTo); } else { if (attends.hasEnrolment() && !otherAttends.hasAluno()) { otherAttends.setEnrolment(attends.getEnrolment()); } else if (otherAttends.hasEnrolment() && attends.hasAluno()) { throw new FenixServiceException("Unable to merge execution courses. Student " + attends.getAluno().getNumber() + " has an enrolment in both.");   } attends.delete(); } }
    private void copyAttends(final ExecutionCourse executionCourseFrom,            final ExecutionCourse executionCourseTo) throws ExcepcaoPersistencia {        final Iterator associatedAttendsFromDestination = executionCourseTo.getAttendsIterator();        final Map alreadyAttendingDestination = new HashMap();        while (associatedAttendsFromDestination.hasNext()) {            Attends attend = (Attends) associatedAttendsFromDestination.next();            alreadyAttendingDestination.put(attend.getAluno().getNumber().toString(), attend);        }        final List<Attends> associatedAttendsFromSource = new ArrayList();        associatedAttendsFromSource.addAll(executionCourseFrom.getAttends());        for (final Attends attend : associatedAttendsFromSource) {            if (!alreadyAttendingDestination.containsKey(attend.getAluno().getNumber().toString())) {                attend.setDisciplinaExecucao(executionCourseTo);            }        }    }