Example #1
0
  protected int createAppointmentsForTimeSpan(
      RecurringAction recurringAction, Date startDate, Date endDate) {
    List<Event> eventList =
        appointmentFinder.findPossibleAppointments(recurringAction, startDate, endDate);
    int eventsCreated = 0;
    try {
      for (Event event : eventList) {
        // TODO use prefered calendar
        int calendarId = 1;

        Uri cUri =
            eventRepository.insert(
                EventFactory.createContentValueFromEvent(
                    recurringAction.getId(), event, calendarId));
        event.setUri(cUri);
        event.setRecurringAction(recurringAction);
        eventDao.createOrUpdate(event);
        eventsCreated++;
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return eventsCreated;
  }
Example #2
0
 protected void removeOldAppointments(RecurringAction recurringAction) {
   Collection<Event> events = recurringAction.getEvents();
   for (Event event : events) {
     eventRepository.deleteEvent(event.getUri());
     recurringAction.removeEvent(event);
     event.setRecurringAction(null);
     try {
       eventDao.delete(event);
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
   try {
     recurringActionDao.update(recurringAction);
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }