Java Code Examples for org.joda.time.YearMonthDay#isAfter()

The following examples show how to use org.joda.time.YearMonthDay#isAfter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionSemester.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void checkDatesIntersection(YearMonthDay begin, YearMonthDay end) {
    List<InfoExecutionPeriod> infoExecutionPeriods = ReadExecutionPeriods.run();
    if (infoExecutionPeriods != null && !infoExecutionPeriods.isEmpty()) {

        Collections.sort(infoExecutionPeriods, InfoExecutionPeriod.COMPARATOR_BY_YEAR_AND_SEMESTER);

        for (InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
            ExecutionSemester executionSemester = infoExecutionPeriod.getExecutionPeriod();
            YearMonthDay beginDate = executionSemester.getBeginDateYearMonthDay();
            YearMonthDay endDate = executionSemester.getEndDateYearMonthDay();
            if (begin.isAfter(endDate) || end.isBefore(beginDate) || executionSemester.equals(this)) {
                continue;
            } else {
                throw new DomainException("error.ExecutionPeriod.intersection.dates");
            }
        }
    }
}
 
Example 2
Source File: AcademicCalendarsManagementDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward viewAcademicCalendar(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    CalendarEntryBean bean = getRenderedObject("datesToDisplayID");

    YearMonthDay beginDate = bean.getBeginDateToDisplayInYearMonthDayFormat();
    YearMonthDay endDate = bean.getEndDateToDisplayInYearMonthDayFormat();

    if (beginDate.isAfter(endDate)) {
        addActionMessage(request, "error.begin.after.end");
        ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
        Partial begin = CalendarEntryBean.getPartialFromYearMonthDay(currentExecutionYear.getBeginDateYearMonthDay());
        Partial end = CalendarEntryBean.getPartialFromYearMonthDay(currentExecutionYear.getEndDateYearMonthDay());
        bean = CalendarEntryBean.createCalendarEntryBeanToCreateEntry(bean.getRootEntry(), bean.getRootEntry(), begin, end);
        RenderUtils.invalidateViewState("datesToDisplayID");
        return generateGanttDiagram(mapping, request, bean);
    }

    return generateGanttDiagram(mapping, request, bean);
}
 
Example 3
Source File: WrittenEvaluationSpaceOccupation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<Interval> getEventSpaceOccupationIntervals(YearMonthDay startDateToSearch, YearMonthDay endDateToSearch) {

    List<Interval> result = new ArrayList<Interval>();
    Collection<WrittenEvaluation> writtenEvaluations = getWrittenEvaluationsSet();

    for (WrittenEvaluation writtenEvaluation : writtenEvaluations) {
        YearMonthDay writtenEvaluationDay = writtenEvaluation.getDayDateYearMonthDay();
        if (startDateToSearch == null
                || (!writtenEvaluationDay.isBefore(startDateToSearch) && !writtenEvaluationDay.isAfter(endDateToSearch))) {

            result.add(createNewInterval(writtenEvaluationDay, writtenEvaluationDay,
                    writtenEvaluation.getBeginningDateHourMinuteSecond(), writtenEvaluation.getEndDateHourMinuteSecond()));
        }
    }
    return result;
}
 
Example 4
Source File: Thesis.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setEnrolment(Enrolment enrolment) {
    final ExecutionDegree executionDegree = getExecutionDegree(enrolment);
    final YearMonthDay beginThesisCreationPeriod = executionDegree.getBeginThesisCreationPeriod();
    final YearMonthDay endThesisCreationPeriod = executionDegree.getEndThesisCreationPeriod();

    final YearMonthDay today = new YearMonthDay();
    if (beginThesisCreationPeriod == null || beginThesisCreationPeriod.isAfter(today)) {
        throw new DomainException("thesis.creation.not.allowed.because.out.of.period");
    }
    if (endThesisCreationPeriod != null && endThesisCreationPeriod.isBefore(today)) {
        throw new DomainException("thesis.creation.not.allowed.because.out.of.period");
    }

    CurricularCourse curricularCourse = enrolment.getCurricularCourse();
    if (!curricularCourse.isDissertation()) {
        throw new DomainException("thesis.enrolment.notDissertationEnrolment");
    }

    super.setEnrolment(enrolment);
}
 
