下面列出了org.joda.time.YearMonthDay#isAfter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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");
}
}
}
}
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);
}
@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);
}
@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;
}
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;
}
@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;
}
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);
}
}
}
}
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");
}
}
@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));
}
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;
}
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);
}
}
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);
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
public boolean isInsidePeriod(final YearMonthDay start, final YearMonthDay end) {
final YearMonthDay date = getTransactionDateDateTime().toYearMonthDay();
return !date.isBefore(start) && !date.isAfter(end);
}
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();
}
}
}
@jvstm.cps.ConsistencyPredicate
protected boolean checkDateInterval() {
final YearMonthDay start = getBeginDateYearMonthDay();
final YearMonthDay end = getEndDateYearMonthDay();
return start != null && (end == null || !start.isAfter(end));
}