示例#1
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;
  }
示例#2
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();
  }
示例#3
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();
 }
  @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;
  }
  @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);
            }
          }
        }
      }
    }
  }