Example 5
Source File: CurriculumGroup.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public YearMonthDay calculateConclusionDate() {
    final Collection<CurriculumModule> curriculumModules = new HashSet<CurriculumModule>(getCurriculumModulesSet());
    YearMonthDay result = null;
    for (final CurriculumModule curriculumModule : curriculumModules) {
        if (curriculumModule.isConcluded(getApprovedCurriculumLinesLastExecutionYear()).isValid()
                && curriculumModule.hasAnyApprovedCurriculumLines()) {
            final YearMonthDay curriculumModuleConclusionDate = curriculumModule.calculateConclusionDate();
            if (curriculumModuleConclusionDate != null && (result == null || curriculumModuleConclusionDate.isAfter(result))) {
                result = curriculumModuleConclusionDate;
            }
        }
    }

    return result;
}
 
Example 6
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean isTimeValidToInsertSummary(HourMinuteSecond timeToInsert, YearMonthDay summaryDate) {

        YearMonthDay currentDate = new YearMonthDay();
        if (timeToInsert == null || summaryDate == null || summaryDate.isAfter(currentDate)) {
            return false;
        }

        if (currentDate.isEqual(summaryDate)) {
            HourMinuteSecond lessonEndTime = null;
            LessonInstance lessonInstance = getLessonInstanceFor(summaryDate);
            lessonEndTime = lessonInstance != null ? lessonInstance.getEndTime() : getEndHourMinuteSecond();
            return !lessonEndTime.isAfter(timeToInsert);
        }

        return true;
    }
 
Example 7
Source File: EventSpaceOccupation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static List<Interval> generateEventSpaceOccupationIntervals(YearMonthDay begin, final YearMonthDay end,
        final HourMinuteSecond beginTime, final HourMinuteSecond endTime, final FrequencyType frequency,
        final DiaSemana diaSemana, final Boolean dailyFrequencyMarkSaturday, final Boolean dailyFrequencyMarkSunday,
        final YearMonthDay startDateToSearch, final YearMonthDay endDateToSearch) {

    List<Interval> result = new ArrayList<Interval>();
    begin = getBeginDateInSpecificWeekDay(diaSemana, begin);

    if (frequency == null) {
        if (!begin.isAfter(end)
                && (startDateToSearch == null || (!end.isBefore(startDateToSearch) && !begin.isAfter(endDateToSearch)))) {
            result.add(createNewInterval(begin, end, beginTime, endTime));
            return result;
        }
    } else {
        int numberOfDaysToSum = frequency.getNumberOfDays();
        while (true) {
            if (begin.isAfter(end)) {
                break;
            }
            if (startDateToSearch == null || (!begin.isBefore(startDateToSearch) && !begin.isAfter(endDateToSearch))) {

                Interval interval = createNewInterval(begin, begin, beginTime, endTime);

                if (!frequency.equals(FrequencyType.DAILY)
                        || ((dailyFrequencyMarkSaturday || interval.getStart().getDayOfWeek() != SATURDAY_IN_JODA_TIME) && (dailyFrequencyMarkSunday || interval
                                .getStart().getDayOfWeek() != SUNDAY_IN_JODA_TIME))) {

                    result.add(interval);
                }
            }
            begin = begin.plusDays(numberOfDaysToSum);
        }
    }
    return result;
}
 
Example 8
Source File: RoomSiteComponentBuilder.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void getLessonInstanceOccupations(List<InfoObject> infoShowOccupations, YearMonthDay weekStartYearMonthDay,
        YearMonthDay weekEndYearMonthDay, Collection<LessonInstance> lessonInstances) {

    if (lessonInstances != null) {
        for (LessonInstance lessonInstance : lessonInstances) {
            final YearMonthDay lessonInstanceDay = lessonInstance.getDay();
            if (!lessonInstanceDay.isBefore(weekStartYearMonthDay) && !lessonInstanceDay.isAfter(weekEndYearMonthDay)) {
                InfoLessonInstance infoLessonInstance = new InfoLessonInstance(lessonInstance);
                infoShowOccupations.add(infoLessonInstance);
            }
        }
    }
}
 
