Search in sources :

Example 1 with ScheduleCalendarType

use of com.enonic.xp.scheduler.ScheduleCalendarType in project xp by enonic.

the class SchedulerSerializer method createCalendar.

private static ScheduleCalendar createCalendar(final PropertySet data) {
    final String value = data.getString(ScheduledJobPropertyNames.CALENDAR_VALUE);
    final String timeZone = data.getString(ScheduledJobPropertyNames.CALENDAR_TIMEZONE);
    final String type = data.getString(ScheduledJobPropertyNames.CALENDAR_TYPE);
    final ScheduleCalendarType calendarType = ScheduleCalendarType.valueOf(type);
    switch(calendarType) {
        case CRON:
            return CronCalendarImpl.create().value(value).timeZone(TimeZone.getTimeZone(timeZone)).build();
        case ONE_TIME:
            return OneTimeCalendarImpl.create().value(Instant.parse(value)).build();
        default:
            throw new IllegalArgumentException(String.format("can't parse [%s] calendar type.", type));
    }
}
Also used : ScheduleCalendarType(com.enonic.xp.scheduler.ScheduleCalendarType)

Aggregations

ScheduleCalendarType (com.enonic.xp.scheduler.ScheduleCalendarType)1