public Exchange createExchange(ExchangePattern pattern, Event event) { Exchange exchange = super.createExchange(pattern); Message message = exchange.getIn(); message.setBody(event); message.setHeader(GoogleCalendarStreamConstants.EVENT_ID, event.getId()); return exchange; } }
@Override public Optional<String> add(Absence absence, CalendarSettings calendarSettings) { googleCalendarClient = getOrCreateGoogleCalendarClient(); if (googleCalendarClient != null) { GoogleCalendarSettings googleCalendarSettings = settingsService.getSettings().getCalendarSettings().getGoogleCalendarSettings(); String calendarId = googleCalendarSettings.getCalendarId(); try { Event eventToCommit = new Event(); fillEvent(absence, eventToCommit); Event eventInCalendar = googleCalendarClient.events().insert(calendarId, eventToCommit).execute(); LOG.info(String.format("Event %s for '%s' added to calendar '%s'.", eventInCalendar.getId(), absence.getPerson().getNiceName(), eventInCalendar.getSummary())); return Optional.of(eventInCalendar.getId()); } catch (IOException ex) { LOG.warn(String.format("An error occurred while trying to add appointment to calendar %s", calendarId), ex); mailService.sendCalendarSyncErrorNotification(calendarId, absence, ex.toString()); } } return Optional.empty(); }
@Override public void updateAppointment(final AppointmentDto appointment) throws IOException { final GoogleAppointmentDto googleAppointmentDto = (GoogleAppointmentDto) appointment; final Event event = client.events().get(calendarId, googleAppointmentDto.getGoogleId()).execute(); populateEventFromAppointmentDto(appointment, event); client.events().update(calendarId, event.getId(), event).execute(); LOG.info("Updated Google appointment " + appointment.getSummary()); }
for (Event e : items) { JSONObject jo = new JSONObject(); jo.put("id", e.getId()); jo.put("epochStart", e.getStart().getDateTime().getValue()); jo.put("epochEnd", e.getEnd().getDateTime().getValue()); jo.put("isParent", !(e.getId().contains("_"))); EventData ed = DatabaseManager.getManager().getEventData(settings.getGuildID(), e.getId());
for (Event e: items) { JSONObject jo = new JSONObject(); jo.put("id", e.getId()); jo.put("epochStart", e.getStart().getDateTime().getValue()); jo.put("epochEnd", e.getEnd().getDateTime().getValue());
for (Event e : items) { JSONObject jo = new JSONObject(); jo.put("id", e.getId()); jo.put("epochStart", e.getStart().getDateTime().getValue()); jo.put("epochEnd", e.getEnd().getDateTime().getValue()); jo.put("isParent", !(e.getId().contains("_"))); EventData ed = DatabaseManager.getManager().getEventData(settings.getGuildID(), e.getId());
for (Event e : items) { JSONObject jo = new JSONObject(); jo.put("id", e.getId()); jo.put("epochStart", e.getStart().getDateTime().getValue()); jo.put("epochEnd", e.getEnd().getDateTime().getValue()); jo.put("isParent", !(e.getId().contains("_"))); EventData ed = DatabaseManager.getManager().getEventData(settings.getGuildID(), e.getId());
for (Event e: items) { JSONObject jo = new JSONObject(); jo.put("id", e.getId()); jo.put("epochStart", e.getStart().getDateTime().getValue()); jo.put("epochEnd", e.getEnd().getDateTime().getValue());
for (Event e: items) { JSONObject jo = new JSONObject(); jo.put("id", e.getId()); jo.put("epochStart", e.getStart().getDateTime().getValue()); jo.put("epochEnd", e.getEnd().getDateTime().getValue());
public static PreEvent copyEvent(long guildId, Event event) { PreEvent pe = new PreEvent(guildId); pe.setSummary(event.getSummary()); pe.setDescription(event.getDescription()); pe.setLocation(event.getLocation()); if (event.getColorId() != null) pe.setColor(EventColor.fromNameOrHexOrID(event.getColorId())); else pe.setColor(EventColor.RED); pe.setEventData(DatabaseManager.getManager().getEventData(guildId, event.getId())); return pe; } }
private AppointmentDto convertToAppointmentDto(final Event event) { final GoogleAppointmentDto result = new GoogleAppointmentDto(); result.setGoogleId(event.getId()); if (event.getExtendedProperties() != null && event.getExtendedProperties().getPrivate() != null) { result.setExchangeId(event.getExtendedProperties().getPrivate().get(EXT_PROPERTY_EXCHANGE_ID));