Esempio n. 1
0
  public BigDecimal getNumberOfApprovedEctsOneYearAgo() {
    ExecutionYear oneYearAgo = getForExecutionYear().getPreviousExecutionYear();
    BigDecimal result = BigDecimal.ZERO;

    if (student == null) {
      return BigDecimal.ZERO;
    }

    for (final Registration registration : student.getRegistrationsSet()) {

      if (registration.isBolonha() && registration.hasAnyEnrolmentsIn(oneYearAgo)) {
        result =
            result
                .add(
                    calculateApprovedECTS(
                        registration
                            .getLastStudentCurricularPlan()
                            .getAprovedEnrolmentsInExecutionPeriod(
                                oneYearAgo.getFirstExecutionPeriod())))
                .add(
                    calculateApprovedECTS(
                        registration
                            .getLastStudentCurricularPlan()
                            .getAprovedEnrolmentsInExecutionPeriod(
                                oneYearAgo.getLastExecutionPeriod())));
      }
    }

    return result;
  }
Esempio n. 2
0
  @Checked("RolePredicates.MASTER_DEGREE_ADMINISTRATIVE_OFFICE_PREDICATE")
  @Service
  public static List run(
      InfoStudent infoStudent, Specialization specialization, StudentCurricularPlanState state)
      throws Exception {

    List infoStudentCurricularPlanList = new ArrayList();

    Registration registration =
        Registration.readStudentByNumberAndDegreeType(
            infoStudent.getNumber(), infoStudent.getDegreeType());
    if (registration == null) {
      return null;
    }
    List studentCurricularPlanList =
        registration.getStudentCurricularPlansBySpecialization(specialization);

    if (studentCurricularPlanList == null || studentCurricularPlanList.isEmpty()) {
      return null;
    }

    for (Iterator iter = studentCurricularPlanList.iterator(); iter.hasNext(); ) {
      StudentCurricularPlan studentCurricularPlan = (StudentCurricularPlan) iter.next();

      if (studentCurricularPlan != null && studentCurricularPlan.getIdInternal() != null) {
        infoStudentCurricularPlanList.add(
            InfoStudentCurricularPlan.newInfoFromDomain(studentCurricularPlan));
      }
    }

    return infoStudentCurricularPlanList;
  }
  private void checkParameters(final RegistrationAcademicServiceRequestCreateBean bean) {
    final CurriculumGroup curriculumGroup = bean.getCurriculumGroup();
    final CourseGroup newCourseGroup = bean.getCourseGroup();
    final ExecutionYear executionYear = bean.getExecutionYear();
    final Registration registration = bean.getRegistration();

    if (curriculumGroup == null) {
      throw new DomainException("error.CourseGroupChangeRequest.curriculumGroup.cannot.be.null");
    }

    if (newCourseGroup == null) {
      throw new DomainException("error.CourseGroupChangeRequest.newCourseGroup.cannot.be.null");
    }

    if (executionYear == null) {
      throw new DomainException("error.CourseGroupChangeRequest.executionYear.cannot.be.null");
    }

    if (!registration.getLastStudentCurricularPlan().hasCurriculumModule(curriculumGroup)) {
      throw new DomainException("error.CourseGroupChangeRequest.invalid.curriculumGroup");
    }

    if (!registration.getLastDegreeCurricularPlan().hasDegreeModule(newCourseGroup)) {
      throw new DomainException("error.CourseGroupChangeRequest.invalid.newCourseGroup");
    }
  }
  protected Boolean run(
      final String executionCourseCode, final String groupPropertiesCode, final String[] selected)
      throws FenixServiceException {

    if (selected == null) {
      return Boolean.TRUE;
    }

    final Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesCode);
    if (groupProperties == null) {
      throw new ExistingServiceException();
    }

    final List<ExecutionCourse> executionCourses = groupProperties.getExecutionCourses();
    StringBuilder sbStudentNumbers = new StringBuilder("");
    sbStudentNumbers.setLength(0);
    // studentCodes list has +1 entry if "select all" was selected
    int totalStudentsProcessed = 0;

    for (final String number : selected) {
      if (number.equals("Todos os Alunos")) {
      } else {
        Registration registration = FenixFramework.getDomainObject(number);
        if (!studentHasSomeAttendsInGrouping(registration, groupProperties)) {
          final Attends attends = findAttends(registration, executionCourses);
          if (attends != null) {
            if (sbStudentNumbers.length() != 0) {
              sbStudentNumbers.append(", " + registration.getNumber().toString());
            } else {
              sbStudentNumbers.append(registration.getNumber().toString());
            }
            totalStudentsProcessed++;
            groupProperties.addAttends(attends);
          }
        }
      }
    }

    if (totalStudentsProcessed > 0) {
      List<ExecutionCourse> ecs = groupProperties.getExecutionCourses();
      for (ExecutionCourse ec : ecs) {
        GroupsAndShiftsManagementLog.createLog(
            ec,
            Bundle.MESSAGING,
            "log.executionCourse.groupAndShifts.grouping.attends.added",
            Integer.toString(totalStudentsProcessed),
            sbStudentNumbers.toString(),
            groupProperties.getName(),
            ec.getNome(),
            ec.getDegreePresentationString());
      }
    }

    return Boolean.TRUE;
  }
