com.sas.hls.schedule
Class ScheduleTrigger

java.lang.Object
  extended by com.sas.hls.schedule.ScheduleTrigger
All Implemented Interfaces:
Serializable

public class ScheduleTrigger
extends Object
implements Serializable

ScheduleTrigger defines when the schedule will run.

Examples:

To define a schedule trigger that runs once at a specified time:

ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.ONCE);
trigger.setStartDate(todayDate);

To define a schedule trigger that runs every two days with a scheduled end date:

ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.DAILY);
trigger.setStartDate(startDate);
trigger.setInterval(2);
trigger.setEndDate(endDate);

To define a schedule trigger that runs every week on Monday for the next 8 weeks:

ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.WEEKLY);
trigger.setStartDate(todayDate);
List daysOfWeek = new ArrayList();
daysOfWeek.add(DayOfWeek.MON);
trigger.setDaysOfWeek(daysOfWeek);
trigger.setNumOccurrences(8);
trigger.setTimeZone(Calendar.getInstance(TimeZone.getTimeZone("CST")).getTimeZone().getID());

To define a schedule trigger that runs every 5 minutes indefinitely:

ScheduleTrigger trigger = new ScheduleTrigger();
trigger.setTriggerType(TriggerType.MINUTELY);
trigger.setStartDate(todayDate);
trigger.setInterval(5);
trigger.setRepeatForever(true);

There are several options for defining how or if a recurring schedule ends. Here is the order in which the options take precedence. If repeateForever is set to true, that takes precedence, and the other options are ignored. If repeateForever is false, and numOccurrences is specified, endDate is ignored.

  • repeatForever
  • numOccurrences
  • endDate
  • See Also:
    Serialized Form

    Nested Class Summary
    static class ScheduleTrigger.DayOfWeek
              DayOfWeek is an enumeration representing the days of a week to use in weekly schedules.
    static class ScheduleTrigger.TriggerType
              TriggerType is an enumeration representing the possible intervals in which the schedule can run.
     
    Constructor Summary
    ScheduleTrigger()
               
     
    Method Summary
     List<ScheduleTrigger.DayOfWeek> getDaysOfWeek()
              For WEEKLY trigger types, this returns the days of the week that this schedule will execute.
     Date getEndDate()
              Gets the end date and time of the schedule which specifies when the schedule will stop executing.
     int getInterval()
              Gets the interval number for the schedule.
     int getNumOccurrences()
              Gets the number of occurrences for the which the schedule should execute.
     boolean getRepeatForever()
              Gets whether to repeat the schedule indefinitely.
     Date getStartDate()
              Gets the start date and time of the schedule
     String getTimeZone()
              Gets the timeZone for the schedule.
     ScheduleTrigger.TriggerType getTriggerType()
              Gets the trigger type for the schedule.
     void setDaysOfWeek(List<ScheduleTrigger.DayOfWeek> daysOfWeek)
              Sets the days of week.
     void setEndDate(Date endDate)
              Sets the end date and time of the schedule.
     void setInterval(int interval)
              Sets the interval number for the schedule.
     void setNumOccurrences(int numOccurrences)
              Sets the number of occurrences for the which the schedule should execute.
     void setRepeatForever(boolean repeatForever)
              Sets whether to repeat the schedule indefinitely.
     void setStartDate(Date startDate)
              Sets the start date and time of the schedule.
     void setTimeZone(String timeZone)
              Sets the timeZone for the schedule.
     void setTriggerType(ScheduleTrigger.TriggerType triggerType)
              Sets the trigger type for the schedule.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    ScheduleTrigger

    public ScheduleTrigger()
    Method Detail

    getStartDate

    public Date getStartDate()
    Gets the start date and time of the schedule

    Returns:
    Returns the startDate.

    setStartDate

    public void setStartDate(Date startDate)
    Sets the start date and time of the schedule.

    Parameters:
    startDate - The startDate to set.

    getEndDate

    public Date getEndDate()
    Gets the end date and time of the schedule which specifies when the schedule will stop executing.

    Returns:
    Returns the endDate.

    setEndDate

    public void setEndDate(Date endDate)
    Sets the end date and time of the schedule. For recurring schedules, if end date is not null, and the numOccurrences value is greater than 0, the numOccurrences value will be honored first. End date cannot be null if repeatForever is false and numOccurrences is not set or 0.

    Parameters:
    endDate - The endDate to set.

    getRepeatForever

    public boolean getRepeatForever()
    Gets whether to repeat the schedule indefinitely. Default is false. This only applies to recurring TriggerTypes MINUTELY, HOURLY, and DAILY.

    Returns:
    Returns the repeatForever.

    setRepeatForever

    public void setRepeatForever(boolean repeatForever)
    Sets whether to repeat the schedule indefinitely. Default is false. This only applies to recurring TriggerTypes MINUTELY, HOURLY, DAILY, or WEEKLY.

    Parameters:
    repeatForever - The repeatForever to set.

    getInterval

    public int getInterval()
    Gets the interval number for the schedule. For example, if TriggerType is DAILY, and interval is 2, it will run every 2 days.

    Returns:
    Returns the interval.

    setInterval

    public void setInterval(int interval)
    Sets the interval number for the schedule. For example, if TriggerType is DAILY, and interval is 2, it will run every 2 days. The value must be greater than 1 if the recurring TriggerType is MINUTELY, HOURLY, or DAILY.

    Parameters:
    interval - The interval to set.

    getTriggerType

    public ScheduleTrigger.TriggerType getTriggerType()
    Gets the trigger type for the schedule.

    Returns:
    Returns the triggerType.

    setTriggerType

    public void setTriggerType(ScheduleTrigger.TriggerType triggerType)
    Sets the trigger type for the schedule.

    Parameters:
    triggerType - The triggerType to set.

    getNumOccurrences

    public int getNumOccurrences()
    Gets the number of occurrences for the which the schedule should execute. For recurring schedules, if end date is not null, and the numOccurrences value is greater than 0, the numOccurrences value will be honored first.

    Returns:
    Returns the numOccurrences.

    setNumOccurrences

    public void setNumOccurrences(int numOccurrences)
    Sets the number of occurrences for the which the schedule should execute. For recurring schedules, if end date is not null, and the numOccurrences value is greater than 0, the numOccurrences value will be honored first.

    Parameters:
    numOccurrences - The numOccurrences to set.

    getDaysOfWeek

    public List<ScheduleTrigger.DayOfWeek> getDaysOfWeek()
    For WEEKLY trigger types, this returns the days of the week that this schedule will execute.

    Returns:
    Returns the daysOfWeek.

    setDaysOfWeek

    public void setDaysOfWeek(List<ScheduleTrigger.DayOfWeek> daysOfWeek)
    Sets the days of week. This value cannot be null or empty if TriggerType is WEEKLY.

    Parameters:
    daysOfWeek - The daysOfWeek to set.

    getTimeZone

    public String getTimeZone()
    Gets the timeZone for the schedule. Only applies to weekly schedules.

    Returns:
    the timeZone

    setTimeZone

    public void setTimeZone(String timeZone)
    Sets the timeZone for the schedule. Only applies to weekly schedules.

    Parameters:
    timeZone - the timeZone to set


    Copyright (c) 2016, SAS Institute Inc., Cary, NC, USA