/** * Checks if person belongs to curricular course. The unit path format should be: * IST{.<SubUnitAcronym>}.<DegreeAcronym>.<CurricularCourseAcronym> * * <p>Accepted roles: STUDENT * * @param person * @param groupCheckQuery * @return * @throws NonExistingServiceException * @throws ExcepcaoPersistencia */ private static Boolean checkCurricularCourseGroup(Person person, GroupCheckQuery groupCheckQuery) throws NonExistingServiceException { final String[] unitAcronyms = groupCheckQuery.unitFullPath.split("\\."); if (!groupCheckQuery.roleType.equals("STUDENT")) { throw new NonExistingServiceException(); } for (final DegreeCurricularPlan degreeCurricularPlan : getDegree(unitAcronyms).getActiveDegreeCurricularPlans()) { final CurricularCourse curricularCourse = degreeCurricularPlan.getCurricularCourseByAcronym(unitAcronyms[4]); if (curricularCourse != null) { List<Enrolment> enrolments = curricularCourse.getEnrolmentsByExecutionPeriod( getExecutionPeriod(groupCheckQuery.year, groupCheckQuery.semester)); for (Enrolment enrolment : enrolments) { if (enrolment.getStudentCurricularPlan().getRegistration().getPerson().equals(person)) { return true; } } } } return false; }
@Atomic private static void deleteMaximumNumberOfCreditsForEnrolmentPeriod( final DegreeCurricularPlan input) { final List<? extends ICurricularRule> rules = input .getRoot() .getCurricularRules( CurricularRuleType.MAXIMUM_NUMBER_OF_CREDITS_FOR_ENROLMENT_PERIOD, (ExecutionYear) null); if (rules.size() > 1) { logger.error( "Update failed: found {} {} rules to update for DCP {}", rules.size(), MaximumNumberOfCreditsForEnrolmentPeriod.class.getSimpleName(), input.getPresentationName()); } else if (!rules.isEmpty()) { final MaximumNumberOfCreditsForEnrolmentPeriod rule = (MaximumNumberOfCreditsForEnrolmentPeriod) rules.iterator().next(); rule.delete(); logger.warn( "Deleted {} for DCP {}", MaximumNumberOfCreditsForEnrolmentPeriod.class.getSimpleName(), input.getPresentationName()); } }
@Override public Object provide(Object source, Object currentValue) { final RegistrationSelectExecutionYearBean bean = ((RegistrationSelectExecutionYearBean) source); final DegreeCurricularPlan degreeCurricularPlan = bean.getRegistration().getLastDegreeCurricularPlan(); final Set<CourseGroup> courseGroups = degreeCurricularPlan.getAllCoursesGroups(); courseGroups.removeAll(degreeCurricularPlan.getRoot().getCycleCourseGroups()); courseGroups.remove(degreeCurricularPlan.getRoot()); return courseGroups; }
@Override public ExecutionDegree getExecutionDegree() { if (semester != null && degreeCurricularPlan != null) { ExecutionDegree degree = degreeCurricularPlan.getExecutionDegreeByAcademicInterval(semester.getAcademicInterval()); return degree; } return null; }
/** * Checks if person belongs to curricular course. The unit path format should be: * IST{.<SubUnitAcronym>}.<DegreeAcronym>.<CurricularCourseAcronym> * * <p>Accepted roles: STUDENT and TEACHER * * @param person * @param groupCheckQuery * @return * @throws NonExistingServiceException * @throws ExcepcaoPersistencia */ private static Boolean checkExecutionCourseGroup(Person person, GroupCheckQuery groupCheckQuery) throws NonExistingServiceException { String[] unitAcronyms = groupCheckQuery.unitFullPath.split("\\."); if (!groupCheckQuery.roleType.equals("TEACHER") && !groupCheckQuery.roleType.equals("STUDENT")) { throw new NonExistingServiceException(); } Degree degree = getDegree(unitAcronyms); for (DegreeCurricularPlan degreeCurricularPlan : degree.getActiveDegreeCurricularPlans()) { ExecutionSemester executionSemester = getExecutionPeriod(groupCheckQuery.year, groupCheckQuery.semester); CurricularCourse curricularCourse = degreeCurricularPlan.getCurricularCourseByAcronym(unitAcronyms[4]); if (curricularCourse != null) { List<ExecutionCourse> executionCourses = curricularCourse.getExecutionCoursesByExecutionPeriod(executionSemester); for (ExecutionCourse executionCourse : executionCourses) { Group group; if (groupCheckQuery.roleType.equals("TEACHER")) { group = TeacherGroup.get(executionCourse); } else { group = StudentGroup.get(executionCourse); } if (group.isMember(person.getUser())) { return true; } } } } return false; }
@Override public boolean evaluate(Context context) { User user = Authenticate.getUser(); if (RoleType.SCIENTIFIC_COUNCIL.isMember(user)) { return true; } final DegreeCurricularPlan parentDegreeCurricularPlan = context.getParentCourseGroup().getParentDegreeCurricularPlan(); if (!parentDegreeCurricularPlan.isBolonhaDegree()) { return true; } if (AcademicAuthorizationGroup.get(AcademicOperationType.MANAGE_DEGREE_CURRICULAR_PLANS) .isMember(user) || RoleType.MANAGER.isMember(user) || RoleType.OPERATOR.isMember(user)) { return true; } return parentDegreeCurricularPlan.getCurricularPlanMembersGroup().isMember(user); }
@Override public Collection<ExecutionDegree> getSearchResults( Map<String, String> argsMap, String value, int maxCount) { final String executionYearOid = argsMap.get("executionYearOid"); final ExecutionYear executionYear = FenixFramework.getDomainObject(executionYearOid); final String searchValue = StringNormalizer.normalize(value); final List<ExecutionDegree> result = new ArrayList<ExecutionDegree>(); for (final ExecutionDegree executionDegree : executionYear.getExecutionDegreesSet()) { final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan(); final Degree degree = degreeCurricularPlan.getDegree(); if (match(searchValue, degreeCurricularPlan.getName()) || match(searchValue, degree.getNameI18N(executionYear).getContent()) || match(searchValue, degree.getSigla())) { result.add(executionDegree); if (result.size() >= maxCount) { break; } } } return result; }
@Override public Set<User> getMembers() { Set<User> users = new HashSet<>(); if (degreeType != null) { ExecutionYear year = ExecutionYear.readCurrentExecutionYear(); for (final ExecutionDegree executionDegree : year.getExecutionDegreesSet()) { final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan(); final Degree degree = degreeCurricularPlan.getDegree(); if (degree.getDegreeType().equals(degreeType)) { for (final Coordinator coordinator : executionDegree.getCoordinatorsListSet()) { User user = coordinator.getPerson().getUser(); if (user != null) { users.add(user); } } } } // for (Degree degree : Degree.readAllByDegreeType(degreeType)) { // users.addAll(getCoordinators(degree)); // } } if (degree != null) { users.addAll(getCoordinators(degree)); } if (degree == null && degreeType == null) { final ExecutionYear executionYear = ExecutionYear.readCurrentExecutionYear(); for (final ExecutionDegree executionDegree : executionYear.getExecutionDegreesSet()) { for (final Coordinator coordinator : executionDegree.getCoordinatorsListSet()) { User user = coordinator.getPerson().getUser(); if (user != null) { users.add(user); } } } } return users; }
@Atomic private static void createEnrolmentPeriodRestrictions(final DegreeCurricularPlan input) { final RootCourseGroup root = input.getRoot(); List<? extends ICurricularRule> rules = root.getCurricularRules( CurricularRuleType.ENROLMENT_PERIOD_RESTRICTIONS, (ExecutionYear) null); if (rules.isEmpty()) { new EnrolmentPeriodRestrictions(root, getBeginExecutionSemester(input, root)); logger.info( "Created {} for DCP {}", EnrolmentPeriodRestrictions.class.getSimpleName(), input.getPresentationName()); } else if (rules.size() > 1) { logger.error( "Possible error: found {} {} rules for DCP {}", rules.size(), EnrolmentPeriodRestrictions.class.getSimpleName(), input.getPresentationName()); } }
private static ExecutionSemester getBeginExecutionSemester( final DegreeCurricularPlan dcp, final RootCourseGroup root) { final Optional<Context> first = root.getChildContextsSet() .stream() .sorted( (o1, o2) -> o1.getBeginExecutionPeriod().compareTo(o2.getBeginExecutionPeriod())) .findFirst(); final ExecutionSemester result = first.isPresent() ? first.get().getBeginExecutionPeriod() : dcp.getFirstExecutionPeriodEnrolments(); return result; }
public ActionForward warmUpCacheForEnrolmentPeriodStart( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final ExecutionSemester ces = ExecutionSemester.readActualExecutionSemester(); final ExecutionSemester pes = ces == null ? null : ces.getPreviousExecutionPeriod(); if (ces != null && pes != null) { long s = System.currentTimeMillis(); for (final ExecutionCourse executionCourse : ces.getAssociatedExecutionCoursesSet()) { executionCourse.getName(); for (final CourseLoad courseLoad : executionCourse.getCourseLoadsSet()) { courseLoad.getType(); for (final Shift shift : courseLoad.getShiftsSet()) { shift.getNome(); for (final SchoolClass schoolClass : shift.getAssociatedClassesSet()) { schoolClass.getNome(); final ExecutionDegree executionDegree = schoolClass.getExecutionDegree(); final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan(); degreeCurricularPlan.getName(); final Degree degree = degreeCurricularPlan.getDegree(); degree.getDegreeType(); final RootCourseGroup root = degreeCurricularPlan.getRoot(); load(root); } for (final Lesson lesson : shift.getAssociatedLessonsSet()) { lesson.getBeginHourMinuteSecond(); for (OccupationPeriod period = lesson.getPeriod(); period != null; period = period.getNextPeriod()) { period.getStartDate(); } for (final LessonInstance lessonInstance : lesson.getLessonInstancesSet()) { lessonInstance.getBeginDateTime(); } } } } } long e = System.currentTimeMillis(); logger.info( "Warming up cache for enrolment period. Load of current semester information took {}ms.", e - s); s = System.currentTimeMillis(); // for (final RoomClassification roomClassification : // rootDomainObject.getRoomClassificationSet()) { // for (final RoomInformation roomInformation : // roomClassification.getRoomInformationsSet()) { // roomInformation.getDescription(); // final Room room = roomInformation.getRoom(); // room.getNormalCapacity(); // } // } e = System.currentTimeMillis(); logger.info("Warming up cache for enrolment period. Load of room listing took {}ms.", e - s); final Set<Student> students = new HashSet<Student>(); s = System.currentTimeMillis(); for (final Enrolment enrolment : pes.getEnrolmentsSet()) { students.add(enrolment.getStudent()); } e = System.currentTimeMillis(); logger.info("Warming up cache for enrolment period. Search for students took {}ms.", e - s); s = System.currentTimeMillis(); for (final Student student : students) { student.getNumber(); for (final Registration registration : student.getRegistrationsSet()) { registration.getNumber(); for (final StudentCurricularPlan studentCurricularPlan : registration.getStudentCurricularPlansSet()) { final RootCurriculumGroup root = studentCurricularPlan.getRoot(); load(root); } } } e = System.currentTimeMillis(); logger.info( "Warming up cache for enrolment period. Load of student curriculum took {}ms.", e - s); } return monitor(mapping, form, request, response); }