* @see org.projectforge.web.calendar.MyFullCalendarEventsProvider#buildEvents(org.joda.time.DateTime, org.joda.time.DateTime)
*/
@Override
protected void buildEvents(final DateTime start, final DateTime end)
{
final TemplateEntry activeTemplateEntry = filter.getActiveTemplateEntry();
if (activeTemplateEntry == null) {
// Nothing to build.
return;
}
final Set<Integer> visibleCalendars = activeTemplateEntry.getVisibleCalendarIds();
if (CollectionUtils.isEmpty(visibleCalendars) == true) {
// Nothing to build.
return;
}
final TeamEventFilter eventFilter = new TeamEventFilter();
eventFilter.setTeamCals(visibleCalendars);
eventFilter.setStartDate(start.toDate());
eventFilter.setEndDate(end.toDate());
eventFilter.setUser(PFUserContext.getUser());
final List<TeamEvent> teamEvents = teamEventDao.getEventList(eventFilter, true);
boolean longFormat = false;
days = Days.daysBetween(start, end).getDays();
if (days < 10) {
// Week or day view:
longFormat = true;
}
final TeamCalRight right = new TeamCalRight();
final PFUserDO user = PFUserContext.getUser();
final TimeZone timeZone = PFUserContext.getTimeZone();
if (CollectionUtils.isNotEmpty(teamEvents) == true) {
for (final TeamEvent teamEvent : teamEvents) {
final DateTime startDate = new DateTime(teamEvent.getStartDate(), PFUserContext.getDateTimeZone());
final DateTime endDate = new DateTime(teamEvent.getEndDate(), PFUserContext.getDateTimeZone());
final TeamEventDO eventDO;
final TeamCalEventId id = new TeamCalEventId(teamEvent, timeZone);
if (teamEvent instanceof TeamEventDO) {
eventDO = (TeamEventDO) teamEvent;
} else {
eventDO = ((TeamRecurrenceEvent) teamEvent).getMaster();
}
teamEventMap.put(id.toString(), teamEvent);
final MyEvent event = new MyEvent();
event.setClassName(EVENT_CLASS_NAME + " " + EventDroppedCallbackScriptGenerator.NO_CONTEXTMENU_INDICATOR);
event.setId("" + id);
event.setColor(activeTemplateEntry.getColorCode(eventDO.getCalendarId()));
if (eventRight.hasUpdateAccess(PFUserContext.getUser(), eventDO, null)) {
event.setEditable(true);
} else {
event.setEditable(false);