Esempio n. 5
0
  private static void checkOldStudentNumber(Integer studentNumber, Person person)
      throws ExistingServiceException {
    if (studentNumber != null) {

      Registration existingStudent =
          Registration.readStudentByNumberAndDegreeType(studentNumber, DegreeType.MASTER_DEGREE);

      if (existingStudent != null && !existingStudent.getPerson().equals(person)) {
        throw new ExistingServiceException();
      }
    }
  }
  private boolean hasAnyValidRegistration(final DegreeChangeIndividualCandidacyEvent event) {
    if (!event.hasCandidacyStudent()) {
      return false;
    }

    final List<Registration> registrations =
        event.getCandidacyStudent().getRegistrationsFor(event.getCandidacyDegree());
    for (final Registration registration : event.getCandidacyStudent().getRegistrationsSet()) {
      if (!registrations.contains(registration) && !registration.isCanceled()) {
        return true;
      }
    }

    return false;
  }
Esempio n. 7
0
  public static Collection<ExecutionYear> getEnrolmentsExecutionYears(final Student student) {
    Set<ExecutionYear> executionYears = new HashSet<ExecutionYear>();
    for (final Registration registration : student.getRegistrationsSet()) {
      if (RegistrationStateType.CANCELED.equals(registration.getLastActiveState())) {
        continue;
      }

      if (RegistrationStateType.TRANSITION.equals(registration.getLastActiveState())) {
        continue;
      }

      executionYears.addAll(registration.getEnrolmentsExecutionYears());
    }

    return executionYears;
  }
Esempio n. 8
0
  private double getEnrolmentsEctsCredits(
      final Registration registration, final ExecutionYear executionYear) {
    double result = 0.0;
    double annualCredits = 0.0;

    for (final ExecutionSemester executionSemester : executionYear.getExecutionPeriodsSet()) {
      for (final Enrolment enrolment :
          registration.getLastStudentCurricularPlan().getEnrolmentsSet()) {
        if (enrolment.isValid(executionSemester)) {
          if (enrolment.isAnual()) {
            this.enrolledInAnualCoursesLastYear = true;

            if (executionSemester.getSemester() == 1) {
              annualCredits += enrolment.getEctsCredits();
            }
            continue;
          }

          result += enrolment.getEctsCredits();
        }
      }
    }

    return result + annualCredits;
  }
Esempio n. 9
0
  public BigDecimal getNumberOfEnrolledEctsOneYearAgo() {
    ExecutionYear oneYearAgo = getForExecutionYear().getPreviousExecutionYear();
    BigDecimal result = BigDecimal.ZERO;

    if (student == null) {
      return BigDecimal.ZERO;
    }

    for (final Registration registration : student.getRegistrationsSet()) {
      if (registration.isBolonha() && registration.hasAnyEnrolmentsIn(oneYearAgo)) {
        result = result.add(new BigDecimal(getEnrolmentsEctsCredits(registration, oneYearAgo)));
      }
    }

    return result;
  }
