@Override
  public ScheduledServiceMonthlyResource getTaskScheduled() {
    if (scheduledTask == null) {
      scheduledTask = new ScheduledServiceMonthlyResource();
      scheduledTask.setEnabled(true);
      scheduledTask.setId(null);
      scheduledTask.setName("taskMonthly");
      scheduledTask.setSchedule("monthly");
      // A future date
      Date startDate = DateUtils.addDays(new Date(), 10);
      startDate = DateUtils.round(startDate, Calendar.DAY_OF_MONTH);
      scheduledTask.setStartDate(String.valueOf(startDate.getTime()));
      scheduledTask.setRecurringTime("03:30");
      scheduledTask.setRecurringDay(Arrays.asList(new String[] {"1", "9", "17", "25"}));

      scheduledTask.setTypeId(UpdateIndexTaskDescriptor.ID);

      ScheduledServicePropertyResource prop = new ScheduledServicePropertyResource();
      prop.setKey("repositoryId");
      prop.setValue("all_repo");
      scheduledTask.addProperty(prop);
    }
    return scheduledTask;
  }
  public <T> ScheduledServiceBaseResource getServiceRestModel(ScheduledTask<T> task) {
    ScheduledServiceBaseResource resource = null;

    if (RunNowSchedule.class.isAssignableFrom(task.getSchedule().getClass())
        || ManualRunSchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceBaseResource();
    } else if (OnceSchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceOnceResource();

      OnceSchedule taskSchedule = (OnceSchedule) task.getSchedule();
      ScheduledServiceOnceResource res = (ScheduledServiceOnceResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setStartTime(formatTime(taskSchedule.getStartDate()));
    } else if (HourlySchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceHourlyResource();

      HourlySchedule taskSchedule = (HourlySchedule) task.getSchedule();
      ScheduledServiceHourlyResource res = (ScheduledServiceHourlyResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setStartTime(formatTime(taskSchedule.getStartDate()));
    } else if (DailySchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceDailyResource();

      DailySchedule taskSchedule = (DailySchedule) task.getSchedule();
      ScheduledServiceDailyResource res = (ScheduledServiceDailyResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setRecurringTime(formatTime(taskSchedule.getStartDate()));
    } else if (WeeklySchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceWeeklyResource();

      WeeklySchedule taskSchedule = (WeeklySchedule) task.getSchedule();
      ScheduledServiceWeeklyResource res = (ScheduledServiceWeeklyResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setRecurringTime(formatTime(taskSchedule.getStartDate()));
      res.setRecurringDay(formatRecurringDayOfWeek(taskSchedule.getDaysToRun()));
    } else if (MonthlySchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceMonthlyResource();

      MonthlySchedule taskSchedule = (MonthlySchedule) task.getSchedule();
      ScheduledServiceMonthlyResource res = (ScheduledServiceMonthlyResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setRecurringTime(formatTime(taskSchedule.getStartDate()));
      res.setRecurringDay(formatRecurringDayOfMonth(taskSchedule.getDaysToRun()));
    } else if (CronSchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceAdvancedResource();

      CronSchedule taskSchedule = (CronSchedule) task.getSchedule();
      ScheduledServiceAdvancedResource res = (ScheduledServiceAdvancedResource) resource;

      res.setCronCommand(taskSchedule.getCronString());
    }

    if (resource != null) {
      resource.setId(task.getId());
      resource.setEnabled(task.isEnabled());
      resource.setName(task.getName());
      resource.setSchedule(getScheduleShortName(task.getSchedule()));
      resource.setTypeId(task.getType());
      resource.setProperties(formatServiceProperties(task.getTaskParams()));
      resource.setAlertEmail(TaskUtils.getAlertEmail(task));
    }

    return resource;
  }