Class DurationReminder

  • All Implemented Interfaces:
    Serializable, IdentifiableEntity

    @Entity
    public class DurationReminder
    extends Reminder

    A reminder to be triggered at a specified duration before the temporal value of the specified property of the related contribution. This reminder uses the ContributionModel instance representing the contribution to get the value of the property. This type of reminder has the specific capability to be automatically rescheduled at each triggering just by asking to the contribution a new temporal value for its property - if the returned value is null or isn't in the future (with the triggering duration taken into account), then the reminder isn't rescheduled.

    Contribution's properties accepting a temporal parameter can be used. This is for contributions that require to have a temporal reference from which a new temporal value for their property is computed. For such properties, the reminder passes the datetime of now plus the given duration.

    Some specific exceptions are thrown when the reminder is scheduled:

    Author:
    mmoquillon
    See Also:
    Serialized Form
    • Constructor Detail

      • DurationReminder

        public DurationReminder​(ContributionIdentifier contributionId,
                                ReminderProcessName processName)
        Constructs a new reminder about the given contribution for the system.
        Parameters:
        contributionId - the unique identifier of a contribution.
        processName - the name of the process the reminder MUST perform when triggered.
      • DurationReminder

        public DurationReminder​(ContributionIdentifier contributionId,
                                User user,
                                ReminderProcessName processName)
        Constructs a new reminder about the specified contribution and for the given user.
        Parameters:
        contributionId - the unique identifier of the contribution.
        user - the user aimed by this reminder.
        processName - the name of the process the reminder MUST perform when triggered.
      • DurationReminder

        protected DurationReminder()
        Empty constructors for the persistence engine.
    • Method Detail

      • copy

        public Reminder copy()
        Description copied from class: Reminder
        Copies this reminder to another one. This method expects the concrete class extending the Reminder abstract one implements a default constructor as it is used to constructs an empty Reminder instance before setting the attributes. Any concrete reminders should override this method in order to set their specifics attributes.
        Overrides:
        copy in class Reminder
        Returns:
        a copy of this reminder.
      • withText

        public final DurationReminder withText​(String text)
        Description copied from class: Reminder
        Sets a text with this reminder. The text will be sent with the notification to the user.
        Overrides:
        withText in class Reminder
        Parameters:
        text - a text to attach with the reminder.
        Returns:
        itself.
      • getDuration

        public int getDuration()
        Gets the duration before the start date of a PlannableOnCalendar object this remainder has to be triggered.
        Returns:
        a duration value.
      • getTimeUnit

        public TimeUnit getTimeUnit()
        Gets the unit of time the duration is expressed.
        Returns:
        a time unit value.
      • triggerBefore

        public DurationReminder triggerBefore​(int duration,
                                              TimeUnit timeUnit,
                                              String temporalProperty)

        Triggers this reminder at the specified duration before the temporal value of the specified property of the related contribution. The property can accept a parameter whose the type must be either Temporal or ZonedDateTime. For such property, the reminder will pass as parameter the datetime of now plus de specified duration.

        Such a property can be for example the visibility end date of a publication or the start date of an event or the start date of one given occurrence of a recurrent event (in that case, the temporal value passed as parameter can be used to select the concerned occurrence).

        Parameters:
        duration - the duration value prior to the temporal property of the contribution.
        timeUnit - the time unit in which is expressed the duration.
        temporalProperty - the temporal property of the contribution.
        Returns:
        itself.
      • computeTriggeringDate

        protected OffsetDateTime computeTriggeringDate()
        Description copied from class: Reminder
        Computes the date time at which this reminder will be triggered. This method is invoked in Reminder.schedule() in order to plan the trigger of this reminder in the timeline. The triggering datetime is computed from the triggering rule that is specific to the concrete type of this reminder. The timezone of the returned triggering date has to be set with the timezone of the user behind the reminder.
        Overrides:
        computeTriggeringDate in class Reminder
        Returns:
        an OffsetDateTime value.