Esempio n. 10
0
  private Registration getActiveRegistration(Student student) {
    List<Registration> activeRegistrations = student.getActiveRegistrations();

    if (activeRegistrations.isEmpty()) {
      return student.getLastRegistration();
    }

    for (Registration registration : activeRegistrations) {
      if (registration.getDegree().getDegreeType().isEmpty()) {
        continue;
      }

      return registration;
    }

    return student.getLastRegistration();
  }
Esempio n. 11
0
 private String getDegrees(final Person person) {
   final StringBuilder stringBuilder = new StringBuilder();
   final Student student = person.getStudent();
   if (student != null) {
     final Set<String> names = new TreeSet<String>();
     for (final Registration registration : student.getRegistrationsSet()) {
       final Degree degree = registration.getDegree();
       names.add(degree.getSigla());
     }
     for (final String name : names) {
       if (stringBuilder.length() > 0) {
         stringBuilder.append(", ");
       }
       stringBuilder.append(name);
     }
   }
   return stringBuilder.toString();
 }
Esempio n. 12
0
  public ActionForward chooseStudent(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final StudentContextSelectionBean studentContextSelectionBean = getRenderedObject();

    final String number = studentContextSelectionBean.getNumber();
    if (number != null && !number.isEmpty()) {
      final AcademicInterval academicInterval = studentContextSelectionBean.getAcademicInterval();
      final ExecutionInterval executionInterval =
          ExecutionInterval.getExecutionInterval(academicInterval);

      final SearchParameters searchParameters = new SearchParameters();
      if (StringUtils.isNumeric(number)) {
        searchParameters.setStudentNumber(Integer.valueOf(number));
      } else {
        searchParameters.setUsername(number);
      }
      final CollectionPager<Person> people =
          new SearchPerson()
              .run(searchParameters, new SearchPerson.SearchPersonPredicate(searchParameters));
      final Collection<Registration> registrations = new ArrayList<Registration>();
      for (final Person person : people.getCollection()) {
        if (person.getStudent() != null) {
          for (final Registration registration : person.getStudent().getRegistrationsSet()) {
            if (registration.hasAnyActiveState((ExecutionSemester) executionInterval)) {
              registrations.add(registration);
            }
          }
        }
      }

      if (studentContextSelectionBean.getToEdit()) {
        request.setAttribute("toEditScheduleRegistrations", registrations);
      } else {
        request.setAttribute("registrations", registrations);
        request.setAttribute("timeTableExecutionSemester", executionInterval);
      }
    }

    return prepare(mapping, form, request, response);
  }
 public static Attends findAttends(
     final Registration registration, final List<ExecutionCourse> executionCourses) {
   for (final ExecutionCourse executionCourse : executionCourses) {
     final Attends attends = registration.readAttendByExecutionCourse(executionCourse);
     if (attends != null) {
       return attends;
     }
   }
   return null;
 }
