for (final Integer enrolementID : enrolementsToTransferIds) { final IEnrolment enrolement = (IEnrolment) persistentEnrollment.readByOID(Enrolment.class, enrolementID); enrolement.setStudentCurricularPlan(newActiveStudentCurricularPlan);
final List<IEnrolment> enrolments = new ArrayList<IEnrolment>(currentActiveStudentCurricularPlan.getEnrolments()); for (final IEnrolment enrolment : enrolments) { final Integer enrolmentId = enrolment.getIdInternal();  if (enrolementsToTransferIds.contains(enrolmentId)) { enrolment.setStudentCurricularPlan(newActiveStudentCurricularPlan); } else if (enrolementsToDeleteIds.contains(enrolmentId)) { enrolment.delete(); } else if (enrolementsToMaintainIds.contains(enrolmentId)) {  } else {  throw new IllegalArgumentException("Unspecified operation for enrolment: " + enrolmentId); }
    public void run(final String employeeUsername, final Integer studentNumber,            final Integer executionDegreeToChangeTo, final Set<Integer> enrolementsToTransferIds,            final Set<Integer> enrolementsToMaintainIds, final Set<Integer> enrolementsToDeleteIds,            final Date newStudentCurricularPlanStartDate)            throws ExcepcaoPersistencia {        final ISuportePersistente persistentSupport = PersistenceSupportFactory                .getDefaultPersistenceSupport();        final IPessoaPersistente persistentPerson = persistentSupport.getIPessoaPersistente();        final IPersistentStudentCurricularPlan persistentStudentCurricularPlan = persistentSupport                .getIStudentCurricularPlanPersistente();        final IPersistentExecutionDegree persistentExecutionDegree = persistentSupport                .getIPersistentExecutionDegree();        final IPersistentEnrollment persistentEnrollment = persistentSupport.getIPersistentEnrolment();        final IPerson personEmployee = persistentPerson.lerPessoaPorUsername(employeeUsername);        final IEmployee employee = personEmployee.getEmployee();        final IStudentCurricularPlan currentActiveStudentCurricularPlan = persistentStudentCurricularPlan                .readActiveStudentCurricularPlan(studentNumber, DegreeType.DEGREE);        currentActiveStudentCurricularPlan.setCurrentState(StudentCurricularPlanState.INCOMPLETE);        final IExecutionDegree executionDegree = (IExecutionDegree) persistentExecutionDegree.readByOID(                ExecutionDegree.class, executionDegreeToChangeTo);        final IDegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan();        final IStudentCurricularPlan newActiveStudentCurricularPlan = degreeCurricularPlan                .getNewStudentCurricularPlan();        newActiveStudentCurricularPlan.setBranch(null);        newActiveStudentCurricularPlan.setClassification(Double.valueOf(0));        newActiveStudentCurricularPlan.setCompletedCourses(0);        newActiveStudentCurricularPlan.setCreditsInSecundaryArea(0);        newActiveStudentCurricularPlan.setCreditsInSpecializationArea(0);        newActiveStudentCurricularPlan.setCurrentState(StudentCurricularPlanState.ACTIVE);        newActiveStudentCurricularPlan.setDegreeCurricularPlan(degreeCurricularPlan);        newActiveStudentCurricularPlan.setEmployee(employee);        newActiveStudentCurricularPlan.setGivenCredits(Double.valueOf(0));        newActiveStudentCurricularPlan.setMasterDegreeThesis(null);        newActiveStudentCurricularPlan.setObservations(null);        newActiveStudentCurricularPlan.setSecundaryBranch(null);        newActiveStudentCurricularPlan.setSpecialization(null);        newActiveStudentCurricularPlan.setStartDate(newStudentCurricularPlanStartDate);        newActiveStudentCurricularPlan.setStudent(currentActiveStudentCurricularPlan.getStudent());        newActiveStudentCurricularPlan.setWhen(Calendar.getInstance().getTime());        for (final Integer enrolementID : enrolementsToTransferIds) {            final IEnrolment enrolement = (IEnrolment) persistentEnrollment.readByOID(Enrolment.class,                    enrolementID);            enrolement.setStudentCurricularPlan(newActiveStudentCurricularPlan);        }        for (final Integer enrolementID : enrolementsToDeleteIds) {            final IEnrolment enrolment = (IEnrolment) persistentEnrollment.readByOID(Enrolment.class,                    enrolementID);            enrolment.delete();        }    }