Example usage for org.joda.time Interval Interval

List of usage examples for org.joda.time Interval Interval

Introduction

In this page you can find the example usage for org.joda.time Interval Interval.

Prototype

public Interval(Object interval, Chronology chronology) 

Source Link

Document

Constructs a time interval by converting or copying from another object, overriding the chronology.

Usage

From source file:net.sourceforge.fenixedu.domain.Teacher.java

License:Open Source License

public boolean hasLessons(DateTime begin, DateTime end, ExecutionYear executionYear) {
    final Interval interval = new Interval(begin, end);
    for (Professorship professorship : getProfessorships(executionYear)) {
        Set<Shift> associatedShifts = professorship.getExecutionCourse().getAssociatedShifts();
        for (Shift shift : associatedShifts) {
            Collection<Lesson> associatedLessons = shift.getAssociatedLessonsSet();
            for (Lesson lesson : associatedLessons) {
                if (lesson.contains(interval)) {
                    return true;
                }/*from w  w  w .  jav a2  s .  c  o  m*/
            }
        }
    }
    return false;
}

From source file:net.sourceforge.fenixedu.domain.time.calendarStructure.AcademicCalendarEntry.java

License:Open Source License

@Override
public List<Interval> getGanttDiagramEventSortedIntervals() {
    List<Interval> result = new ArrayList<Interval>();
    result.add(new Interval(getBegin(), getEnd()));
    return result;
}

From source file:net.sourceforge.fenixedu.domain.time.chronologies.AcademicChronology.java

License:Open Source License

public int getDayOfAcademicSemester(long instant) {
    AcademicCalendarEntry entryByInstant = academicCalendar.getEntryByInstant(instant, AcademicSemesterCE.class,
            AcademicYearCE.class);
    if (entryByInstant != null) {
        DateTime instantDateTime = new DateTime(instant);
        Interval interval = new Interval(entryByInstant.getBegin(), instantDateTime);
        int days = interval.toPeriod().getDays();
        if (days > 0) {
            return days;
        }/* w w w.  j  a  v a2  s .  c  o  m*/
    }
    return 0;
}

From source file:net.sourceforge.fenixedu.domain.TutorshipSummaryPeriod.java

License:Open Source License

public boolean isOpenNow() {
    Interval interval = new Interval(getBeginDate().toDateTimeAtStartOfDay(),
            getEndDate().plusDays(1).toDateTimeAtStartOfDay());
    return interval.containsNow();
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.UnavailablePeriod.java

License:Open Source License

public Boolean containsDate(DateTime date) {
    Interval interval = new Interval(this.getBeginDate(), this.getEndDate());
    return interval.contains(date);
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.UnavailablePeriod.java

License:Open Source License

public Boolean containsInterval(DateTime begin, DateTime end) {
    Interval interval = new Interval(this.getBeginDate(), this.getEndDate());
    return (interval.contains(begin) || interval.contains(end));
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.VigilantWrapper.java

License:Open Source License

public Boolean isAvailableOnDate(DateTime begin, DateTime end) {
    Collection<UnavailablePeriod> unavailablePeriods = this.getPerson().getUnavailablePeriodsSet();
    for (UnavailablePeriod period : unavailablePeriods) {
        if (period.containsInterval(begin, end)) {
            return Boolean.FALSE;
        }/*from   ww w.  jav  a  2  s  . c  o m*/

    }
    Interval interval = new Interval(begin, end);

    for (VigilantWrapper otherVigilant : this.getPerson().getVigilantWrappersSet()) {
        for (Vigilancy vigilancy : otherVigilant.getVigilanciesSet()) {
            if (interval.overlaps(vigilancy.getWrittenEvaluation().getDurationInterval())) {
                if (vigilancy.getWrittenEvaluation().getDurationInterval().overlaps(interval)) {
                    return Boolean.FALSE;
                }
            }
        }
    }

    return Boolean.TRUE;
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.VigilantWrapper.java

License:Open Source License

public List<Interval> getConvokePeriods() {
    List<Interval> convokingPeriods = new ArrayList<Interval>();
    Collection<Vigilancy> convokes = this.getVigilanciesSet();
    for (Vigilancy convoke : convokes) {
        convokingPeriods.add(new Interval(convoke.getBeginDate(), convoke.getEndDate()));
    }/*  ww w . ja v a2 s  . c  om*/
    return convokingPeriods;
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.VigilantWrapper.java

License:Open Source License

public boolean hasNoEvaluationsOnDate(DateTime beginOfExam, DateTime endOfExam) {
    Collection<Vigilancy> convokes = this.getVigilanciesSet();
    Interval requestedInterval = new Interval(beginOfExam, endOfExam);
    for (Vigilancy convoke : convokes) {
        DateTime begin = convoke.getBeginDateTime();
        DateTime end = convoke.getEndDateTime();
        Interval convokeInterval = new Interval(begin, end);
        if (convokeInterval.contains(requestedInterval)) {
            return Boolean.FALSE;
        }/*from w w w  .j  av  a 2  s. co  m*/
    }
    return Boolean.TRUE;

}

From source file:net.sourceforge.fenixedu.domain.vigilancy.VigilantWrapper.java

License:Open Source License

public UnavailableTypes getWhyIsUnavailabeFor(WrittenEvaluation writtenEvaluation) {
    DateTime begin = writtenEvaluation.getBeginningDateTime();
    DateTime end = writtenEvaluation.getEndDateTime();

    if (!this.isAvailableOnDate(begin, end)) {
        return UnavailableTypes.UNAVAILABLE_PERIOD;
    }//from  ww w  .  j  av a2s  . com
    if (!this.isAvailableInCampus(writtenEvaluation.getCampus())) {
        return UnavailableTypes.NOT_AVAILABLE_ON_CAMPUS;
    }
    if (!this.hasNoEvaluationsOnDate(begin, end)) {
        return UnavailableTypes.ALREADY_CONVOKED_FOR_ANOTHER_EVALUATION;
    }

    Teacher teacher = this.getPerson().getTeacher();
    if (teacher != null) {
        Set<PersonContractSituation> validTeacherServiceExemptions = teacher
                .getValidTeacherServiceExemptions(new Interval(begin, end.plusDays(1)));
        if (!validTeacherServiceExemptions.isEmpty()) {
            return UnavailableTypes.SERVICE_EXEMPTION;
        }
    }

    if (teacher != null && teacher.hasLessons(begin, end)) {
        return UnavailableTypes.LESSON_AT_SAME_TIME;
    }

    Person person = this.getPerson().getIncompatibleVigilantPerson();
    if (person != null) {
        Collection<Vigilancy> convokes = writtenEvaluation.getVigilanciesSet();
        for (Vigilancy convoke : convokes) {
            if (convoke.getVigilantWrapper().getPerson().equals(person)) {
                return UnavailableTypes.INCOMPATIBLE_PERSON;
            }
        }
    }

    return UnavailableTypes.UNKNOWN;

}