protected List<SelectItem> readExecutionYearItems() {
    final List<SelectItem> result = new ArrayList<SelectItem>();

    final Collection<ExecutionDegree> executionDegrees =
        getDegreeCurricularPlan().getExecutionDegreesSet();

    if (executionDegrees.isEmpty()) {
      final ExecutionYear executionYear =
          getDegreeCurricularPlan().getRoot().getMinimumExecutionPeriod().getExecutionYear();
      result.add(new SelectItem(executionYear.getExternalId(), executionYear.getYear()));
      return result;
    }

    for (ExecutionDegree executionDegree : executionDegrees) {
      result.add(
          new SelectItem(
              executionDegree.getExecutionYear().getExternalId(),
              executionDegree.getExecutionYear().getYear()));
    }

    if (getExecutionYearID() == null) {
      setExecutionYearID(
          getDegreeCurricularPlan()
              .getMostRecentExecutionDegree()
              .getExecutionYear()
              .getExternalId());
    }

    return result;
  }
  public ActionForward exportResultsToFile(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String degreeTypeString = (String) getFromRequest(request, "degreeType");
    DegreeType degreeType = DegreeType.valueOf(degreeTypeString);
    ExecutionYear executionYear = getDomainObject(request, "executionYearOID");
    StyledExcelSpreadsheet spreadsheet =
        YearDelegateElection.exportElectionsResultsToFile(
            Degree.readAllByDegreeType(degreeType), executionYear);

    final ServletOutputStream writer = response.getOutputStream();
    spreadsheet.getWorkbook().write(writer);
    response.setContentType("application/txt");
    final String filename =
        String.format(
            "electionsResults_%s_%s.xls",
            degreeType.getLocalizedName(), executionYear.getYear().replace("/", "-"));
    response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
    writer.flush();
    response.flushBuffer();
    return null;
  }
Exemplo n.º 3
0
 /*
  * Checks if given period belongs to given execution year
  */
 private void validatePeriodGivenExecutionYear(
     ExecutionYear executionYear, DelegateElectionPeriod period) {
   if (period.getStartDate().isBefore(executionYear.getBeginDateYearMonthDay())
       || period.getEndDate().isAfter(executionYear.getEndDateYearMonthDay())) {
     throw new DomainException(
         "error.elections.setPeriod.invalidPeriod",
         new String[] {
           getDegree().getSigla(),
           getCurricularYear().getYear().toString(),
           period.getPeriod(),
           executionYear.getYear()
         });
   }
 }
Exemplo n.º 4
0
  private VirtualPath getVirtualPath(Site site, Container container) {

    List<Content> contents = site.getPathTo(container);

    final VirtualPath filePath = new VirtualPath();

    for (Content content : contents.subList(1, contents.size())) {
      filePath.addNode(
          0,
          new VirtualPathNode(
              content.getClass().getSimpleName().substring(0, 1) + content.getExternalId(),
              content.getName().getContent()));
    }

    String authorName = site.getAuthorName();
    filePath.addNode(
        0,
        new VirtualPathNode(
            "Site" + site.getExternalId(),
            authorName == null ? "Site" + site.getExternalId() : authorName));

    ExecutionSemester executionSemester = site.getExecutionPeriod();
    if (executionSemester == null) {
      filePath.addNode(0, new VirtualPathNode("Intemporal", "Intemporal"));
    } else {
      filePath.addNode(
          0,
          new VirtualPathNode(
              "EP" + executionSemester.getExternalId(), executionSemester.getName()));

      ExecutionYear executionYear = executionSemester.getExecutionYear();
      filePath.addNode(
          0, new VirtualPathNode("EY" + executionYear.getExternalId(), executionYear.getYear()));
    }

    filePath.addNode(0, new VirtualPathNode("Courses", "Courses"));
    return filePath;
  }
Exemplo n.º 5
0
  @Override
  protected String getMessage(Thesis thesis) {
    Person currentPerson = AccessControl.getPerson();
    ExecutionYear executionYear = ExecutionYear.readCurrentExecutionYear();

    String title = thesis.getTitle().getContent();
    String year = executionYear.getYear();
    String degreeName = thesis.getDegree().getNameFor(executionYear).getContent();
    String studentName = thesis.getStudent().getPerson().getName();
    String studentNumber = thesis.getStudent().getNumber().toString();
    String presidentName = name(thesis.getPresident());
    String presidentAffiliation = affiliation(thesis.getPresident());
    String orientatorName = name(thesis.getOrientator());
    String orientatorAffiliation = affiliation(thesis.getOrientator());
    String coorientatorName = name(thesis.getCoorientator());
    String coorientatorAffiliation = affiliation(thesis.getCoorientator());
    String vowel1Name = name(thesis.getVowels(), 0);
    String vowel1Affiliation = affiliation(thesis.getVowels(), 0);
    String vowel2Name = name(thesis.getVowels(), 1);
    String vowel2Affiliation = affiliation(thesis.getVowels(), 1);
    String vowel3Name = name(thesis.getVowels(), 2);
    String vowel3Affiliation = affiliation(thesis.getVowels(), 2);

    String date = String.format(new Locale("pt"), "%1$td de %1$tB de %1$tY", new Date());
    String currentPersonName = currentPerson.getNickname();

    if (thesis.isCoordinator()) {
      return getMessage(
          COORDINATOR_BODY_KEY,
          year,
          degreeName,
          studentName,
          studentNumber,
          presidentName,
          presidentAffiliation,
          orientatorName,
          orientatorAffiliation,
          includeFlag(coorientatorName),
          coorientatorName,
          coorientatorAffiliation,
          includeFlag(vowel1Name),
          vowel1Name,
          vowel1Affiliation,
          includeFlag(vowel2Name),
          vowel2Name,
          vowel2Affiliation,
          includeFlag(vowel3Name),
          vowel3Name,
          vowel3Affiliation,
          date,
          currentPersonName);
    } else {
      return getMessage(
          BODY_KEY,
          year,
          degreeName,
          studentName,
          studentNumber,
          presidentName,
          presidentAffiliation,
          orientatorName,
          orientatorAffiliation,
          includeFlag(coorientatorName),
          coorientatorName,
          coorientatorAffiliation,
          includeFlag(vowel1Name),
          vowel1Name,
          vowel1Affiliation,
          includeFlag(vowel2Name),
          vowel2Name,
          vowel2Affiliation,
          includeFlag(vowel3Name),
          vowel3Name,
          vowel3Affiliation,
          date,
          currentPersonName);
    }
  }