person.setOptional(optional);
return person;
}
public AppointmentDto convertToAppointmentDto(final Appointment appointment) throws ServiceLocalException {
final AppointmentDto appointmentDto = new AppointmentDto();
appointmentDto.setExchangeId(appointment.getId().getUniqueId());
appointmentDto.setLastModified(convertToJodaDateTime(appointment.getLastModifiedTime(), false));
appointmentDto.setSummary(appointment.getSubject());
try {
appointmentDto.setDescription(MessageBody.getStringFromMessageBody(appointment.getBody()));
} catch (final Exception e) {
LOG.error("Unable to retrieve appointment body from Exchange", e);
}
appointmentDto.setStart(convertToJodaDateTime(appointment.getStart(), appointment.getIsAllDayEvent()));
appointmentDto.setEnd(convertToJodaDateTime(appointment.getEnd(), appointment.getIsAllDayEvent()));
appointmentDto.setAllDay(appointment.getIsAllDayEvent());
appointmentDto.setLocation(appointment.getLocation());
if (appointment.getOrganizer() != null) {
appointmentDto.setOrganizer(convertToPersonDto(appointment.getOrganizer(), false));
}
final Set<PersonDto> attendees = new HashSet<PersonDto>();
if (appointment.getRequiredAttendees() != null) {
for (final Attendee exchangeAttendee : appointment.getRequiredAttendees()) {
attendees.add(convertToPersonDto(exchangeAttendee, false));
}
}
if (appointment.getOptionalAttendees() != null) {
for (final Attendee exchangeAttendee : appointment.getOptionalAttendees()) {
attendees.add(convertToPersonDto(exchangeAttendee, true));
}
}
appointmentDto.setAttendees(attendees);
appointmentDto.setReminderMinutesBeforeStart(appointment.getReminderMinutesBeforeStart());
if (appointment.getRecurrence() != null) {
if (appointment.getRecurrence() instanceof Recurrence.DailyPattern) {
appointmentDto.setRecurrenceType(RecurrenceType.DAILY);
} else if (appointment.getRecurrence() instanceof Recurrence.WeeklyPattern) {
appointmentDto.setRecurrenceType(RecurrenceType.WEEKLY);
} else if (appointment.getRecurrence() instanceof Recurrence.MonthlyPattern) {
appointmentDto.setRecurrenceType(RecurrenceType.MONTHLY);
} else if (appointment.getRecurrence() instanceof Recurrence.YearlyPattern) {
appointmentDto.setRecurrenceType(RecurrenceType.YEARLY);
}
appointmentDto.setRecurrenceCount(appointment.getRecurrence().getNumberOfOccurrences());
}
return appointmentDto;
}