Esempio n. 14
0
  public Integer getCountNumberOfDegreeChanges() {
    int numberOfDegreeChanges = 0;

    if (student == null) {
      return 0;
    }

    List<Registration> registrations = new ArrayList<Registration>(student.getRegistrationsSet());
    Collections.sort(registrations, Registration.COMPARATOR_BY_START_DATE);
    for (final Registration iter : registrations) {
      final SortedSet<RegistrationState> states =
          new TreeSet<RegistrationState>(RegistrationState.DATE_COMPARATOR);
      states.addAll(iter.getRegistrationStates(RegistrationStateType.INTERNAL_ABANDON));
      if (!states.isEmpty()) {
        numberOfDegreeChanges++;
      }
    }

    return numberOfDegreeChanges;
  }
  private final Collection<ICurriculumEntry> getEntriesToReport(final boolean useConcluded) {
    final HashSet<ICurriculumEntry> result = new HashSet<ICurriculumEntry>();

    final Registration registration = getRegistration();
    ICurriculum curriculum;
    if (registration.isBolonha()) {
      for (final CycleCurriculumGroup cycle :
          registration.getLastStudentCurricularPlan().getInternalCycleCurriculumGrops()) {
        if (cycle.hasAnyApprovedCurriculumLines()
            && (useConcluded || !cycle.isConclusionProcessed())) {
          curriculum = cycle.getCurriculum(getFilteringDate());
          filterEntries(result, this, curriculum);
        }
      }
    } else {
      curriculum = getRegistration().getCurriculum(getFilteringDate());
      filterEntries(result, this, curriculum);
    }

    return result;
  }
 @Atomic
 private static OutboundMobilityCandidacySubmission getOutboundMobilityCandidacySubmission(
     final OutboundMobilityCandidacyContest contest, final Registration registration) {
   final OutboundMobilityCandidacyPeriod candidacyPeriod =
       contest.getOutboundMobilityCandidacyPeriod();
   for (final OutboundMobilityCandidacySubmission submission :
       registration.getOutboundMobilityCandidacySubmissionSet()) {
     if (submission.getOutboundMobilityCandidacyPeriod() == candidacyPeriod) {
       return submission;
     }
   }
   return new OutboundMobilityCandidacySubmission(candidacyPeriod, registration);
 }
Esempio n. 17
0
  public boolean fillWithStudent(final ExecutionYear forExecutionYear, Student student) {
    this.forExecutionYear = forExecutionYear;

    try {
      this.institutionCode = getDefaultInstitutionCode();
      this.institutionName = getDefaultInstitutionName();
      this.candidacyNumber = "";

      this.studentNumber = student.getNumber();

      this.studentName = student.getPerson().getName();
      this.documentTypeName = student.getPerson().getIdDocumentType().getLocalizedName();
      this.documentNumber = student.getPerson().getDocumentIdNumber();
      Registration activeRegistration = getActiveRegistration(student);

      this.degreeCode = activeRegistration.getDegree().getMinistryCode();

      if ("9999".equals(this.degreeCode)) {
        this.degreeCode = "";
      }

      this.degreeName = activeRegistration.getDegree().getNameI18N().getContent();
      this.degreeTypeName = activeRegistration.getDegree().getDegreeTypeName();

      this.upperObservations = "";

      this.person = student.getPerson();
      this.student = student;
      enrolledInAnualCoursesLastYear = false;
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      return false;
    }

    return true;
  }
Esempio n. 18
0
  @Checked("RolePredicates.STUDENT_PREDICATE")
  @Service
  public static Boolean run(Integer studentGroupCode, String username)
      throws FenixServiceException {

    final StudentGroup studentGroup = rootDomainObject.readStudentGroupByOID(studentGroupCode);
    if (studentGroup == null) {
      throw new InvalidArgumentsServiceException();
    }
    final Registration registration = Registration.readByUsername(username);
    if (registration == null) {
      throw new InvalidArgumentsServiceException();
    }

    final Grouping grouping = studentGroup.getGrouping();
    final Attends studentAttend = grouping.getStudentAttend(registration);
    if (studentAttend == null) {
      throw new NotAuthorizedException();
    }
    if (studentGroup.getAttends().contains(studentAttend)) {
      throw new InvalidSituationServiceException();
    }

    final IGroupEnrolmentStrategyFactory enrolmentGroupPolicyStrategyFactory =
        GroupEnrolmentStrategyFactory.getInstance();
    final IGroupEnrolmentStrategy strategy =
        enrolmentGroupPolicyStrategyFactory.getGroupEnrolmentStrategyInstance(grouping);

    boolean result = strategy.checkPossibleToEnrolInExistingGroup(grouping, studentGroup);
    if (!result) {
      throw new InvalidArgumentsServiceException();
    }

    checkIfStudentIsNotEnrolledInOtherGroups(
        grouping.getStudentGroups(), studentGroup, studentAttend);

    studentGroup.addAttends(studentAttend);

    informStudents(studentGroup, registration, grouping);

    return Boolean.TRUE;
  }
