@Override public int compare(final TeamEventDO o1, final TeamEventDO o2) { if ((o1 == null || o1.getStartDate() == null) && (o2 == null || o2.getStartDate() == null)) { return 0; } if (o1 == null || o1.getStartDate() == null) { return -1; } if (o2 == null || o2.getStartDate() == null) { return 1; } // at this point, no NPE could occur return o1.getStartDate().compareTo(o2.getStartDate()); } };
/** * @param master * @param startDay day of event (startDate and endDate will be calculated based on this day and the master). */ public TeamRecurrenceEvent(final TeamEventDO master, final Calendar startDate) { this.master = master; final Calendar cal = (Calendar) startDate.clone(); this.startDate = cal.getTime(); final long duration = master.getEndDate().getTime() - master.getStartDate().getTime(); cal.add(Calendar.MINUTE, (int) (duration / 60000)); this.endDate = cal.getTime(); }
@Override public String getObject() { final StringBuffer buf = new StringBuffer(); if (data.getStartDate() != null) { buf.append(DateHelper.TECHNICAL_ISO_UTC.get().format(data.getStartDate())); if (data.getEndDate() != null) { buf.append(" - "); } } if (data.getEndDate() != null) { buf.append(DateHelper.TECHNICAL_ISO_UTC.get().format(data.getEndDate())); } return buf.toString(); } });
private boolean matches(final TeamEventDO teamEventDo, Long startTime, Long endTime) { // Following period extension is needed due to all day events which are stored in UTC. The additional events in the result list not // matching the time period have to be removed by caller! startTime = startTime - ONE_DAY; endTime = endTime + ONE_DAY; // the following implementation is inspired by TeamEventDao with the following lines: // queryFilter.add(Restrictions.or( // (Restrictions.or(Restrictions.between("startDate", startDate, endDate), Restrictions.between("endDate", startDate, endDate))), // // get events whose duration overlap with chosen duration. // (Restrictions.and(Restrictions.le("startDate", startDate), Restrictions.ge("endDate", endDate))))); final Long eventStartTime = teamEventDo.getStartDate() != null ? teamEventDo.getStartDate().getTime() : TeamEventDao.MIN_DATE_1800; final Long eventEndTime = teamEventDo.getEndDate() != null ? teamEventDo.getEndDate().getTime() : TeamEventDao.MAX_DATE_3000; if (between(eventStartTime, startTime, endTime) || between(eventEndTime, startTime, endTime)) { return true; } if (eventStartTime <= startTime && eventEndTime >= endTime) { return true; } return false; }
public List<TeamEventDO> getResultList(final Long startTime, final Long endTime, final boolean minimalAccess) { // sorting should by synchronized synchronized (this) { if (sorted == false) { sort(); } } final List<TeamEventDO> result = new ArrayList<TeamEventDO>(); for (final TeamEventDO teamEventDo : eventList) { // all our events are sorted, if we find a event which starts // after the end date, we can break this iteration if (teamEventDo.getStartDate().getTime() > endTime) { break; } if (matches(teamEventDo, startTime, endTime) == true) { if (minimalAccess == true) { result.add(teamEventDo.createMinimalCopy()); } else { result.add(teamEventDo); } } } // and return return result; }
final Date startDate1 = o1.getStartDate(); final Date startDate2 = o2.getStartDate(); if (startDate1 == null) { if (startDate2 == null) {
@Override public Property toVEvent(final TeamEventDO event) { if (event.isAllDay() == true) { final Date startUtc = CalendarUtils.getUTCMidnightDate(event.getStartDate()); net.fortuna.ical4j.model.Date date = new net.fortuna.ical4j.model.Date(startUtc); return new DtStart(date); } else { DateTime date = new DateTime(event.getStartDate()); date.setTimeZone(TIMEZONE_REGISTRY.getTimeZone(event.getTimeZone().getID())); return new DtStart(date); } }
teamEventDO.setStartDate(new Timestamp(teamEventDO.getStartDate().getTime() + startDateMove));
@Override public void setResponsePage() { if (returnToPage == null) { returnToPage = new TeamCalCalendarPage(new PageParameters()); } super.setResponsePage(); if (returnToPage instanceof CalendarPage) { // Display the date of this time sheet in the CalendarPage (useful if the time sheet was moved). if (newEvent != null) { ((CalendarPage) returnToPage).setStartDate(newEvent.getStartDate()); } else if (eventOfCaller != null) { ((CalendarPage) returnToPage).setStartDate(eventOfCaller.getStartDate()); } else { ((CalendarPage) returnToPage).setStartDate(getData().getStartDate()); } } }
private boolean preCheckSendMail(final TeamEventDO event) { // check event ownership if (event.isOwnership() != null && event.isOwnership() == false) { return false; } // check date, send mails for future events only final Date now = new Date(); if (event.getStartDate().after(now)) { return true; } // No recurrence so event is in the past if (event.getRecurrenceRule() == null) { return false; } // Check rrule to see if an until date exists try { final RRule rRule = new RRule(event.getRecurrenceRule()); final net.fortuna.ical4j.model.Date until = rRule.getRecur().getUntil(); if (until == null) { return true; } final Date untilDate = new Date(until.getTime()); return untilDate.before(now) == false; } catch (ParseException e) { return false; } }
@Override public void onClick() { final TimesheetDO timesheet = new TimesheetDO(); timesheet.setStartDate(getData().getStartDate())// .setStopTime(getData().getEndDate()) // .setLocation(getData().getLocation()); final StringBuffer buf = new StringBuffer(); buf.append(getData().getSubject()); final String note = getData().getNote(); if (StringUtils.isNotBlank(note) == true) { buf.append("\n").append(note); } timesheet.setDescription(buf.toString()); timesheetDao.setUser(timesheet, getUserId()); final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(timesheet); timesheetEditPage.setReturnToPage(getReturnToPage()); setResponsePage(timesheetEditPage); }
if (list != null) { for (final TeamEventDO event : list) { if (matches(event.getStartDate(), event.getEndDate(), event.isAllDay(), teamEventFilter) == true) { result.add(event);
/** * Sets midnight (UTC) of all day events. * * @see org.projectforge.framework.persistence.api.BaseDao#onSaveOrModify(org.projectforge.core.ExtendedBaseDO) */ @Override protected void onSaveOrModify(final TeamEventDO event) { super.onSaveOrModify(event); Validate.notNull(event.getCalendar()); // If is all day event, set start and stop to midnight if (event.isAllDay() == true) { final Date startDate = event.getStartDate(); if (startDate != null) { event.setStartDate(CalendarUtils.getUTCMidnightTimestamp(startDate)); } final Date endDate = event.getEndDate(); if (endDate != null) { event.setEndDate(CalendarUtils.getUTCMidnightTimestamp(endDate)); } } }
Assert.assertEquals(event.getStartDate().getTime(), DateHelper.parseIsoTimestamp("2020-01-01 12:00:00.000", DateHelper.EUROPE_BERLIN).getTime());
@Override public void onSubmit() { final TeamEventDO event = getData(); final TimesheetDO timesheet = new TimesheetDO(); if (event != null) { timesheet.setStartDate(event.getStartDate()); timesheet.setStopTime(event.getEndDate()); } if (returnToPage == null) { returnToPage = new TeamCalCalendarPage(new PageParameters()); } setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage(returnToPage)); }
if (vacationTeamEvent.getStartDate().equals(startTimestamp) == false || vacationTeamEvent.getEndDate().equals(endTimestamp) == false) { vacationTeamEvent.setStartDate(startTimestamp); vacationTeamEvent.setEndDate(endTimestamp);
Assert.assertEquals("ICAL_IMPORT_UID_VALUE_UPDATE_IF_REQUIRED", event.getUid()); Assert.assertEquals(DateHelper.parseIsoTimestamp("2017-06-22 15:07:52.000", DateHelper.UTC).getTime(), event.getDtStamp().getTime()); Assert.assertEquals(DateHelper.parseIsoTimestamp("2020-01-01 12:00:00.000", DateHelper.EUROPE_BERLIN).getTime(), event.getStartDate().getTime()); Assert.assertEquals(DateHelper.parseIsoTimestamp("2020-01-01 13:00:00.000", DateHelper.EUROPE_BERLIN).getTime(), event.getEndDate().getTime()); Assert.assertEquals("Test ical import web frontend", event.getSubject());
Assert.assertEquals("ICAL_IMPORT_UID_VALUE_UPDATE_IF_REQUIRED", event.getUid()); Assert.assertEquals(DateHelper.parseIsoTimestamp("2017-06-21 15:07:52.000", DateHelper.UTC).getTime(), event.getDtStamp().getTime()); Assert.assertEquals(DateHelper.parseIsoTimestamp("2020-01-01 12:00:00.000", DateHelper.EUROPE_BERLIN).getTime(), event.getStartDate().getTime()); Assert.assertEquals(DateHelper.parseIsoTimestamp("2020-01-01 13:00:00.000", DateHelper.EUROPE_BERLIN).getTime(), event.getEndDate().getTime()); Assert.assertEquals("Test ical import web frontend (edited)", event.getSubject());
/** * @see org.projectforge.web.core.importstorage.AbstractImportStoragePanel#addColumns(org.apache.wicket.markup.repeater.RepeatingView, * org.projectforge.framework.persistence.utils.ImportedElement) */ @Override protected void addColumns(final RepeatingView cellRepeater, final ImportedElement<?> element, final String style) { final TeamEventDO event = (TeamEventDO) element.getValue(); addCell(cellRepeater, event.getSubject(), style); addCell(cellRepeater, event.getLocation(), style); addCell(cellRepeater, String.valueOf(event.isAllDay()), style); addCell(cellRepeater, DateTimeFormatter.instance().getFormattedDateTime(event.getStartDate()), style); addCell(cellRepeater, DateTimeFormatter.instance().getFormattedDateTime(event.getEndDate()), style); addCell(cellRepeater, event.getNote(), style); addCell(cellRepeater, event.getRecurrenceRule(), style); addCell(cellRepeater, DateTimeFormatter.instance().getFormattedDate(event.getRecurrenceUntil()), style); } }
private void copyFields(final CalendarEventObject event, final TeamEventDO src) { event.setCalendarId(src.getCalendarId()); event.setRecurrenceRule(src.getRecurrenceRule()); event.setRecurrenceExDate(src.getRecurrenceExDate()); event.setRecurrenceUntil(src.getRecurrenceUntil()); DOConverter.copyFields(event, src); event.setLastUpdate(src.getDtStamp()); if (src.getReminderActionType() != null && src.getReminderDuration() != null && src.getReminderDurationUnit() != null) { event.setReminderType(src.getReminderActionType().toString()); event.setReminderDuration(src.getReminderDuration()); final ReminderDurationUnit unit = src.getReminderDurationUnit(); event.setReminderUnit(unit.toString()); final DateHolder date = new DateHolder(src.getStartDate()); if (unit == ReminderDurationUnit.MINUTES) { date.add(Calendar.MINUTE, -src.getReminderDuration()); event.setReminder(date.getDate()); } else if (unit == ReminderDurationUnit.HOURS) { date.add(Calendar.HOUR, -src.getReminderDuration()); event.setReminder(date.getDate()); } else if (unit == ReminderDurationUnit.DAYS) { date.add(Calendar.DAY_OF_YEAR, -src.getReminderDuration()); event.setReminder(date.getDate()); } else { log.warn("ReminderDurationUnit '" + src.getReminderDurationUnit() + "' not yet implemented."); } } }