Example #1
0
 @Deprecated
 public java.util.Date getEnd() {
   org.joda.time.YearMonthDay ymd = getEndYearMonthDay();
   return (ymd == null)
       ? null
       : new java.util.Date(ymd.getYear() - 1900, ymd.getMonthOfYear() - 1, ymd.getDayOfMonth());
 }
Example #2
0
 public void testMaximumValue() {
   DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
   while (dt.getYear() < 1590) {
     dt = dt.plusDays(1);
     YearMonthDay ymd = dt.toYearMonthDay();
     assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
     assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
     assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
   }
 }
Example #3
0
 public void testSubtractDays() {
   // This is a test for a bug in version 1.0. The dayOfMonth range
   // duration field did not match the monthOfYear duration field. This
   // caused an exception to be thrown when subtracting days.
   DateTime dt =
       new DateTime(1112306400000L, GJChronology.getInstance(DateTimeZone.forID("Europe/Berlin")));
   YearMonthDay ymd = dt.toYearMonthDay();
   while (ymd.toDateTimeAtMidnight().getDayOfWeek() != DateTimeConstants.MONDAY) {
     ymd = ymd.minus(Period.days(1));
   }
 }
Example #4
0
 @Deprecated
 public void setEnd(java.util.Date date) {
   if (date == null) {
     setEndYearMonthDay(null);
   } else {
     setEndYearMonthDay(org.joda.time.YearMonthDay.fromDateFields(date));
   }
 }
Example #5
0
 private boolean checkOccupationPeriod(
     Date evaluationDate, ExecutionSemester executionSemester, MarkSheetType markSheetType) {
   OccupationPeriod occupationPeriod = getOccupationPeriodFor(executionSemester, markSheetType);
   return evaluationDate != null
       && occupationPeriod != null
       && occupationPeriod.nestedOccupationPeriodsContainsDay(
           YearMonthDay.fromDateFields(evaluationDate));
 }
Example #6
0
  private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, GJChronology.getInstance(DateTimeZone.UTC));
    DateTime dtEnd = new DateTime(end, GJChronology.getInstance(DateTimeZone.UTC));
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(GJChronology.getInstance(DateTimeZone.UTC));
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);

    if (type == DurationFieldType.years()
        || type == DurationFieldType.months()
        || type == DurationFieldType.days()) {
      YearMonthDay ymdStart = new YearMonthDay(start, GJChronology.getInstance(DateTimeZone.UTC));
      YearMonthDay ymdEnd = new YearMonthDay(end, GJChronology.getInstance(DateTimeZone.UTC));
      assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
      assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
  }
  public static SchoolUnit createNewSchoolUnit(
      MultiLanguageString schoolName,
      String schoolNameCard,
      Unit parentUnit,
      Boolean official,
      String code,
      AcademicalInstitutionType institutionType) {

    SchoolUnit schoolUnit = new SchoolUnit();
    schoolUnit.setPartyName(schoolName);
    schoolUnit.setIdentificationCardLabel(schoolNameCard);
    schoolUnit.setOfficial(official);
    schoolUnit.setCode(code);
    schoolUnit.setInstitutionType(institutionType);
    schoolUnit.setBeginDateYearMonthDay(
        YearMonthDay.fromDateFields(new GregorianCalendar().getTime()));
    schoolUnit.setCanBeResponsibleOfSpaces(Boolean.FALSE);
    return createNewUnit(parentUnit, schoolUnit, Boolean.FALSE);
  }
Example #8
0
  @Override
  public void editVotingPeriod(
      YearMonthDay startDate, YearMonthDay endDate, DelegateElectionVotingPeriod votingPeriod) {
    if (!endDate.isAfter(getLastVotingEndDate())) {
      throw new DomainException(
          "error.elections.edit.newEndDateMustBeGreater",
          getDegree().getSigla(),
          getCurricularYear().getYear().toString());
    }

    if (!votingPeriod.isPastPeriod()) {
      votingPeriod.setEndDate(endDate);
    } else {
      throw new DomainException(
          "error.yearDelegateElections.edit.pastPeriod",
          new String[] {
            getDegree().getSigla(),
            getCurricularYear().getYear().toString(),
            votingPeriod.getPeriod()
          });
    }
  }
