Пример #1
0
  /*
   * DOMAIN SERVICES
   */
  public static YearDelegateElection createDelegateElectionWithCandidacyPeriod(
      Degree degree,
      ExecutionYear executionYear,
      YearMonthDay candidacyPeriodStartDate,
      YearMonthDay candidacyPeriodEndDate,
      CurricularYear curricularYear) {

    DelegateElectionCandidacyPeriod period =
        new DelegateElectionCandidacyPeriod(candidacyPeriodStartDate, candidacyPeriodEndDate);
    checkNewElectionCandidacyPeriod(degree, executionYear, curricularYear, period);

    /* Checks if there is a previous delegate election and its state */
    checkPreviousDelegateElectionExistence(degree, curricularYear, executionYear);

    YearDelegateElection election =
        new YearDelegateElection(executionYear, degree, curricularYear, period);

    /* Add degree students to election students list */
    for (DegreeCurricularPlan dcp : degree.getActiveDegreeCurricularPlans()) {
      for (StudentCurricularPlan scp : dcp.getActiveStudentCurricularPlans()) {
        if (scp.getRegistration().getCurricularYear(executionYear) == curricularYear.getYear()) {
          if (!hasDelegateElection(election, scp)) {
            election.addStudents(scp.getRegistration().getStudent());
          }
        }
      }
    }

    return election;
  }
Пример #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;
  }
  protected void run(String year) {

    gratuitySituationsToDelete = new HashSet<GratuitySituation>();

    ExecutionYear executionYear = readExecutionYear(year);

    // read master degree and persistentSupportecialization execution
    // degrees
    Collection<ExecutionDegree> executionDegrees =
        executionYear.getExecutionDegreesByType(DegreeType.MASTER_DEGREE);

    for (ExecutionDegree executionDegree : executionDegrees) {

      GratuityValues gratuityValues = executionDegree.getGratuityValues();

      if (gratuityValues == null) {
        continue;
      }

      this.firstYear = executionDegree.isFirstYear();

      Collection<StudentCurricularPlan> studentCurricularPlans =
          executionDegree.getDegreeCurricularPlan().getStudentCurricularPlans();
      for (StudentCurricularPlan studentCurricularPlan : studentCurricularPlans) {

        GratuitySituation gratuitySituation =
            studentCurricularPlan.getGratuitySituationByGratuityValues(gratuityValues);

        if (year.equals("2002/2003") && gratuitySituation.getTransactionListSet().size() == 0) {
          gratuitySituation.setEmployee(null);
          gratuitySituation.setGratuityValues(null);
          gratuitySituation.setStudentCurricularPlan(null);
          this.gratuitySituationsToDelete.add(gratuitySituation);
          continue;
        }

        if (gratuitySituation == null) {
          createGratuitySituation(gratuityValues, studentCurricularPlan);
        } else {
          updateGratuitySituation(gratuitySituation);
        }
      }
    }

    for (GratuitySituation gratuitySituationToDelete : this.gratuitySituationsToDelete) {
      gratuitySituationToDelete.delete();
    }
  }
  @Override
  public Double calculateStudentWeightedAverage(StudentCurricularPlan studentCurricularPlan) {
    float marks = 0;
    float numberOfWeigths = 0;

    for (Enrolment enrolment : studentCurricularPlan.getEnrolmentsSet()) {

      if (enrolment.isEnrolmentStateApproved()
          && !enrolment
              .getCurricularCourse()
              .getType()
              .equals(CurricularCourseType.P_TYPE_COURSE)) {
        if (!enrolment.isExtraCurricular()) {
          final Grade grade = enrolment.getGrade();
          if (grade.isNumeric()) {
            int enrolmentMark = Integer.valueOf(grade.getValue());
            double enrolmentWeight = enrolment.getCurricularCourse().getCredits();

            if (enrolmentMark > 0) {
              marks += (enrolmentMark * enrolmentWeight);
              numberOfWeigths += enrolmentWeight;
            }
          } else {
            // This mark will not count for the average
          }
        }
      }
    }

    if (marks == 0) {
      return new Double(0);
    }

    return NumberUtils.formatNumber(new Double(marks / numberOfWeigths), 1);
  }
  protected void createCandidacyPrecedentDegreeInformation(
      final IndividualCandidacyProcessWithPrecedentDegreeInformationBean bean,
      final StudentCurricularPlan studentCurricularPlan) {

    if (studentCurricularPlan.isBolonhaDegree()) {
      final CycleType cycleType;

      if (studentCurricularPlan.hasConcludedAnyInternalCycle()) {
        cycleType = studentCurricularPlan.getLastConcludedCycleCurriculumGroup().getCycleType();
      } else {
        cycleType = studentCurricularPlan.getLastOrderedCycleCurriculumGroup().getCycleType();
      }

      bean.setPrecedentDegreeInformation(
          PrecedentDegreeInformationBeanFactory.createBean(studentCurricularPlan, cycleType));
    } else {
      bean.setPrecedentDegreeInformation(
          PrecedentDegreeInformationBeanFactory.createBean(studentCurricularPlan));
    }
  }
  /**
   * @param gratuityValues
   * @param studentCurricularPlan
   * @throws ExcepcaoPersistencia
   */
  private void createGratuitySituation(
      GratuityValues gratuityValues, StudentCurricularPlan studentCurricularPlan) {

    if (studentCurricularPlan
            .getSpecialization()
            .equals(Specialization.STUDENT_CURRICULAR_PLAN_SPECIALIZATION)
        && !this.firstYear) {
      return;
    }

    new GratuitySituation(gratuityValues, studentCurricularPlan);
  }
Пример #7
0
 private static boolean hasDelegateElection(
     YearDelegateElection election, StudentCurricularPlan scp) {
   for (DelegateElection delegateElection :
       scp.getRegistration().getStudent().getDelegateElections()) {
     if (delegateElection instanceof YearDelegateElection) {
       if (delegateElection.getDegree().equals(election.getDegree())
           && delegateElection.getExecutionYear().equals(election.getExecutionYear())
           && (delegateElection.hasLastVotingPeriod()
               && !delegateElection.getLastVotingPeriod().isPastPeriod())) {
         return true;
       }
     }
   }
   return false;
 }
Пример #8
0
 private static InfoCandidateRegistration createNewInfoCandidateRegistration(
     MasterDegreeCandidate masterDegreeCandidate, StudentCurricularPlan studentCurricularPlan) {
   InfoCandidateRegistration infoCandidateRegistration = new InfoCandidateRegistration();
   infoCandidateRegistration.setInfoMasterDegreeCandidate(
       InfoMasterDegreeCandidateWithInfoPerson.newInfoFromDomain(masterDegreeCandidate));
   infoCandidateRegistration.setInfoStudentCurricularPlan(
       InfoStudentCurricularPlan.newInfoFromDomain(studentCurricularPlan));
   infoCandidateRegistration.setEnrolments(new ArrayList<InfoEnrolment>());
   Iterator<Enrolment> iteratorSCPs = studentCurricularPlan.getEnrolmentsSet().iterator();
   while (iteratorSCPs.hasNext()) {
     Enrolment enrolment = iteratorSCPs.next();
     infoCandidateRegistration.getEnrolments().add(InfoEnrolment.newInfoFromDomain(enrolment));
   }
   return infoCandidateRegistration;
 }
Пример #9
0
  private static StudentCurricularPlan createNewStudentCurricularPlan(
      Registration registration, String branchID, MasterDegreeCandidate masterDegreeCandidate) {
    Branch branch = FenixFramework.getDomainObject(branchID);
    DegreeCurricularPlan degreecurricularPlan =
        masterDegreeCandidate.getExecutionDegree().getDegreeCurricularPlan();

    StudentCurricularPlan studentCurricularPlan =
        StudentCurricularPlan.createPreBolonhaMasterDegree(
            registration,
            degreecurricularPlan,
            new YearMonthDay(),
            branch,
            masterDegreeCandidate.getGivenCredits(),
            masterDegreeCandidate.getSpecialization());
    return studentCurricularPlan;
  }
Пример #10
0
  @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);
            }
          }
        }
      }
    }
  }