protected void addCalendarBooking( String uuid, long calendarBookingId, long companyId, long groupId, long userId, String userName, Date createDate, Date modifiedDate, long calendarId, long calendarResourceId, String title, String description, String location, long startTime, long endTime, boolean allDay, String recurrence, int firstReminder, NotificationType firstReminderType, int secondReminder, NotificationType secondReminderType) throws SystemException { CalendarBooking calendarBooking = calendarBookingPersistence.create(calendarBookingId); calendarBooking.setUuid(uuid); calendarBooking.setCompanyId(companyId); calendarBooking.setGroupId(groupId); calendarBooking.setUserId(userId); calendarBooking.setUserName(userName); calendarBooking.setCreateDate(createDate); calendarBooking.setModifiedDate(modifiedDate); calendarBooking.setCalendarId(calendarId); calendarBooking.setCalendarResourceId(calendarResourceId); calendarBooking.setParentCalendarBookingId(calendarBookingId); calendarBooking.setTitle(title); calendarBooking.setDescription(description); calendarBooking.setLocation(location); calendarBooking.setStartTime(startTime); calendarBooking.setEndTime(endTime); calendarBooking.setAllDay(allDay); calendarBooking.setRecurrence(recurrence); calendarBooking.setFirstReminder(firstReminder); calendarBooking.setFirstReminderType(firstReminderType.toString()); calendarBooking.setSecondReminder(secondReminder); calendarBooking.setSecondReminderType(secondReminderType.toString()); calendarBooking.setStatus(WorkflowConstants.STATUS_APPROVED); calendarBooking.setStatusByUserId(userId); calendarBooking.setStatusByUserName(userName); calendarBooking.setStatusDate(createDate); calendarBookingPersistence.update(calendarBooking); }
/** * Converts the soap model instance into a normal model instance. * * @param soapModel the soap model instance to convert * @return the normal model instance */ public static CalendarBooking toModel(CalendarBookingSoap soapModel) { if (soapModel == null) { return null; } CalendarBooking model = new CalendarBookingImpl(); model.setUuid(soapModel.getUuid()); model.setCalendarBookingId(soapModel.getCalendarBookingId()); model.setGroupId(soapModel.getGroupId()); model.setCompanyId(soapModel.getCompanyId()); model.setUserId(soapModel.getUserId()); model.setUserName(soapModel.getUserName()); model.setCreateDate(soapModel.getCreateDate()); model.setModifiedDate(soapModel.getModifiedDate()); model.setCalendarId(soapModel.getCalendarId()); model.setCalendarResourceId(soapModel.getCalendarResourceId()); model.setParentCalendarBookingId(soapModel.getParentCalendarBookingId()); model.setTitle(soapModel.getTitle()); model.setDescription(soapModel.getDescription()); model.setLocation(soapModel.getLocation()); model.setStartTime(soapModel.getStartTime()); model.setEndTime(soapModel.getEndTime()); model.setAllDay(soapModel.getAllDay()); model.setRecurrence(soapModel.getRecurrence()); model.setFirstReminder(soapModel.getFirstReminder()); model.setFirstReminderType(soapModel.getFirstReminderType()); model.setSecondReminder(soapModel.getSecondReminder()); model.setSecondReminderType(soapModel.getSecondReminderType()); model.setStatus(soapModel.getStatus()); model.setStatusByUserId(soapModel.getStatusByUserId()); model.setStatusByUserName(soapModel.getStatusByUserName()); model.setStatusDate(soapModel.getStatusDate()); return model; }
public CalendarBooking addCalendarBooking( long userId, long calendarId, long[] childCalendarIds, long parentCalendarBookingId, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String location, long startDate, long endDate, boolean allDay, String recurrence, long firstReminder, String firstReminderType, long secondReminder, String secondReminderType, ServiceContext serviceContext) throws PortalException, SystemException { // Calendar booking User user = userPersistence.findByPrimaryKey(userId); Calendar calendar = calendarPersistence.findByPrimaryKey(calendarId); java.util.Calendar startDateJCalendar = JCalendarUtil.getJCalendar(startDate); java.util.Calendar endDateJCalendar = JCalendarUtil.getJCalendar(endDate); if (allDay) { startDateJCalendar = JCalendarUtil.toMidnightJCalendar(startDateJCalendar); endDateJCalendar = JCalendarUtil.toLastHourJCalendar(endDateJCalendar); } if (firstReminder < secondReminder) { long originalSecondReminder = secondReminder; secondReminder = firstReminder; firstReminder = originalSecondReminder; } Date now = new Date(); validate(titleMap, startDateJCalendar, endDateJCalendar); long calendarBookingId = counterLocalService.increment(); CalendarBooking calendarBooking = calendarBookingPersistence.create(calendarBookingId); calendarBooking.setUuid(serviceContext.getUuid()); calendarBooking.setGroupId(calendar.getGroupId()); calendarBooking.setCompanyId(user.getCompanyId()); calendarBooking.setUserId(user.getUserId()); calendarBooking.setUserName(user.getFullName()); calendarBooking.setCreateDate(serviceContext.getCreateDate(now)); calendarBooking.setModifiedDate(serviceContext.getModifiedDate(now)); calendarBooking.setCalendarId(calendarId); calendarBooking.setCalendarResourceId(calendar.getCalendarResourceId()); if (parentCalendarBookingId > 0) { calendarBooking.setParentCalendarBookingId(parentCalendarBookingId); } else { calendarBooking.setParentCalendarBookingId(calendarBookingId); } calendarBooking.setTitleMap(titleMap); calendarBooking.setDescriptionMap(descriptionMap); calendarBooking.setLocation(location); calendarBooking.setStartDate(startDateJCalendar.getTimeInMillis()); calendarBooking.setEndDate(endDateJCalendar.getTimeInMillis()); calendarBooking.setAllDay(allDay); calendarBooking.setRecurrence(recurrence); calendarBooking.setFirstReminder(firstReminder); calendarBooking.setFirstReminderType(firstReminderType); calendarBooking.setSecondReminder(secondReminder); calendarBooking.setSecondReminderType(secondReminderType); int status = CalendarBookingWorkflowConstants.STATUS_PENDING; if (parentCalendarBookingId == 0) { status = CalendarBookingWorkflowConstants.STATUS_APPROVED; } calendarBooking.setStatus(status); calendarBooking.setStatusDate(serviceContext.getModifiedDate(now)); calendarBookingPersistence.update(calendarBooking, false); addChildCalendarBookings(calendarBooking, childCalendarIds, serviceContext); // Workflow calendarBookingApprovalWorkflow.startWorkflow(userId, calendarBookingId, serviceContext); return calendarBooking; }