int numberOfCompletedCourses = student .countCompletedCoursesForActiveUndergraduateCurricularPlan();
final Set<Degree> degrees = new HashSet<Degree>(); for (final ExecutionDegree someExecutionDegree : scheduleing.getExecutionDegreesSet()) { degrees.add(someExecutionDegree.getDegreeCurricularPlan().getDegree()); } final int numberOfCompletedCourses = student.getActiveStudentCurricularPlan().numberCompletedCoursesForSpecifiedDegrees(degrees);
    public boolean run(Integer groupOID, String username) throws ExcepcaoPersistencia,            FenixServiceException {        Group group = rootDomainObject.readGroupByOID(groupOID);        Student student = Student.readByUsername(username);        if (group == null                || student == null                || group.getGroupStudents() == null                || CollectionUtils.find(group.getGroupStudents(),                        new PREDICATE_FIND_GROUP_STUDENT_BY_STUDENT(student)) != null) {            return false;        }        Scheduleing scheduleing = group.getExecutionDegree().getScheduling();        if (scheduleing == null || scheduleing.getMaximumNumberOfStudents() == null) {            throw new MaximumNumberOfStudentsUndefinedException();        } else if (scheduleing.getMinimumNumberOfCompletedCourses() == null) {            throw new MinimumNumberOfCompletedCoursesUndefinedException();        } else if (scheduleing.getMaximumNumberOfStudents().intValue() <= group.getGroupStudents()                .size()) {            throw new MaximumNumberOfStudentsReachedException(scheduleing.getMaximumNumberOfStudents()                    .toString());        } else {            int numberOfCompletedCourses = student                    .countCompletedCoursesForActiveUndergraduateCurricularPlan();            if (numberOfCompletedCourses < scheduleing.getMinimumNumberOfCompletedCourses().intValue()) {                throw new MinimumNumberOfCompletedCoursesNotReachedException(scheduleing                        .getMinimumNumberOfCompletedCourses().toString());            }        }        GroupStudent groupStudent = DomainFactory.makeGroupStudent();        groupStudent.setStudent(student);        groupStudent.setFinalDegreeDegreeWorkGroup(group);        return true;    }