Exemple #1
0
  /** used in template */
  private String renderAllDayGrid() throws Exception {
    int numberOfDays = isShowCustomView_ ? 5 : 7;
    String styleWidth = isShowCustomView_ ? "width:19.8%;*width:20%;" : "width:13.8%;*width:14%;";

    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder
        .append(
            "\n<div id=\"UIWeekViewGridAllDay\" class=\"eventAllDay\" numberOfDays=\""
                + numberOfDays
                + "\">")
        .append("\n<div class=\"eventAlldayBoard\" style=\"position:relative\">")
        .append(
            "\n<table style=\"table-layout:fixed;\" class=\"uiGrid table allDayTable \" cellspacing=\"0\" cellpadding=\"0\">")
        .append("\n<tr>")
        .append("\n<td style=\"width: 55px;\"></td>");

    Calendar cl = getBeginDateOfWeek();
    int t = 0;
    while (t++ < numberOfDays) {

      stringBuilder.append(
          "\n<td class=\"whiteTd\" style=\""
              + styleWidth
              + "\" startTimeFull=\""
              + tempFormat.format(cl.getTime())
              + "\"></td>");
      cl.add(Calendar.DATE, 1);
    }
    stringBuilder.append("\n</tr>").append("\n</table>");

    for (CalendarEvent event : allDayEvent) {
      long begindate = event.getFromDateTime().getTime();
      long enddate = event.getToDateTime().getTime();
      // long startTime  = event.getFromDateTime().getTime() ;
      // long finishTime = event.getToDateTime().getTime() ;
      String eventId = event.getId();
      String calType = event.getCalType();
      String calendarId = event.getCalendarId();
      String color = getColors().get(calType + CalendarUtils.COLON + calendarId);
      // String title    = tf.format(event.getFromDateTime()) + "->" +
      // tf.format(event.getToDateTime())+ ":&#013; " + event.getSummary() ;
      String actionLink = event("UpdateAllDayEvent", eventId);
      boolean isOccur =
          (event.getRepeatType() != null
              && !CalendarEvent.RP_NOREPEAT.equals(event.getRepeatType())
              && (event.getIsExceptionOccurrence() == null || !event.getIsExceptionOccurrence()));
      String recurId = event.getRecurrenceId();
      boolean isEditable;
      if (!event.getCalType().equals(CalendarUtils.PRIVATE_TYPE))
        isEditable = isEventEditable(event);
      else isEditable = true;

      stringBuilder
          .append(
              "\n<div class=\"eventContainer eventAlldayContainer weekViewEventBoxes clearfix\" eventcat=\""
                  + event.getEventCategoryId()
                  + "\" style=\"position:absolute;display:none;\"")
          .append(
              "\n caltype=\""
                  + calType
                  + "\" eventid=\""
                  + eventId
                  + "\" isOccur=\""
                  + isOccur
                  + "\" recurId=\""
                  + recurId
                  + "\"")
          .append(
              "\n calid=\""
                  + calendarId
                  + "\" startTime=\""
                  + begindate
                  + "\" endTime=\""
                  + enddate
                  + "\"")
          .append(
              "\n startTimeFull=\""
                  + tempFormat.format(event.getFromDateTime())
                  + "\" endTimeFull=\""
                  + tempFormat.format(event.getToDateTime())
                  + "\"")
          .append("\n actionlink=\"" + actionLink + "\" isEditable=\"" + isEditable + "\">");

      if (!eventList.contains(eventId)) {
        eventList.add(eventId);

        stringBuilder
            .append(
                "\n<input type=\"hidden\" name=\""
                    + eventId
                    + "calType\" value=\""
                    + calType
                    + "\" />")
            .append(
                "\n<input type=\"hidden\" name=\""
                    + eventId
                    + "calendarId\" value=\""
                    + calendarId
                    + "\" />")
            .append("\n<input type=\"hidden\" name=\"" + eventId + "startTime\" value=\"\" />")
            .append("\n<input type=\"hidden\" name=\"" + eventId + "finishTime\" value=\"\" />")
            .append(
                "\n<input type=\"hidden\" name=\""
                    + eventId
                    + "isOccur\" value=\""
                    + isOccur
                    + "\" />")
            .append(
                "\n<input type=\"hidden\" name=\""
                    + eventId
                    + "recurId\" value=\""
                    + recurId
                    + "\" />")
            .append("\n<input type=\"hidden\" name=\"" + eventId + "currentDate\" value=\"\" />");
      }

      if (event.getFromDateTime().before(getBeginDateOfWeek().getTime())) {
        stringBuilder
            .append("\n<div class=\"leftContinueEvent  pull-left " + color + "\">")
            .append("\n<i class=\"uiIconMiniArrowLeft uiIconWhite\"></i>")
            .append("\n</div>");
      } else {
        stringBuilder
            .append(
                "\n<div class=\"leftResizeEvent LeftResizeEvent resizeEventContainer pull-left "
                    + color
                    + "\">")
            .append("\n<span></span>\n</div>");
      }

      if (event.getToDateTime().after(getEndDateOfWeek().getTime())) {
        stringBuilder
            .append("\n<div class=\"rightContinueEvent pull-right " + color + "\">")
            .append("\n<i class=\"uiIconMiniArrowRight uiIconWhite\"></i>\n</div>");
      } else {
        stringBuilder
            .append(
                "\n<div class=\"rightResizeEvent RightResizeEvent resizeEventContainer pull-right "
                    + color
                    + "\">")
            .append("\n<span></span>\n</div>");
      }

      stringBuilder
          .append(
              "\n<div class=\"eventAlldayContent " + color + "\">" + event.getSummary() + "</div>")
          .append("\n</div>");
    }
    stringBuilder.append("\n</div>\n</div>");

    return stringBuilder.toString();
  }