Example #9
0
  public ActionForward checkRooms(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    DynaActionForm examForm = (DynaActionForm) form;
    ContextUtils.setCurricularYearsContext(request);

    String infoExamId = (String) request.getAttribute(PresentationConstants.EXAM_OID);
    if (infoExamId == null) {
      infoExamId = request.getParameter(PresentationConstants.EXAM_OID);
    }
    request.setAttribute(PresentationConstants.EXAM_OID, infoExamId);

    String[] executionCourseArray = (String[]) examForm.get("executionCourses");

    List executionCourseList = new ArrayList();
    for (String element : executionCourseArray) {

      InfoExecutionCourse executionCourse;
      try {
        executionCourse =
            ReadExecutionCourseWithAssociatedCurricularCourses.run(new Integer(element));
      } catch (Exception ex) {
        throw new Exception(ex);
      }

      executionCourseList.add(executionCourse);
    }
    request.setAttribute(PresentationConstants.EXECUTION_COURSES_LIST, executionCourseList);

    String nextPage = request.getParameter("nextPage");
    request.setAttribute(PresentationConstants.NEXT_PAGE, nextPage);

    List examSeasons = Util.getExamSeasons();
    request.setAttribute(PresentationConstants.LABLELIST_SEASONS, examSeasons);

    List executionCourseNames =
        (List) request.getAttribute(PresentationConstants.LIST_EXECUTION_COURSE_NAMES);
    request.setAttribute(PresentationConstants.LIST_EXECUTION_COURSE_NAMES, executionCourseNames);

    String[] executionCourse = (String[]) examForm.get("executionCourses");
    examForm.set("executionCourses", executionCourse);

    String[] scopeIDArray = (String[]) examForm.get("scopes");
    examForm.set("scopes", scopeIDArray);

    // exam start time
    Calendar examStartTime = Calendar.getInstance();
    Integer startHour = new Integer((String) examForm.get("beginningHour"));
    Integer startMinute = new Integer((String) examForm.get("beginningMinute"));
    examStartTime.set(Calendar.HOUR_OF_DAY, startHour.intValue());
    examStartTime.set(Calendar.MINUTE, startMinute.intValue());
    examStartTime.set(Calendar.SECOND, 0);

    // exam end time
    Calendar examEndTime = Calendar.getInstance();
    Integer endHour = new Integer((String) examForm.get("endHour"));
    Integer endMinute = new Integer((String) examForm.get("endMinute"));
    examEndTime.set(Calendar.HOUR_OF_DAY, endHour.intValue());
    examEndTime.set(Calendar.MINUTE, endMinute.intValue());
    examEndTime.set(Calendar.SECOND, 0);

    if (examStartTime.after(examEndTime)) {
      addErrorMessage(request, "error.timeSwitched", "error.timeSwitched");
      return prepare(mapping, form, request, response);
    }

    // exam date
    Calendar examDate = Calendar.getInstance();
    Integer day = new Integer((String) examForm.get("day"));
    Integer month = new Integer((String) examForm.get("month"));
    Integer year = new Integer((String) examForm.get("year"));
    examDate.set(Calendar.YEAR, year.intValue());
    examDate.set(Calendar.MONTH, month.intValue() - 1);
    examDate.set(Calendar.DAY_OF_MONTH, day.intValue());

    int dayOfWeekInt = examDate.get(Calendar.DAY_OF_WEEK);
    DiaSemana dayOfWeek = new DiaSemana(dayOfWeekInt);
    if (dayOfWeekInt == Calendar.SUNDAY) {
      addErrorMessage(request, "error.sunday", "error.sunday");
      return prepare(mapping, form, request, response);
    }

    List<InfoRoom> availableInfoRoom =
        ReadAvailableRoomsForExam.run(
            YearMonthDay.fromCalendarFields(examDate),
            YearMonthDay.fromCalendarFields(examDate),
            HourMinuteSecond.fromCalendarFields(examStartTime),
            HourMinuteSecond.fromCalendarFields(examEndTime),
            dayOfWeek,
            null,
            null,
            Boolean.FALSE);

    String[] rooms = (String[]) examForm.get("rooms");
    List<InfoRoom> selectedRooms = new ArrayList<InfoRoom>();
    List<InfoRoom> occupiedSelectedRooms = new ArrayList<InfoRoom>();

    if (rooms != null && rooms.length > 0) {

      for (String room : rooms) {

        InfoRoom infoRoom = ReadRoomByOID.run(Integer.valueOf(room));

        selectedRooms.add(infoRoom);
      }

      for (int iterSR = 0; iterSR < selectedRooms.size(); iterSR++) {
        InfoRoom selectedInfoRoom = selectedRooms.get(iterSR);

        boolean infoContida = false;

        for (int iterAIF = 0; iterAIF < availableInfoRoom.size(); iterAIF++) {
          InfoRoom availInfoRoom = availableInfoRoom.get(iterAIF);

          if (selectedInfoRoom.equals(availInfoRoom)) {
            infoContida = true;
            break;
          }
        }

        if (!infoContida) {
          // room occupied
          occupiedSelectedRooms.add(selectedInfoRoom);
        }
      }

      for (int iterOSR = 0; iterOSR < occupiedSelectedRooms.size(); iterOSR++) {
        InfoRoom occupiedInfoRoom = occupiedSelectedRooms.get(iterOSR);
        selectedRooms.remove(occupiedInfoRoom);
      }

      request.setAttribute("rooms", selectedRooms);
    }

    return mapping.findForward("showCreateForm");
  }
  public ActionForward prepareEdit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws FenixActionException {

    User userView = Authenticate.getUser();
    DynaActionForm dynaForm = (DynaActionForm) form;

    InfoDegreeCurricularPlan oldInfoDegreeCP = null;

    try {
      oldInfoDegreeCP =
          ReadDegreeCurricularPlan.runReadDegreeCurricularPlan(
              request.getParameter("degreeCurricularPlanId"));

    } catch (NonExistingServiceException e) {
      throw new NonExistingActionException(
          "message.nonExistingDegreeCurricularPlan", mapping.findForward("readDegree"));
    } catch (FenixServiceException fenixServiceException) {
      throw new FenixActionException(fenixServiceException.getMessage());
    }

    dynaForm.set("name", oldInfoDegreeCP.getName());
    dynaForm.set("state", oldInfoDegreeCP.getState().toString());

    DegreeCurricularPlan oldDegreeCP = oldInfoDegreeCP.getDegreeCurricularPlan();

    if (oldDegreeCP.getInitialDateYearMonthDay() != null) {
      YearMonthDay ymd = oldDegreeCP.getInitialDateYearMonthDay();
      String initialDateString =
          ymd.getDayOfMonth() + "/" + ymd.getMonthOfYear() + "/" + ymd.getYear();

      dynaForm.set("initialDate", initialDateString);
    }

    if (oldDegreeCP.getEndDateYearMonthDay() != null) {
      YearMonthDay ymd = oldDegreeCP.getEndDateYearMonthDay();
      String endDateString = ymd.getDayOfMonth() + "/" + ymd.getMonthOfYear() + "/" + ymd.getYear();

      dynaForm.set("endDate", endDateString);
    }

    if (oldInfoDegreeCP.getDegreeDuration() != null) {
      dynaForm.set("degreeDuration", oldInfoDegreeCP.getDegreeDuration().toString());
    }
    if (oldInfoDegreeCP.getMinimalYearForOptionalCourses() != null) {
      dynaForm.set(
          "minimalYearForOptionalCourses",
          oldInfoDegreeCP.getMinimalYearForOptionalCourses().toString());
    }

    if (oldInfoDegreeCP.getNeededCredits() != null) {
      dynaForm.set("neededCredits", oldInfoDegreeCP.getNeededCredits().toString());
    }

    dynaForm.set("markType", oldInfoDegreeCP.getMarkType().getType().toString());

    if (oldInfoDegreeCP.getGradeScale() != null) {
      dynaForm.set("gradeType", oldInfoDegreeCP.getGradeScale().toString());
    }

    if (oldInfoDegreeCP.getNumerusClausus() != null) {
      dynaForm.set("numerusClausus", oldInfoDegreeCP.getNumerusClausus().toString());
    }
    dynaForm.set("anotation", oldInfoDegreeCP.getAnotation());

    return mapping.findForward("editDegreeCP");
  }
    public ByteArrayOutputStream getFilledPdf(Person person) throws IOException, DocumentException {
      InputStream istream = getClass().getResourceAsStream(SANTANDER_APPLICATION_PDF_PATH);
      PdfReader reader = new PdfReader(istream);
      reader.getAcroForm().remove(PdfName.SIGFLAGS);
      reader.selectPages("1,2");
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      PdfStamper stamper = new PdfStamper(reader, output);
      form = stamper.getAcroFields();

      setField("topmostSubform[0].Page1[0].Nomecompleto[0]", person.getName());
      String documentIdNumber = person.getDocumentIdNumber();
      if (person.getIdDocumentType().equals(IDDocumentType.CITIZEN_CARD)
          || person.getIdDocumentType().equals(IDDocumentType.IDENTITY_CARD)) {
        setField("topmostSubform[0].Page1[0].NumBICartaoCidadaooutro[0]", documentIdNumber);
        setField(
            "topmostSubform[0].Page1[0].Checkdigit[0]",
            person.getIdentificationDocumentSeriesNumberValue());
      } else {
        setField("topmostSubform[0].Page1[0].Outrotipodocidentificacao[0]", documentIdNumber);
      }

      YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay();
      if (emissionDate != null) {
        setField(
            "topmostSubform[0].Page1[0].Dataemissao[0]",
            emissionDate.toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      }
      setField(
          "topmostSubform[0].Page1[0].Datavalidade[0]",
          person
              .getExpirationDateOfDocumentIdYearMonthDay()
              .toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      setField("topmostSubform[0].Page1[0].NIF[0]", person.getSocialSecurityNumber());
      setField(
          "topmostSubform[0].Page1[0].Nacionalidade[0]",
          person.getCountryOfBirth().getCountryNationality().toString());
      setField(
          "topmostSubform[0].Page1[0].Datanascimento[0]",
          person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("dd/MM/yyyy")));
      YearMonthDay dateOfBirthYearMonthDay = person.getDateOfBirthYearMonthDay();
      Period periodBetween = new Period(dateOfBirthYearMonthDay, new YearMonthDay());
      setField(
          "topmostSubform[0].Page1[0].Idadeactual[0]",
          String.valueOf(periodBetween.get(DurationFieldType.years())));
      if (person.isFemale()) {
        setField("topmostSubform[0].Page1[0].Sexo[0]", "F"); // female
      } else if (person.isMale()) {
        setField("topmostSubform[0].Page1[0].Sexo[0]", "M"); // male
      }

      switch (person.getMaritalStatus()) {
        case CIVIL_UNION:
          setField("topmostSubform[0].Page1[0].Uniaofacto[0]", "1");
          break;
        case DIVORCED:
          setField("topmostSubform[0].Page1[0].Divorciado[0]", "1");
          break;
        case MARRIED:
          setField("topmostSubform[0].Page1[0].Casado[0]", "1");
          break;
        case SEPARATED:
          setField("topmostSubform[0].Page1[0].Separado[0]", "1");
          break;
        case SINGLE:
          setField("topmostSubform[0].Page1[0].Solteiro[0]", "1");
          break;
        case WIDOWER:
          setField("topmostSubform[0].Page1[0].Viuvo[0]", "1");
          break;
      }
      setField("topmostSubform[0].Page1[0].Telemovel[0]", person.getDefaultMobilePhoneNumber());
      setField("topmostSubform[0].Page1[0].E-mail[0]", getMail(person));
      setField("topmostSubform[0].Page1[0].Moradaprincipal[0]", person.getAddress());
      setField("topmostSubform[0].Page1[0].localidade[0]", person.getAreaOfAreaCode());
      String postalCode = person.getPostalCode();
      int dashIndex = postalCode.indexOf('-');
      setField("topmostSubform[0].Page1[0].CodPostal[0]", postalCode.substring(0, 4));
      String last3Numbers = person.getPostalCode().substring(dashIndex + 1, dashIndex + 4);
      setField("topmostSubform[0].Page1[0].ExtensaoCodPostal[0]", last3Numbers);

      setField(
          "topmostSubform[0].Page1[0].Nacionalidade[0]",
          person.getCountryOfBirth().getCountryNationality().toString());
      setField(
          "topmostSubform[0].Page1[0].Nacionalidade[0]",
          person.getCountryOfBirth().getCountryNationality().toString());

      stamper.setFormFlattening(true);
      stamper.close();
      return output;
    }
Example #12
0
 public boolean intersects(final Date begin, final Date end) {
   return intersects(YearMonthDay.fromDateFields(begin), YearMonthDay.fromDateFields(end));
 }
    public ByteArrayOutputStream getFilledPdf(Person person) throws IOException, DocumentException {
      InputStream istream = getClass().getResourceAsStream(BPI_PERSONAL_INFORMATION_PDF_PATH);
      PdfReader reader = new PdfReader(istream);
      reader.getAcroForm().remove(PdfName.SIGFLAGS);
      reader.selectPages("1,2");
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      PdfStamper stamper = new PdfStamper(reader, output);
      form = stamper.getAcroFields();

      setField("Nome completo_1", person.getName());
      setField("NIF", person.getSocialSecurityNumber());
      setField("Nº", person.getDocumentIdNumber());

      setField("Nacionalidade", person.getCountryOfBirth().getCountryNationality().toString());
      setField("Naturalidade", person.getCountryOfBirth().getName());

      setField("Distrito", person.getDistrictOfBirth());
      setField("Concelho", person.getDistrictSubdivisionOfBirth());
      setField("Freguesia", person.getParishOfBirth());
      setField("Nome do Pai", person.getNameOfFather());
      setField("Nome da Mãe", person.getNameOfMother());
      setField("Morada de Residencia_1", person.getAddress());
      setField("Localidade", person.getAreaOfAreaCode());
      setField("Designação Postal", person.getAreaOfAreaCode());
      setField("País", person.getCountryOfResidence().getName());

      String postalCode = person.getPostalCode();
      int dashIndex = postalCode.indexOf('-');
      setField("Código Postal4", postalCode.substring(0, 4));
      String last3Numbers = postalCode.substring(dashIndex + 1, dashIndex + 4);
      setField("Código Postal_5", last3Numbers);
      setField("Móvel", person.getDefaultMobilePhoneNumber());
      setField("E-mail", getMail(person));

      YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay();
      if (emissionDate != null) {
        setField("Dia_1", String.valueOf(emissionDate.getDayOfMonth()));
        setField("Mês_1", String.valueOf(emissionDate.getMonthOfYear()));
        setField("Ano_1", String.valueOf(emissionDate.getYear()));
      }

      YearMonthDay expirationDate = person.getExpirationDateOfDocumentIdYearMonthDay();
      setField("Dia_2", String.valueOf(expirationDate.getDayOfMonth()));
      setField("Mês_2", String.valueOf(expirationDate.getMonthOfYear()));
      setField("Ano_2", String.valueOf(expirationDate.getYear()));

      YearMonthDay birthdayDate = person.getDateOfBirthYearMonthDay();
      setField("Dia3", String.valueOf(birthdayDate.getDayOfMonth()));
      setField("Mês3", String.valueOf(birthdayDate.getMonthOfYear()));
      setField("Ano_3", String.valueOf(birthdayDate.getYear()));

      stamper.setFormFlattening(true);
      stamper.close();
      return output;
    }
  @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;
  }
