@Override
public void createEntity(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
CalendarVO calendar = (CalendarVO) Panel.getPanelStack(request).peek().getAttribute("calendar");
// create event
EventVO event = new EventVO();
Date choosenDate = null;
if(form.getDate() != null) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
choosenDate = sdf.parse(form.getDate());
} catch(ParseException e) {
log.error("invalid date found ()", e);
}
}
Calendar cal = GregorianCalendar.getInstance();
if(choosenDate != null) {
Calendar cal2 = GregorianCalendar.getInstance();
cal2.setTime(choosenDate);
cal.set(Calendar.DAY_OF_MONTH, cal2.get(Calendar.DAY_OF_MONTH));
cal.set(Calendar.MONTH, cal2.get(Calendar.MONTH));
cal.set(Calendar.YEAR, cal2.get(Calendar.YEAR));
}
event.setStartDate(cal.getTime());
cal.add(Calendar.MINUTE, 30);
event.setEndDate(cal.getTime());
event.setRecurrenceType(EventVO.RecurrenceType.NONE);
event.setOccupied(false);
// create event calendar
EventCalendarVO eventCalendar = new EventCalendarVO();
eventCalendar.setCalendar(calendar);
eventCalendar.setEvent(event);
eventCalendar.setParticipiantType(EventCalendarVO.ParticipiantType.HOST);
eventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.ACCEPTED);
eventCalendar.setOwnerUser(calendar.getOwnerUser());
eventCalendar.setOwnerGroup(calendar.getOwnerGroup());
eventCalendar.setAccessUser(calendar.getAccessUser());
eventCalendar.setAccessGroup(calendar.getAccessGroup());
eventCalendar.setAccessGlobal(calendar.getAccessGlobal());
event.getEventCalendars().add(eventCalendar);
attributes.put("event", event);
}