Example 9
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private SortedSet<YearMonthDay> getAllValidLessonDatesWithoutInstancesDates(YearMonthDay startDateToSearch,
        YearMonthDay endDateToSearch) {

    SortedSet<YearMonthDay> result = new TreeSet<YearMonthDay>();
    startDateToSearch = startDateToSearch != null ? getValidBeginDate(startDateToSearch) : null;

    if (!wasFinished() && startDateToSearch != null && endDateToSearch != null && !startDateToSearch.isAfter(endDateToSearch)) {
        Space lessonCampus = getLessonCampus();
        final int dayIncrement =
                getFrequency() == FrequencyType.BIWEEKLY ? FrequencyType.WEEKLY.getNumberOfDays() : getFrequency()
                        .getNumberOfDays();
        boolean shouldAdd = true;
        while (true) {
            if (isDayValid(startDateToSearch, lessonCampus)) {
                if (getFrequency() != FrequencyType.BIWEEKLY || shouldAdd) {
                    if (!isHoliday(startDateToSearch, lessonCampus)) {
                        result.add(startDateToSearch);
                    }
                }
                shouldAdd = !shouldAdd;
            }
            startDateToSearch = startDateToSearch.plusDays(dayIncrement);
            if (startDateToSearch.isAfter(endDateToSearch)) {
                break;
            }
        }
    }
    return result;
}
 
Example 10
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SortedSet<YearMonthDay> getAllLessonInstanceDatesUntil(YearMonthDay day) {
    SortedSet<YearMonthDay> result = new TreeSet<YearMonthDay>();
    if (day != null) {
        for (LessonInstance instance : getLessonInstancesSet()) {
            YearMonthDay instanceDay = instance.getDay();
            if (!instanceDay.isAfter(day)) {
                result.add(instanceDay);
            }
        }
    }
    return result;
}
 
Example 11
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SortedSet<YearMonthDay> getAllLessonDatesUntil(YearMonthDay day) {
    SortedSet<YearMonthDay> result = new TreeSet<YearMonthDay>();
    if (day != null) {
        result.addAll(getAllLessonInstanceDatesUntil(day));
        if (!wasFinished()) {
            YearMonthDay startDateToSearch = getLessonStartDay();
            YearMonthDay lessonEndDay = getLessonEndDay();
            YearMonthDay endDateToSearch = (lessonEndDay.isAfter(day)) ? day : lessonEndDay;
            result.addAll(getAllValidLessonDatesWithoutInstancesDates(startDateToSearch, endDateToSearch));
        }
    }
    return result;
}
 
Example 12
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private YearMonthDay getValidEndDate(YearMonthDay endDate) {
    YearMonthDay lessonEnd =
            endDate.toDateTimeAtMidnight().withDayOfWeek(getDiaSemana().getDiaSemanaInDayOfWeekJodaFormat()).toYearMonthDay();
    if (lessonEnd.isAfter(endDate)) {
        lessonEnd = lessonEnd.minusDays(NUMBER_OF_DAYS_IN_WEEK);
    }
    return lessonEnd;
}
 
Example 13
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void refreshPeriodAndInstancesInSummaryCreation(YearMonthDay newBeginDate) {
    if (!wasFinished() && newBeginDate != null && newBeginDate.isAfter(getPeriod().getStartYearMonthDay())) {
        SortedSet<YearMonthDay> instanceDates =
                getAllLessonInstancesDatesToCreate(getLessonStartDay(), newBeginDate.minusDays(1), true);
        YearMonthDay newEndDate = getPeriod().getLastOccupationPeriodOfNestedPeriods().getEndYearMonthDay();
        if (!newBeginDate.isAfter(newEndDate)) {
            refreshPeriod(newBeginDate, getPeriod().getLastOccupationPeriodOfNestedPeriods().getEndYearMonthDay());
        } else {
            OccupationPeriod period = getPeriod();
            removeLessonSpaceOccupationAndPeriod();
            period.delete();
        }
        createAllLessonInstances(instanceDates);
    }
}
 
Example 14
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Lesson(DiaSemana diaSemana, Calendar inicio, Calendar fim, Shift shift, FrequencyType frequency,
        ExecutionSemester executionSemester, YearMonthDay beginDate, YearMonthDay endDate, Space room) {

    super();

    OccupationPeriod period = null;
    if (shift != null) {
        final ExecutionCourse executionCourse = shift.getExecutionCourse();
        GenericPair<YearMonthDay, YearMonthDay> maxLessonsPeriod = executionCourse.getMaxLessonsPeriod();
        if (beginDate == null || beginDate.isBefore(maxLessonsPeriod.getLeft())) {
            throw new DomainException("error.Lesson.invalid.begin.date");
        }
        if (endDate == null || endDate.isAfter(maxLessonsPeriod.getRight())) {
            throw new DomainException("error.invalid.new.date");
        }
        period = OccupationPeriod.createOccupationPeriodForLesson(executionCourse, beginDate, endDate);
    }

    setRootDomainObject(Bennu.getInstance());
    setDiaSemana(diaSemana);
    setInicio(inicio);
    setFim(fim);
    setShift(shift);
    setFrequency(frequency);
    setPeriod(period);

    checkShiftLoad(shift);

    if (room != null) {
        new LessonSpaceOccupation(room, this);
    }
}
 