Exemple #2
0
  /** used in template */
  private String renderEventBoard() throws Exception {
    StringBuilder stringBuilder = new StringBuilder();

    stringBuilder.append("\n<div class=\"eventBoard\">");

    Calendar cl = getBeginDateOfWeek();
    int t = 0;
    int numberOfDays = isShowCustomView_ ? 5 : 7;
    String styleWidth = isShowCustomView_ ? "width:19.8%;*width:20%;" : "width:13.8%;*width:14%;";

    while (t++ < numberOfDays) {
      int day = cl.get(Calendar.DATE);
      int month = cl.get(Calendar.MONTH);
      int year = cl.get(Calendar.YEAR);
      String key = keyGen(day, month, year);
      int dayOfWeek = cl.get(Calendar.DAY_OF_WEEK);
      List<CalendarEvent> events = getEventData().get(key);
      if (events != null) {
        for (CalendarEvent event : events) {
          String eventId = event.getId();
          String begin = tf.format(event.getFromDateTime());
          String begindate = dtf.format(event.getFromDateTime());
          String end = tf.format(event.getToDateTime());
          Calendar cal = CalendarUtils.getInstanceTempCalendar();
          cal.setTime(event.getFromDateTime());
          int beginTime = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
          cal.setTime(event.getToDateTime());
          int endTime = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
          String color =
              getColors().get(event.getCalType() + CalendarUtils.COLON + event.getCalendarId());
          String actionLink = event("UpdateEvent", eventId);
          boolean isOccur =
              (event.getRepeatType() != null
                  && !CalendarEvent.RP_NOREPEAT.equals(event.getRepeatType())
                  && (event.getIsExceptionOccurrence() == null
                      || !event.getIsExceptionOccurrence()));
          String recurId = event.getRecurrenceId();
          boolean isEditable;
          if (!event.getCalType().equals(CalendarUtils.PRIVATE_TYPE))
            isEditable = isEventEditable(event);
          else isEditable = true;

          stringBuilder
              .append(
                  "\n<div class=\"eventContainerBorder weekViewEventBoxes "
                      + color
                      + "\" eventindex=\""
                      + dayOfWeek
                      + "\"")
              .append(
                  " style=\"position: absolute;display:none\" eventcat=\""
                      + event.getEventCategoryId()
                      + "\" caltype=\""
                      + event.getCalType()
                      + "\"")
              .append(
                  " eventid=\""
                      + eventId
                      + "\" calid=\""
                      + event.getCalendarId()
                      + "\" actionlink=\""
                      + actionLink
                      + "\" unselectable=\"on\"")
              .append(
                  " startTime=\""
                      + beginTime
                      + "\" endTime=\""
                      + endTime
                      + "\" isOccur=\""
                      + isOccur
                      + "\" recurId=\""
                      + recurId
                      + "\" isEditable=\""
                      + isEditable
                      + "\">");

          if (!eventList.contains(eventId)) {
            eventList.add(eventId);

            stringBuilder
                .append(
                    "\n<input type=\"hidden\" name=\""
                        + eventId
                        + "calType\" value=\""
                        + event.getCalType()
                        + "\" />")
                .append(
                    "\n<input type=\"hidden\" name=\""
                        + eventId
                        + "calendarId\" value=\""
                        + event.getCalendarId()
                        + "\" />")
                .append("\n<input type=\"hidden\" name=\"" + eventId + "startTime\" value=\"\" />")
                .append("\n<input type=\"hidden\" name=\"" + eventId + "finishTime\" value=\"\" />")
                .append(
                    "\n<input type=\"hidden\" name=\""
                        + eventId
                        + "isOccur\" value=\""
                        + isOccur
                        + "\" />")
                .append(
                    "\n<input type=\"hidden\" name=\""
                        + eventId
                        + "recurId\" value=\""
                        + recurId
                        + "\" />")
                .append(
                    "\n<input type=\"hidden\" name=\"" + eventId + "currentDate\" value=\"\" />");
          }

          /** display event duration */
          if (event.isEventDurationSmallerThanHalfHour()) {
              /** short event */
            stringBuilder
                .append("\n<div class=\"clearfix\">")
                .append(
                    "\n<div unselectable=\"on\" class=\"eventContainerBar eventTitle pull-left\" style=\" display: inline-block; \">");

            if (CalendarEvent.TYPE_TASK.equals(event.getEventType())) {
              stringBuilder.append("\n<i class=\"uiIconCalTaskMini\"></i>");
            } else {
              stringBuilder.append("\n<i class=\"uiIconCalClockMini\"></i>");
              // occurring icon
              if (isOccur) {
                stringBuilder.append("<i class=\"uiIconCalRecurring\"></i>");
              } else if (!isOccur && Boolean.TRUE.equals(event.getIsExceptionOccurrence())) {
                stringBuilder.append("<i class=\"uiIconCalEditRecurring\"></i>");
              }
            }

            stringBuilder.append(
                "\n<i class=\"uiIconCal"
                    + event.getPriority()
                    + "Priority\"></i>"
                    + begin
                    + "</div>");

            /** display event summary */
            if ((event.getEventType().equals(CalendarEvent.TYPE_TASK))
                && (event.getEventState().equals(CalendarEvent.COMPLETED))) {
              stringBuilder.append(
                  "\n<div unselectable=\"on\" class=\"eventContainer\" style=\"text-decoration:line-through; \">"
                      + event.getSummary()
                      + "</div>");
            } else {
              stringBuilder.append(
                  "\n<div class=\"eventContainer \" >" + event.getSummary() + "</div>");
            }
            stringBuilder.append("</div>");
          } else {

            stringBuilder.append(
                "\n<div unselectable=\"on\" class=\"eventContainerBar eventTitle\">");

            if (CalendarEvent.TYPE_TASK.equals(event.getEventType())) {
              stringBuilder.append("\n<i class=\"uiIconCalTaskMini\"></i>");
            } else {
              stringBuilder.append("\n<i class=\"uiIconCalClockMini\"></i>");
              // occurring icon
              if (isOccur) {
                stringBuilder.append("<i class=\"uiIconCalRecurring\"></i>");
              } else if (!isOccur && Boolean.TRUE.equals(event.getIsExceptionOccurrence())) {
                stringBuilder.append("<i class=\"uiIconCalEditRecurring\"></i>");
              }
            }

            stringBuilder
                .append("\n<i class=\"uiIconCal" + event.getPriority() + "Priority\"></i>")
                .append(begin + " - " + end + "</div>");

            if ((event.getEventType().equals(CalendarEvent.TYPE_TASK))
                && (event.getEventState().equals(CalendarEvent.COMPLETED))) {
              stringBuilder
                  .append(
                      "\n<div unselectable=\"on\" class=\"eventContainer\" style=\" text-decoration:line-through; \">")
                  .append(event.getSummary() + "</div>");
            } else {
              stringBuilder.append(
                  "\n<div class=\"eventContainer\">" + event.getSummary() + "</div>");
            }
          }

          stringBuilder
              .append("\n<div class=\"resizeEventContainer\" unselectable=\"on\">")
              .append("\n<span></span>\n</div>\n</div>");
        }
      }
      cl.add(Calendar.DATE, 1);
    }

    stringBuilder
        .append("\n</div>")
        .append(
            "\n<table style=\"table-layout:fixed;\" class=\"uiGrid table \" id=\"UIWeekViewGrid\" lastupdatedid=\""
                + getLastUpdatedEventId()
                + "\"")
        .append(" cellspacing=\"0\" cellpadding=\"0\">")
        .append("\n<tbody>");

    boolean flag = false;
    String style = isShowWorkingTime() ? "WorkOffTime" : "none";
    String styleClass;

    String tempTimeFormat = CalendarUtils.TIMEFORMATPATTERNS[0];
    if (getTimeFormat().startsWith("HH")) tempTimeFormat = CalendarUtils.TIMEFORMATPATTERNS[1];
    int counter = 0;
    String timeName = "Gray";
    for (String full : getDisplayTimes(tempTimeFormat, getTimeInterval(), Locale.ENGLISH)) {
      if ((counter % 4) == 0 || (counter % 4) == 1) {
        timeName = "OddRow";
      } else if ((counter % 4) == 2 || (counter % 4) == 3) {
        timeName = "EvenRow";
      }

      String time = full.substring(0, full.lastIndexOf("_"));
      String display = full.substring(full.lastIndexOf("_") + 1);
      if (isShowWorkingTime()) {
        if (time.equals(getStartTime())) {
          style = "";
        }
        if (time.equals(getEndTime())) {
          style = "WorkOffTime";
        }
      }

      if (flag) {
        styleClass = "tdDotLine";
      } else {
        styleClass = "tdLine";
      }

      stringBuilder.append("\n<tr class=\"" + style + " " + timeName + "\">");

      if (!flag) {
        stringBuilder.append("\n<td class=\"tdTime center\" style=\"width: 55px;\">");
      } else {
        stringBuilder.append("\n<td style=\"width: 55px;\">");
      }

      stringBuilder.append("\n<div>");
      if (!flag) {
        stringBuilder.append(display);
      } else {
        stringBuilder.append("&nbsp;");
      }

      stringBuilder.append("\n</div>\n</td>");

      cl = getBeginDateOfWeek();
      DateFormat dayFormat = new SimpleDateFormat(getDateFormat(), Locale.ENGLISH);
      DateFormat fullDateFormat =
          new SimpleDateFormat(getDateFormat() + " " + CalendarUtils.TIMEFORMAT, Locale.ENGLISH);
      dayFormat.setCalendar(cl);
      fullDateFormat.setCalendar(cl);

      t = 0;
      String cssClass;
      while (t++ < numberOfDays) {
        // df.setCalendar(cl) ;
        String startTime = dayFormat.format(cl.getTime()) + " " + time;
        // dtf.setCalendar(cl) ;
        fullDateFormat.setLenient(false);
        // add try-catch block to handle Daylight Saving Time problem
        try {
          cl.setTime(fullDateFormat.parse(startTime));
        } catch (ParseException e) {
          fullDateFormat.setLenient(true);
          cl.setTime(fullDateFormat.parse(startTime));
        }
        int dayOfWeek = cl.get(Calendar.DAY_OF_WEEK);
        if (isCurrentDay(cl.get(Calendar.DATE), cl.get(Calendar.MONTH), cl.get(Calendar.YEAR))) {
          cssClass = "today";
        } else if (dayOfWeek == 1 || dayOfWeek == 7) {
          cssClass = "Weekend";
        } else {
          cssClass = "Weekday";
        }

        stringBuilder
            .append(
                "\n<td startFull=\""
                    + tempFormat.format(cl.getTime())
                    + "\" startTime=\""
                    + cl.getTimeInMillis()
                    + "\"")
            .append(
                " eventindex=\""
                    + dayOfWeek
                    + "\" class=\""
                    + styleClass
                    + " "
                    + cssClass
                    + " "
                    + style
                    + "\" style=\""
                    + styleWidth
                    + "\">")
            .append("\n<span></span>\n</td>");
        cl.add(Calendar.DATE, 1);
      }
      flag = !flag;

      stringBuilder.append("</tr>");
      counter++;
    }
    stringBuilder.append("\n</tbody>\n</table>");

    return stringBuilder.toString();
  }
  /**
   * Build the repeating summary, i.e: daily every 2 days, until 02/03/2011. <br>
   * The summary structure is defined in resource bundle, it contains some parameters and </br> will
   * be replaced by values from repeatEvent. <br>
   *
   * <p>There are 6 parameters: {count}, {until}, {interval}, {byDays}, {theDay}, {theNumber}.<br>
   * Some labels in resource bundle to define numbers (the first, the second, ...) which were used
   * in summary
   *
   * @param repeatEvent the repeating event
   * @return summary string about repeating event
   * @throws Exception
   */
  public String buildRepeatSummary(CalendarEvent repeatEvent) {
    if (repeatEvent == null) return "";
    String repeatType = repeatEvent.getRepeatType();
    if (CalendarEvent.RP_NOREPEAT.equals(repeatType) || repeatType == null) return "";

    try {
      String userId = ConversationState.getCurrent().getIdentity().getUserId();
      calService_ =
          (CalendarService)
              PortalContainer.getInstance().getComponentInstance(CalendarService.class);
      CalendarSetting calSetting = calService_.getCalendarSetting(userId);
      WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance();

      Locale locale = requestContext.getParentAppRequestContext().getLocale();
      DateFormat format = new SimpleDateFormat(calSetting.getDateFormat(), locale);
      DateFormatSymbols symbols = new DateFormatSymbols(locale);
      String[] dayOfWeeks = symbols.getWeekdays();

      int interval = (int) repeatEvent.getRepeatInterval();
      int count = (int) repeatEvent.getRepeatCount();
      Date until = repeatEvent.getRepeatUntilDate();
      String endType = RP_END_NEVER;
      if (count > 0) endType = RP_END_AFTER;
      if (until != null) endType = RP_END_BYDATE;

      StringBuilder pattern = new StringBuilder("");
      if (repeatType.equals(CalendarEvent.RP_DAILY)) {
        if (interval == 1) {
          // pattern = "Daily";
          pattern.append(CalendarUIActivity.getUICalendarLabel("daily"));
        } else {
          // pattern = "Every {interval} days";
          pattern.append(CalendarUIActivity.getUICalendarLabel("every-day"));
        }
        if (endType.equals(RP_END_AFTER)) {
          // pattern = "Daily, {count} times";
          // pattern = "Every {interval} days, {count} times";
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("count-times"));
        }
        if (endType.equals(RP_END_BYDATE)) {
          // pattern = "Daily, until {until}";
          // pattern = "Every {interval} days, until {until}";
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("until"));
        }

        return new String(pattern)
            .replace("{interval}", String.valueOf(interval))
            .replace("{count}", String.valueOf(repeatEvent.getRepeatCount()))
            .replace(
                "{until}",
                repeatEvent.getRepeatUntilDate() == null
                    ? ""
                    : format.format(repeatEvent.getRepeatUntilDate()));
      }

      if (repeatType.equals(CalendarEvent.RP_WEEKLY)) {
        if (interval == 1) {
          // pattern = "Weekly on {byDays}";
          pattern.append(CalendarUIActivity.getUICalendarLabel("weekly"));
        } else {
          // pattern = "Every {interval} weeks on {byDays}";
          pattern.append(CalendarUIActivity.getUICalendarLabel("every-week"));
        }
        if (endType.equals(RP_END_AFTER)) {
          // pattern = "Weekly on {byDays}, {count} times";
          // pattern = "Every {interval} weeks on {byDays}, {count} times";
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("count-times"));
        }
        if (endType.equals(RP_END_BYDATE)) {
          // pattern = "Weekly on {byDays}, until {until}";
          // pattern = "Every {interval} weeks on {byDays}, until {until}";
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("until"));
        }

        String[] weeklyByDays = repeatEvent.getRepeatByDay();
        StringBuffer byDays = new StringBuffer();
        for (int i = 0; i < weeklyByDays.length; i++) {
          if (i == 0) {
            byDays.append(dayOfWeeks[convertToDayOfWeek(weeklyByDays[0])]);
          } else {
            byDays.append(", ");
            byDays.append(dayOfWeeks[convertToDayOfWeek(weeklyByDays[i])]);
          }
        }
        return new String(pattern)
            .replace("{interval}", String.valueOf(interval))
            .replace("{count}", String.valueOf(repeatEvent.getRepeatCount()))
            .replace(
                "{until}",
                repeatEvent.getRepeatUntilDate() == null
                    ? ""
                    : format.format(repeatEvent.getRepeatUntilDate()))
            .replace("{byDays}", byDays.toString());
      }

      if (repeatType.equals(CalendarEvent.RP_MONTHLY)) {
        String monthlyType = RP_MONTHLY_BYMONTHDAY;
        if (repeatEvent.getRepeatByDay() != null && repeatEvent.getRepeatByDay().length > 0)
          monthlyType = RP_MONTHLY_BYDAY;

        if (interval == 1) {
          // pattern = "Monthly on"
          pattern.append(CalendarUIActivity.getUICalendarLabel("monthly"));
        } else {
          // pattern = "Every {interval} months on
          pattern.append(CalendarUIActivity.getUICalendarLabel("every-month"));
        }

        if (monthlyType.equals(RP_MONTHLY_BYDAY)) {
          // pattern = "Monthly on {theNumber} {theDay}
          // pattern = "Every {interval} months on {theNumber} {theDay}
          pattern.append(" " + CalendarUIActivity.getUICalendarLabel("monthly-by-day"));
        } else {
          // pattern = "Monthly on day {theDay}
          // pattern = "Every {interval} months on day {theDay}
          pattern.append(" " + CalendarUIActivity.getUICalendarLabel("monthly-by-month-day"));
        }

        if (endType.equals(RP_END_AFTER)) {
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("count-times"));
        }
        if (endType.equals(RP_END_BYDATE)) {
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("until"));
        }

        String theNumber = ""; // the first, the second, the third, ...
        String theDay =
            ""; // in monthly by day, it's Monday, Tuesday, ... (day of week), in monthly by
        // monthday, it's 1-31 (day of month)
        if (monthlyType.equals(RP_MONTHLY_BYDAY)) {
          java.util.Calendar temp = getCalendarInstanceBySetting(calSetting);
          temp.setTime(repeatEvent.getFromDateTime());
          int weekOfMonth = temp.get(java.util.Calendar.WEEK_OF_MONTH);
          java.util.Calendar temp2 = getCalendarInstanceBySetting(calSetting);
          temp2.setTime(temp.getTime());
          temp2.add(java.util.Calendar.DATE, 7);
          if (temp2.get(java.util.Calendar.MONTH) != temp.get(java.util.Calendar.MONTH))
            weekOfMonth = 5;
          int dayOfWeek = temp.get(java.util.Calendar.DAY_OF_WEEK);
          String[] weekOfMonths =
              new String[] {
                CalendarUIActivity.getUICalendarLabel("summary-the-first"),
                CalendarUIActivity.getUICalendarLabel("summary-the-second"),
                CalendarUIActivity.getUICalendarLabel("summary-the-third"),
                CalendarUIActivity.getUICalendarLabel("summary-the-fourth"),
                CalendarUIActivity.getUICalendarLabel("summary-the-last")
              };
          theNumber = weekOfMonths[weekOfMonth - 1];
          theDay = dayOfWeeks[dayOfWeek];
        } else {
          java.util.Calendar temp = getCalendarInstanceBySetting(calSetting);
          temp.setTime(repeatEvent.getFromDateTime());
          int dayOfMonth = temp.get(java.util.Calendar.DAY_OF_MONTH);
          theDay = String.valueOf(dayOfMonth);
        }
        return new String(pattern)
            .replace("{interval}", String.valueOf(interval))
            .replace("{count}", String.valueOf(repeatEvent.getRepeatCount()))
            .replace(
                "{until}",
                repeatEvent.getRepeatUntilDate() == null
                    ? ""
                    : format.format(repeatEvent.getRepeatUntilDate()))
            .replace("{theDay}", theDay)
            .replace("{theNumber}", theNumber);
      }

      if (repeatType.equals(CalendarEvent.RP_YEARLY)) {
        if (interval == 1) {
          // pattern = "Yearly on {theDay}"
          pattern.append(CalendarUIActivity.getUICalendarLabel("yearly"));
        } else {
          // pattern = "Every {interval} years on {theDay}"
          pattern.append(CalendarUIActivity.getUICalendarLabel("every-year"));
        }

        if (endType.equals(RP_END_AFTER)) {
          // pattern = "Yearly on {theDay}, {count} times"
          // pattern = "Every {interval} years on {theDay}, {count} times"
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("count-times"));
        }
        if (endType.equals(RP_END_BYDATE)) {
          // pattern = "Yearly on {theDay}, until {until}"
          // pattern = "Every {interval} years on {theDay}, until {until}"
          pattern.append(", " + CalendarUIActivity.getUICalendarLabel("until"));
        }

        String theDay = format.format(repeatEvent.getFromDateTime()); //
        return new String(pattern)
            .replace("{interval}", String.valueOf(interval))
            .replace("{count}", String.valueOf(repeatEvent.getRepeatCount()))
            .replace(
                "{until}",
                repeatEvent.getRepeatUntilDate() == null
                    ? ""
                    : format.format(repeatEvent.getRepeatUntilDate()))
            .replace("{theDay}", theDay);
      }
    } catch (Exception e) {
      LOG.info(e.getLocalizedMessage());
    }
    return null;
  }