Example #15
0
 @Deprecated
 public boolean isDateInSpecialSeasonOfGradeSubmission(YearMonthDay date) {
   return isDateInPeriodOfType(
       date.toDateTimeAtMidnight(), OccupationPeriodType.GRADE_SUBMISSION_SPECIAL_SEASON, null);
 }
Example #16
0
 @Deprecated
 public boolean isDateInSecondSemesterNormalSeasonOfGradeSubmission(YearMonthDay date) {
   return isDateInPeriodOfType(
       date.toDateTimeAtMidnight(), OccupationPeriodType.GRADE_SUBMISSION, 2);
 }
Example #17
0
 public static Partial getPartialFromYearMonthDay(YearMonthDay day) {
   return new Partial(
       new DateTimeFieldType[] {DateTimeFieldType.year(), DateTimeFieldType.monthOfYear()},
       new int[] {day.getYear(), day.getMonthOfYear()});
 }
Example #18
0
  public ActionForward search(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IUserView userView = UserView.getUser();
    DynaValidatorForm roomSearchForm = (DynaValidatorForm) form;

    // date
    Calendar searchDate = Calendar.getInstance();
    Integer day = new Integer((String) roomSearchForm.get("day"));
    Integer month = new Integer((String) roomSearchForm.get("month"));
    Integer year = new Integer((String) roomSearchForm.get("year"));
    request.setAttribute("day", day.toString());
    request.setAttribute("month", month.toString());
    request.setAttribute("year", year.toString());
    searchDate.set(Calendar.YEAR, year.intValue());
    searchDate.set(Calendar.MONTH, month.intValue() - 1);
    searchDate.set(Calendar.DAY_OF_MONTH, day.intValue());
    if (searchDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
      ActionError actionError = new ActionError("error.sunday");
      ActionErrors actionErrors = new ActionErrors();
      actionErrors.add("error.sunday", actionError);
      saveErrors(request, actionErrors);
      return prepare(mapping, form, request, response);
    }

    // exam start time
    Calendar searchStartTime = Calendar.getInstance();
    Integer startHour = new Integer((String) roomSearchForm.get("beginningHour"));
    Integer startMinute = new Integer((String) roomSearchForm.get("beginningMinute"));
    request.setAttribute("beginningHour", startHour.toString());
    request.setAttribute("beginningMinute", startMinute.toString());
    searchStartTime.set(Calendar.HOUR_OF_DAY, startHour.intValue());
    searchStartTime.set(Calendar.MINUTE, startMinute.intValue());
    searchStartTime.set(Calendar.SECOND, 0);

    // exam end time
    Calendar searchEndTime = Calendar.getInstance();
    Integer endHour = new Integer((String) roomSearchForm.get("endHour"));
    Integer endMinute = new Integer((String) roomSearchForm.get("endMinute"));
    request.setAttribute("endHour", endHour.toString());
    request.setAttribute("endMinute", endMinute.toString());
    searchEndTime.set(Calendar.HOUR_OF_DAY, endHour.intValue());
    searchEndTime.set(Calendar.MINUTE, endMinute.intValue());
    searchEndTime.set(Calendar.SECOND, 0);

    if (searchStartTime.after(searchEndTime)) {
      ActionError actionError = new ActionError("error.timeSwitched");
      ActionErrors actionErrors = new ActionErrors();
      actionErrors.add("error.timeSwitched", actionError);
      saveErrors(request, actionErrors);
      return prepare(mapping, form, request, response);
    }

    int dayOfWeekInt = searchDate.get(Calendar.DAY_OF_WEEK);
    DiaSemana dayOfWeek = new DiaSemana(dayOfWeekInt);

    List<InfoRoom> availableInfoRoom = null;
    availableInfoRoom =
        ReadAvailableRoomsForExam.run(
            YearMonthDay.fromCalendarFields(searchDate),
            YearMonthDay.fromCalendarFields(searchDate),
            HourMinuteSecond.fromCalendarFields(searchStartTime),
            HourMinuteSecond.fromCalendarFields(searchEndTime),
            dayOfWeek,
            null,
            null,
            Boolean.FALSE);
    String sdate =
        roomSearchForm.get("day")
            + "/"
            + roomSearchForm.get("month")
            + "/"
            + roomSearchForm.get("year");
    String startTime =
        roomSearchForm.get("beginningHour") + ":" + roomSearchForm.get("beginningMinute");
    String endTime = roomSearchForm.get("endHour") + ":" + roomSearchForm.get("endMinute");
    request.setAttribute(PresentationConstants.DATE, sdate);
    request.setAttribute(PresentationConstants.START_TIME, startTime);
    request.setAttribute(PresentationConstants.END_TIME, endTime);

    Integer exam = null;
    Integer normal = null;
    List<InfoRoom> newAvailableInfoRoom = new ArrayList<InfoRoom>();
    if (availableInfoRoom != null && !availableInfoRoom.isEmpty()) {
      try {
        exam = new Integer((String) roomSearchForm.get("exam"));
      } catch (NumberFormatException ex) {
        // the user didn't speciefy a exam minimum capacity
      }
      try {
        normal = new Integer((String) roomSearchForm.get("normal"));
      } catch (NumberFormatException ex) {
        // the user didn't speciefy a normal minimum capacity
      }
      if (normal != null || exam != null) {
        Iterator<InfoRoom> iter = availableInfoRoom.iterator();
        while (iter.hasNext()) {
          InfoRoom elem = iter.next();
          if (!((normal != null && elem.getCapacidadeNormal().intValue() < normal.intValue())
              || (exam != null && elem.getCapacidadeExame().intValue() < exam.intValue()))) {
            newAvailableInfoRoom.add(elem);
          }
        }
      } else {
        newAvailableInfoRoom = availableInfoRoom;
      }
    }
    if (newAvailableInfoRoom != null && !newAvailableInfoRoom.isEmpty()) {
      Collections.sort(newAvailableInfoRoom, new BeanComparator("nome"));
      String[] availableRoomId = new String[newAvailableInfoRoom.size()];
      Iterator<InfoRoom> iter = newAvailableInfoRoom.iterator();
      int i = 0;
      while (iter.hasNext()) {
        InfoRoom elem = iter.next();
        availableRoomId[i] = elem.getIdInternal().toString();
      }
      request.setAttribute(PresentationConstants.AVAILABLE_ROOMS_ID, availableRoomId);
    }

    request.setAttribute(PresentationConstants.AVAILABLE_ROOMS, newAvailableInfoRoom);
    return mapping.findForward("showRooms");
  }
 public String getNextPossibleLessonInstanceDate() {
   YearMonthDay day = getLesson().getNextPossibleLessonInstanceDate();
   return day != null ? day.toString("dd/MM/yyyy") : "-";
 }