Ejemplo n.º 1
0
 private void saveHistoryInject() throws Exception {
   baseURL = publicCalendar.toString();
   baseURL += ";" + privateCalendar.toString();
   baseURL += ";" + eventCategorys.toString();
   baseURL += ";" + categoryIds.toString();
   setting.setBaseURL(baseURL);
   calService.saveCalendarSetting(currentUser, setting);
 }
Ejemplo n.º 2
0
  private void initPrivateCalendar() throws Exception {
    log.info("Inject private datas ....");
    // save setting
    try {
      setting = calService.getCalendarSetting(currentUser);
      log.info(String.format("Save calendar setting for user %s ....", currentUser));
    } catch (Exception e) {
      setting = newCalendarSetting();
      calService.saveCalendarSetting(currentUser, setting);
    }
    long t = System.currentTimeMillis(), t1 = t;

    t = System.currentTimeMillis();
    // save EventCategoy
    List<EventCategory> eventCategories = findEventCategorys();
    for (EventCategory evCat : eventCategories) {
      calService.saveEventCategory(currentUser, evCat, true);
      eventCategory.add(evCat);
      eventCategorys.add(evCat.getId());
    }
    log.info(
        String.format(
            "Saved %s eventCategories in %sms",
            eventCategories.size(), (System.currentTimeMillis() - t)));
    // save calendar
    List<Calendar> calendars = findCalendars(false);
    List<CalendarEvent> events;
    int index = 0, size = calendars.size(), evsCal, evs = 0, tas = 0;
    for (Calendar calendar : calendars) {
      t = System.currentTimeMillis();
      calService.saveUserCalendar(currentUser, calendar, true);
      privateCalendar.add(calendar.getId());
      // save Event
      events = findCalendarEvent(calendar.getId(), "0", CalendarEvent.TYPE_EVENT, false);
      for (CalendarEvent event : events) {
        calService.saveUserEvent(currentUser, calendar.getId(), event, true);
      }
      evsCal = events.size();
      evs += evsCal;
      // save Task
      events = findCalendarEvent(calendar.getId(), "0", CalendarEvent.TYPE_TASK, false);
      tas += events.size();
      for (CalendarEvent event : events) {
        calService.saveUserEvent(currentUser, calendar.getId(), event, true);
      }
      log.info(
          String.format(
              "Saved Calendar %s/%s with %s Events and %s Tasks in %sms",
              (++index), size, evsCal, events.size(), (System.currentTimeMillis()) - t));
    }
    log.info(
        String.format(
            "INITIALIZED EventCategorys=%s / Calendars=%s / Events=%s / Tasks=%s in %sms",
            eventCategories.size(), calendars.size(), evs, tas, (System.currentTimeMillis() - t1)));
    saveHistoryInject();
  }