Ejemplo n.º 1
0
  private Map<BranchCourseGroup, String> generateAverageByBranch(
      YearViewBean bean, BranchType bType) {
    Map<BranchCourseGroup, String> result =
        new TreeMap<BranchCourseGroup, String>(BranchCourseGroup.COMPARATOR_BY_NAME);

    Set<BranchCourseGroup> branches = bean.getDegreeCurricularPlan().getBranchesByType(bType);

    Map<BranchCourseGroup, BigDecimal> sigma = new HashMap<BranchCourseGroup, BigDecimal>();
    Map<BranchCourseGroup, BigDecimal> cardinality = new HashMap<BranchCourseGroup, BigDecimal>();
    Map<BranchCourseGroup, BigDecimal> average = new HashMap<BranchCourseGroup, BigDecimal>();

    for (BranchCourseGroup branch : branches) {
      sigma.put(branch, new BigDecimal(0));
      cardinality.put(branch, new BigDecimal(0));
      average.put(branch, new BigDecimal(0));
    }

    for (Enrolment enrol : bean.getEnrolments()) {
      BranchCourseGroup branch =
          enrol.getParentBranchCurriculumGroup() != null
              ? enrol.getParentBranchCurriculumGroup().getDegreeModule()
              : null;
      if (branch == null || branch.getBranchType() != bType) {
        continue;
      }

      Grade grade = enrol.getGrade();
      if (grade.isApproved() && grade.getGradeScale() == GradeScale.TYPE20) {
        BigDecimal biggy = sigma.get(branch);
        BigDecimal smalls = biggy.add(grade.getNumericValue());
        sigma.put(branch, smalls);

        BigDecimal notorious = cardinality.get(branch);
        BigDecimal big = notorious.add(BigDecimal.ONE);
        cardinality.put(branch, big);
      }
    }

    for (BranchCourseGroup branch : branches) {
      if (cardinality.get(branch).compareTo(BigDecimal.ZERO) == 0) {
        result.put(branch, "-");
      } else {
        result.put(
            branch,
            (sigma.get(branch))
                .divide(cardinality.get(branch), 2, RoundingMode.HALF_EVEN)
                .toPlainString());
      }
    }

    return result;
  }
Ejemplo n.º 2
0
  private Map<CurricularYear, String> generateAverageByCurricularYear(YearViewBean bean) {
    Map<CurricularYear, String> result =
        new TreeMap<CurricularYear, String>(
            new Comparator() {
              @Override
              public int compare(Object year1, Object year2) {
                return ((CurricularYear) year1)
                    .getYear()
                    .compareTo(((CurricularYear) year2).getYear());
              }
            });

    int years = bean.getDegreeCurricularPlan().getDegree().getDegreeType().getYears();

    BigDecimal[] sigma = new BigDecimal[years + 1];
    BigDecimal[] cardinality = new BigDecimal[years + 1];
    BigDecimal[] average = new BigDecimal[years + 1];

    for (int i = 1; i <= years; i++) {
      sigma[i] = new BigDecimal(0);
      cardinality[i] = new BigDecimal(0);
      average[i] = new BigDecimal(0);
    }

    for (Enrolment enrol : bean.getEnrolments()) {
      CurricularYear year = CurricularYear.readByYear(enrol.getRegistration().getCurricularYear());
      Grade grade = enrol.getGrade();
      if (grade.isApproved() && grade.getGradeScale() == GradeScale.TYPE20) {
        BigDecimal biggy = sigma[year.getYear()];
        BigDecimal smalls = biggy.add(grade.getNumericValue());
        sigma[year.getYear()] = smalls;

        BigDecimal notorious = cardinality[year.getYear()];
        BigDecimal big = notorious.add(BigDecimal.ONE);
        cardinality[year.getYear()] = big;
      }
    }

    for (int i = 1; i <= years; i++) {
      if (cardinality[i].compareTo(BigDecimal.ZERO) == 0) {
        result.put(CurricularYear.readByYear(i), "-");
      } else {
        result.put(
            CurricularYear.readByYear(i),
            sigma[i].divide(cardinality[i], 2, RoundingMode.HALF_EVEN).toPlainString());
      }
    }

    return result;
  }
Ejemplo n.º 3
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);
            }
          }
        }
      }
    }
  }