Esempio n. 19
0
 public StudentCurricularPlan getStudentCurricularPlan() {
   final Registration registration = getRegistration();
   return registration == null ? null : registration.getLastStudentCurricularPlan();
 }
  @Override
  public void renderReport(final Spreadsheet spreadsheet) throws Exception {
    spreadsheet.setHeader("Número");
    spreadsheet.setHeader("Sexo");
    spreadsheet.setHeader("Média");
    spreadsheet.setHeader("Média Anual");
    spreadsheet.setHeader("Número Inscrições");
    spreadsheet.setHeader("Número Aprovações");
    spreadsheet.setHeader("Nota de Seriação");
    spreadsheet.setHeader("Local de Origem");

    final ExecutionYear executionYear = getExecutionYear();
    for (final Degree degree : Degree.readNotEmptyDegrees()) {
      if (checkDegreeType(getDegreeType(), degree)) {
        if (isActive(degree)) {
          for (final Registration registration : degree.getRegistrationsSet()) {
            if (registration.isRegistered(getExecutionYear())) {

              int enrolmentCounter = 0;
              int aprovalCounter = 0;
              BigDecimal bigDecimal = null;
              double totalCredits = 0;

              for (final Registration otherRegistration :
                  registration.getStudent().getRegistrationsSet()) {
                if (otherRegistration.getDegree() == registration.getDegree()) {
                  for (final StudentCurricularPlan studentCurricularPlan :
                      otherRegistration.getStudentCurricularPlansSet()) {
                    for (final Enrolment enrolment : studentCurricularPlan.getEnrolmentsSet()) {
                      final ExecutionSemester executionSemester = enrolment.getExecutionPeriod();
                      if (executionSemester.getExecutionYear() == executionYear) {
                        enrolmentCounter++;
                        if (enrolment.isApproved()) {
                          aprovalCounter++;
                          final Grade grade = enrolment.getGrade();
                          if (grade.isNumeric()) {
                            final double credits =
                                enrolment.getEctsCreditsForCurriculum().doubleValue();
                            totalCredits += credits;
                            bigDecimal =
                                bigDecimal == null
                                    ? grade.getNumericValue().multiply(new BigDecimal(credits))
                                    : bigDecimal.add(
                                        grade.getNumericValue().multiply(new BigDecimal(credits)));
                          }
                        }
                      }
                    }
                  }
                }
              }

              final Row row = spreadsheet.addRow();
              row.setCell(registration.getNumber().toString());
              row.setCell(registration.getPerson().getGender().toLocalizedString());
              row.setCell(registration.getAverage(executionYear));
              if (bigDecimal == null) {
                row.setCell("");
              } else {
                row.setCell(
                    bigDecimal.divide(new BigDecimal(totalCredits), 5, RoundingMode.HALF_UP));
              }
              row.setCell(Integer.toString(enrolmentCounter));
              row.setCell(Integer.toString(aprovalCounter));
              row.setCell(
                  registration.getEntryGrade() != null
                      ? registration.getEntryGrade().toString()
                      : StringUtils.EMPTY);
              Boolean dislocated = null;
              if (registration.hasStudentCandidacy()) {
                dislocated =
                    registration.getStudentCandidacy().getDislocatedFromPermanentResidence();
              }

              final String dislocatedString =
                  dislocated == null
                      ? ""
                      : (dislocated.booleanValue() ? "Deslocado" : "Não Deslocado");
              row.setCell(dislocatedString);
            }
          }
        }
      }
    }
  }
  @SuppressWarnings("unchecked")
  private ByteArrayOutputStream createAcademicAdminProcessSheet(Person person) throws JRException {
    InputStream istream = getClass().getResourceAsStream(ACADEMIC_ADMIN_SHEET_REPORT_PATH);
    JasperReport report = (JasperReport) JRLoader.loadObject(istream);

    @SuppressWarnings("rawtypes")
    HashMap map = new HashMap();

    try {
      final Student student = person.getStudent();
      final Registration registration = findRegistration(student);

      map.put("executionYear", ExecutionYear.readCurrentExecutionYear().getYear());
      if (registration != null) {
        map.put("course", registration.getDegree().getNameI18N().toString());
      }
      map.put("studentNumber", student.getNumber().toString());
      map.put("fullName", person.getName());

      try {
        map.put(
            "photo",
            new ByteArrayInputStream(person.getPersonalPhotoEvenIfPending().getDefaultAvatar()));
      } catch (Exception e) {
        // nothing; print everything else
      }

      map.put(
          "sex",
          BundleUtil.getStringFromResourceBundle(
              "resources/EnumerationResources", person.getGender().name()));
      map.put("maritalStatus", person.getMaritalStatus().getPresentationName());
      map.put("profession", person.getProfession());
      map.put("idDocType", person.getIdDocumentType().getLocalizedName());
      map.put("idDocNumber", person.getDocumentIdNumber());

      YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay();
      if (emissionDate != null) {
        map.put(
            "idDocEmissionDate", emissionDate.toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      }

      map.put(
          "idDocExpirationDate",
          person
              .getExpirationDateOfDocumentIdYearMonthDay()
              .toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      map.put("idDocEmissionLocation", person.getEmissionLocationOfDocumentId());

      String nif = person.getSocialSecurityNumber();
      if (nif != null) {
        map.put("NIF", nif);
      }

      map.put(
          "birthDate",
          person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      map.put("nationality", person.getCountryOfBirth().getCountryNationality().toString());
      map.put("parishOfBirth", person.getParishOfBirth());
      map.put("districtSubdivisionOfBirth", person.getDistrictSubdivisionOfBirth());
      map.put("districtOfBirth", person.getDistrictOfBirth());
      map.put("countryOfBirth", person.getCountryOfBirth().getName());
      map.put("fathersName", person.getNameOfFather());
      map.put("mothersName", person.getNameOfMother());
      map.put("address", person.getAddress());
      map.put("postalCode", person.getPostalCode());
      map.put("locality", person.getAreaOfAreaCode());
      map.put("cellphoneNumber", person.getDefaultMobilePhoneNumber());
      map.put("telephoneNumber", person.getDefaultPhoneNumber());
      map.put("emailAddress", getMail(person));
      map.put(
          "currentDate",
          new java.text.SimpleDateFormat(
                  "'Lisboa, 'dd' de 'MMMM' de 'yyyy", new java.util.Locale("PT", "pt"))
              .format(new java.util.Date()));
    } catch (NullPointerException e) {
      // nothing; will cause printing of incomplete form
      // better than no form at all
    }

    JasperPrint print = JasperFillManager.fillReport(report, map);
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    JasperExportManager.exportReportToPdfStream(print, output);
    return output;
  }
Esempio n. 22
0
  public Integer getCurricularYearInCurrentYear() {
    ExecutionYear currentYear = getForExecutionYear();

    if (student == null) {
      return 0;
    }

    Registration lastRegistration = student.getLastActiveRegistration();

    if (lastRegistration == null) {
      return null;
    }

    if (lastRegistration.getDegreeType().equals(DegreeType.BOLONHA_DEGREE)) {
      return lastRegistration
          .getCurriculum(new DateTime(), currentYear, CycleType.FIRST_CYCLE)
          .getCurricularYear();
    } else if (lastRegistration
        .getDegreeType()
        .equals(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE)) {
      if (lastRegistration.hasConcludedFirstCycle()) {
        return lastRegistration.getCurricularYear(currentYear);
      } else {
        if (lastRegistration.getLastStudentCurricularPlan().getCycle(CycleType.FIRST_CYCLE)
            != null) {
          return lastRegistration
              .getCurriculum(new DateTime(), currentYear, CycleType.FIRST_CYCLE)
              .getCurricularYear();
        } else {
          return lastRegistration
              .getCurriculum(new DateTime(), currentYear, CycleType.SECOND_CYCLE)
              .getCurricularYear();
        }
      }
    } else if (lastRegistration.getDegreeType().equals(DegreeType.BOLONHA_MASTER_DEGREE)) {
      return lastRegistration.getCurricularYear(currentYear);
    }

    return lastRegistration.getCurricularYear(currentYear);
  }