List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:net.sourceforge.fenixedu.domain.teacher.evaluation.FacultyEvaluationProcessBean.java
License:Open Source License
public Interval getAutoEvaluationInterval() { return new Interval(getAutoEvaluationIntervalStart(), getAutoEvaluationIntervalEnd()); }
From source file:net.sourceforge.fenixedu.domain.teacher.evaluation.FacultyEvaluationProcessBean.java
License:Open Source License
public Interval getEvaluationInterval() { return new Interval(getEvaluationIntervalStart(), getEvaluationIntervalEnd()); }
From source file:net.sourceforge.fenixedu.domain.teacher.ReductionService.java
License:Open Source License
private BigDecimal getTeacherMaxCreditsFromAge() { YearMonthDay dateOfBirthYearMonthDay = getTeacherService().getTeacher().getPerson() .getDateOfBirthYearMonthDay(); if (dateOfBirthYearMonthDay != null) { Interval interval = new Interval(dateOfBirthYearMonthDay.toLocalDate().toDateTimeAtStartOfDay(), getTeacherService().getExecutionPeriod().getEndDateYearMonthDay().plusDays(1).toLocalDate() .toDateTimeAtStartOfDay()); int age = interval.toPeriod(PeriodType.years()).getYears(); if (age >= 65) { return BigDecimal.ONE; }//w w w . j av a2s .com } return BigDecimal.ZERO; }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
public PersonContractSituation getDominantTeacherServiceExemption(ExecutionSemester executionSemester) { PersonContractSituation dominantExemption = null; int daysInDominantExemption = 0; Interval semesterInterval = new Interval( executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(), executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay()); for (PersonContractSituation personContractSituation : getValidTeacherServiceExemptions( executionSemester)) {//from ww w. j a v a 2s . c om int daysInInterval = personContractSituation.getDaysInInterval(semesterInterval); if (dominantExemption == null || daysInInterval > daysInDominantExemption) { dominantExemption = personContractSituation; daysInDominantExemption = daysInInterval; } } return dominantExemption; }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
public Set<PersonContractSituation> getValidTeacherServiceExemptions(ExecutionSemester executionSemester) { PersonProfessionalData personProfessionalData = getPerson().getPersonProfessionalData(); Interval semesterInterval = new Interval( executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(), executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay()); if (semesterInterval != null && personProfessionalData != null) { return personProfessionalData.getValidPersonProfessionalExemptionByCategoryType(CategoryType.TEACHER, semesterInterval);// ww w. j av a 2 s .c om } return new HashSet<PersonContractSituation>(); }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
public double getServiceExemptionCredits(ExecutionSemester executionSemester) { Set<PersonContractSituation> personProfessionalExemptions = getValidTeacherServiceExemptions( executionSemester);//www .j a v a 2s . c om Interval semesterInterval = new Interval( executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(), executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay()); int lessonsDays = semesterInterval.toPeriod(PeriodType.days()).getDays(); List<Interval> notYetOverlapedIntervals = new ArrayList<Interval>(); List<Interval> newIntervals = new ArrayList<Interval>(); notYetOverlapedIntervals.add(semesterInterval); Double mandatoryLessonHours = getMandatoryLessonHours(executionSemester); Double maxSneHours = mandatoryLessonHours; TeacherService teacherService = getTeacherServiceByExecutionPeriod(executionSemester); if (teacherService != null && teacherService.getReductionService() != null) { maxSneHours = Math.max(0, (mandatoryLessonHours - teacherService.getReductionServiceCredits().doubleValue())); } for (PersonContractSituation personContractSituation : personProfessionalExemptions) { LocalDate exemptionEnd = personContractSituation.getServiceExemptionEndDate() == null ? semesterInterval.getEnd().toLocalDate() : personContractSituation.getServiceExemptionEndDate(); Interval exemptionInterval = new Interval( personContractSituation.getBeginDate().toDateTimeAtStartOfDay(), exemptionEnd.toDateTimeAtStartOfDay()); PersonProfessionalExemption personProfessionalExemption = personContractSituation .getPersonProfessionalExemption(); if (personContractSituation.countForCredits(semesterInterval)) { if (personProfessionalExemption != null) { exemptionEnd = personProfessionalExemption.getEndDate() == null ? semesterInterval.getEnd().toLocalDate() : personProfessionalExemption.getEndDate(); exemptionInterval = new Interval( personProfessionalExemption.getBeginDate().toDateTimeAtStartOfDay(), exemptionEnd.toDateTimeAtStartOfDay()); if (personProfessionalExemption.getIsSabaticalOrEquivalent()) { if (isSabbaticalForSemester(exemptionInterval, semesterInterval)) { return maxSneHours; } else { continue; } } } for (Interval notYetOverlapedInterval : notYetOverlapedIntervals) { Interval overlapInterval = exemptionInterval.overlap(notYetOverlapedInterval); if (overlapInterval != null) { newIntervals.addAll(getNotOverlapedIntervals(overlapInterval, notYetOverlapedInterval)); } else { newIntervals.add(notYetOverlapedInterval); } } notYetOverlapedIntervals.clear(); notYetOverlapedIntervals.addAll(newIntervals); newIntervals.clear(); } } int notOverlapedDays = 0; for (Interval interval : notYetOverlapedIntervals) { notOverlapedDays += interval.toPeriod(PeriodType.days()).getDays(); } int overlapedDays = lessonsDays - notOverlapedDays; Double overlapedPercentage = round(Double.valueOf(overlapedDays) / Double.valueOf(lessonsDays)); return round(overlapedPercentage * maxSneHours); }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
private List<Interval> getNotOverlapedIntervals(Interval overlapInterval, Interval notYetOverlapedInterval) { List<Interval> intervals = new ArrayList<Interval>(); LocalDate overlapIntervalStart = overlapInterval.getStart().toLocalDate(); LocalDate overlapIntervalEnd = overlapInterval.getEnd().toLocalDate(); LocalDate notYetOverlapedIntervalStart = notYetOverlapedInterval.getStart().toLocalDate(); LocalDate notYetOverlapedIntervalEnd = notYetOverlapedInterval.getEnd().toLocalDate(); if (overlapIntervalStart.equals(notYetOverlapedIntervalStart) && !overlapIntervalEnd.equals(notYetOverlapedIntervalEnd)) { intervals.add(new Interval(overlapInterval.getEnd().plusDays(1), notYetOverlapedInterval.getEnd())); } else if (!overlapIntervalStart.equals(notYetOverlapedIntervalStart) && overlapIntervalEnd.equals(notYetOverlapedIntervalEnd)) { intervals//from w w w . jav a 2 s. co m .add(new Interval(notYetOverlapedInterval.getStart(), overlapInterval.getStart().minusDays(1))); } else if (!overlapIntervalStart.equals(notYetOverlapedIntervalStart) && !overlapIntervalEnd.equals(notYetOverlapedIntervalEnd)) { intervals .add(new Interval(notYetOverlapedInterval.getStart(), overlapInterval.getStart().minusDays(1))); intervals.add(new Interval(overlapInterval.getEnd().plusDays(1), notYetOverlapedInterval.getEnd())); } return intervals; }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
private boolean isSabbaticalForSemester(Interval exemptionInterval, Interval semesterPeriod) { double overlapPercentageThisSemester = calculateLessonsIntervalAndExemptionOverlapPercentage(semesterPeriod, exemptionInterval);/*from w w w . j ava2 s . c om*/ if (overlapPercentageThisSemester == 1) { return true; } if (semesterPeriod.contains(exemptionInterval.getStart())) { return overlapPercentageThisSemester >= 0.5; } ExecutionSemester firstExecutionPeriod = ExecutionSemester.readByDateTime(exemptionInterval.getStart()); Interval firstExecutionPeriodInterval = new Interval( firstExecutionPeriod.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(), firstExecutionPeriod.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay()); double overlapPercentageFirstSemester = calculateLessonsIntervalAndExemptionOverlapPercentage( firstExecutionPeriodInterval, exemptionInterval); return overlapPercentageFirstSemester < 0.5; }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
public boolean isActiveForSemester(ExecutionSemester executionSemester) { int minimumWorkingDays = 90; int activeDays = 0; Interval semesterInterval = new Interval( executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(), executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay()); PersonProfessionalData personProfessionalData = getPerson().getPersonProfessionalData(); if (personProfessionalData != null) { GiafProfessionalData giafProfessionalData = personProfessionalData.getGiafProfessionalData(); if (giafProfessionalData != null) { for (final PersonContractSituation situation : giafProfessionalData .getValidPersonContractSituations()) { if (situation.overlaps(semesterInterval) && situation.getProfessionalCategory() != null && situation.getProfessionalCategory().getCategoryType().equals(CategoryType.TEACHER)) { LocalDate beginDate = situation.getBeginDate() .isBefore(semesterInterval.getStart().toLocalDate()) ? semesterInterval.getStart().toLocalDate() : situation.getBeginDate(); LocalDate endDate = situation.getEndDate() == null || situation.getEndDate().isAfter(semesterInterval.getEnd().toLocalDate()) ? semesterInterval.getEnd().toLocalDate() : situation.getEndDate(); int days = new Interval(beginDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay()).toPeriod(PeriodType.days()).getDays() + 1; activeDays = activeDays + days; }/*from w ww . j a v a 2 s. c o m*/ } } } return activeDays >= minimumWorkingDays; }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
public Double getMandatoryLessonHours(ExecutionSemester executionSemester) { PersonContractSituation teacherContractSituation = null; Interval semesterInterval = new Interval( executionSemester.getBeginDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(), executionSemester.getEndDateYearMonthDay().toLocalDate().toDateTimeAtStartOfDay()); if (isActiveForSemester(executionSemester)) { teacherContractSituation = getDominantTeacherContractSituation(semesterInterval); PersonContractSituation personContractSituation = getDominantTeacherServiceExemption(executionSemester); if (personContractSituation != null && !personContractSituation.countForCredits(semesterInterval)) { teacherContractSituation = personContractSituation; }//from w w w. java 2 s.co m } else if (getTeacherAuthorization(executionSemester) != null) { TeacherService teacherService = getTeacherServiceByExecutionPeriod(executionSemester); return teacherService == null ? 0 : teacherService.getTeachingDegreeHours(); } return teacherContractSituation == null ? 0 : teacherContractSituation.getWeeklyLessonHours(semesterInterval); }