IEnrolment enrolment = writeEnrollment(studentCurricularPlan, executionPeriod, curricularCourse, enrollmentsCreated);
IEnrollment enrolment = writeEnrollment(studentCurricularPlan, executionPeriod, curricularCourse, enrollmentsCreated);
	private void automaticalyEnrollInMandatoryCurricularCourses() throws ExcepcaoPersistencia	{		HashMap enrollmentsCreated = new HashMap();		// FIXME [DAVID]: There is a bug here!		// Try this: Enroll in all mandatory curricular courses and some others more untill you get a total of maxCourses		// enrolled. Now try to unenroll a mandatory curricular course.		// It was allowed because totalSize >= maxCourses so it will not automaticaly enroll in mandatory curricular courses		// that were unenrolled before.		List curricularCourses =			getMandatoryCurricularCourses(this.studentEnrolmentContext.getFinalCurricularCoursesWhereStudentCanBeEnrolled());		int maxCourses =			this.studentEnrolmentContext.getStudentCurricularPlan().getStudent().getStudentKind().getMaxCoursesToEnrol().intValue();		int currentSemesterEnrollmentsSize = this.studentEnrolmentContext.getStudentCurrentSemesterEnrollments().size();				int totalSize = curricularCourses.size() + currentSemesterEnrollmentsSize;				if (curricularCourses != null && !curricularCourses.isEmpty() && totalSize <= maxCourses)		{			IStudentCurricularPlan studentCurricularPlan = this.studentEnrolmentContext.getStudentCurricularPlan();			IExecutionPeriod executionPeriod = this.studentEnrolmentContext.getExecutionPeriod();			List enrollmentsToAdd = new ArrayList();			Iterator iterator = curricularCourses.iterator();			while (iterator.hasNext())			{				ICurricularCourse curricularCourse = (ICurricularCourse) iterator.next();				IEnrolment enrolment = writeEnrollment(studentCurricularPlan, executionPeriod, curricularCourse, enrollmentsCreated);				if (enrolment != null)				{					enrollmentsToAdd.add(enrolment);					enrollmentsCreated.put(curricularCourse.getIdInternal(), enrolment);				}			}						List studentEverEnrolledCurricularCourses = getStudentEverEnrolledCurricularCourses();			iterator = enrollmentsCreated.entrySet().iterator();			while (iterator.hasNext())			{				Map.Entry mapEntry = (Map.Entry) iterator.next();				IEnrolment enrolment = (IEnrolment) mapEntry.getValue();				studentEverEnrolledCurricularCourses.add(enrolment.getCurricularCourse());			}						this.studentEnrolmentContext.getStudentCurrentSemesterEnrollments().addAll(enrollmentsToAdd);			this.studentEnrolmentContext.getFinalCurricularCoursesWhereStudentCanBeEnrolled().removeAll(curricularCourses);			this.studentEnrolmentContext.setAcumulatedEnrolments(studentEverEnrolledCurricularCourses);			computeAvailableCurricularCourses();		}	}