Example 15
Source File: Registration.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
final public StudentCurricularPlan getStudentCurricularPlan(final YearMonthDay date) {
    StudentCurricularPlan result = null;
    for (final StudentCurricularPlan studentCurricularPlan : getStudentCurricularPlansSet()) {
        final YearMonthDay startDate = studentCurricularPlan.getStartDateYearMonthDay();
        if (!startDate.isAfter(date) && (result == null || startDate.isAfter(result.getStartDateYearMonthDay()))) {
            result = studentCurricularPlan;
        }
    }
    return result;
}
 
Example 16
Source File: OccupationPeriod.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
public OccupationPeriod(YearMonthDay startDate, YearMonthDay endDate) {
    this();
    if (startDate == null || endDate == null || startDate.isAfter(endDate)) {
        throw new DomainException("error.occupationPeriod.invalid.dates");
    }
    this.setPeriodInterval(IntervalTools.getInterval(startDate, endDate));
}
 
Example 17
Source File: RegistrationConclusionProcess.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void checkEnteredConclusionDate(final RegistrationConclusionBean conclusionBean) {
    final YearMonthDay startDate = conclusionBean.getRegistration().getStartDate();

    if (startDate.isAfter(conclusionBean.getEnteredConclusionDate())) {
        throw new DomainException("error.RegistrationConclusionProcess.start.date.is.after.entered.date");
    }

}
 
Example 18
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void refreshPeriod(YearMonthDay newBeginDate, YearMonthDay newEndDate) {

        if (newBeginDate != null && newEndDate != null && !newBeginDate.isAfter(newEndDate)) {

            boolean newPeriod = false;
            OccupationPeriod currentPeriod = getPeriod();
            OccupationPeriod oldFirstPeriod = currentPeriod;

            if (currentPeriod == null || currentPeriod.getNextPeriod() == null) {
                setPeriod(new OccupationPeriod(newBeginDate, newEndDate));
                newPeriod = true;

            } else {

                while (currentPeriod != null) {

                    if (currentPeriod.getStartYearMonthDay().isAfter(newEndDate)) {
                        newPeriod = false;
                        break;
                    }

                    if (!currentPeriod.getEndYearMonthDay().isBefore(newBeginDate)) {

                        if (!currentPeriod.getStartYearMonthDay().isAfter(newBeginDate)) {
                            setPeriod(getNewNestedPeriods(currentPeriod, newBeginDate, newEndDate));

                        } else {
                            if (currentPeriod.equals(oldFirstPeriod)) {
                                setPeriod(getNewNestedPeriods(currentPeriod, newBeginDate, newEndDate));
                            } else {
                                setPeriod(getNewNestedPeriods(currentPeriod, currentPeriod.getStartYearMonthDay(), newEndDate));
                            }
                        }

                        newPeriod = true;
                        break;
                    }
                    currentPeriod = currentPeriod.getNextPeriod();
                }
            }

            if (!newPeriod) {
                removeLessonSpaceOccupationAndPeriod();
            }

            if (oldFirstPeriod != null) {
                oldFirstPeriod.delete();
            }
        }
    }
 
Example 19
Source File: GratuityTransaction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean isInsidePeriod(final YearMonthDay start, final YearMonthDay end) {
    final YearMonthDay date = getTransactionDateDateTime().toYearMonthDay();
    return !date.isBefore(start) && !date.isAfter(end);
}
 
Example 20
Source File: Unit.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@jvstm.cps.ConsistencyPredicate
protected boolean checkDateInterval() {
    final YearMonthDay start = getBeginDateYearMonthDay();
    final YearMonthDay end = getEndDateYearMonthDay();
    return start != null && (end == null || !start.isAfter(end));
}