Class DurationReminder
- java.lang.Object
-
- org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<E,I>
-
- org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<Reminder,ReminderIdentifier>
-
- org.silverpeas.core.reminder.Reminder
-
- org.silverpeas.core.reminder.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:
- If the property doesn't exist, a
NoSuchPropertyException
is thrown. - If the property isn't a date or a date time, then an
IllegalArgumentException
is thrown.
- Author:
- mmoquillon
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.silverpeas.core.reminder.Reminder
Reminder.ReminderBuilder
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DurationReminder()
Empty constructors for the persistence engine.DurationReminder(ContributionIdentifier contributionId, User user, ReminderProcessName processName)
Constructs a new reminder about the specified contribution and for the given user.DurationReminder(ContributionIdentifier contributionId, ReminderProcessName processName)
Constructs a new reminder about the given contribution for the system.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected OffsetDateTime
computeTriggeringDate()
Computes the date time at which this reminder will be triggered.Reminder
copy()
Copies this reminder to another one.boolean
equals(Object o)
int
getDuration()
Gets the duration before the start date of aPlannableOnCalendar
object this remainder has to be triggered.TimeUnit
getTimeUnit()
Gets the unit of time the duration is expressed.int
hashCode()
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.DurationReminder
withText(String text)
Sets a text with this reminder.-
Methods inherited from class org.silverpeas.core.reminder.Reminder
getByContribution, getByContributionAndUser, getById, getByUser, getContribution, getContributionId, getContributionProperty, getProcessName, getScheduledDateTime, getText, getUserId, isSchedulable, isScheduled, isSystemUser, isTriggered, make, schedule, triggered, unschedule
-
Methods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity
performBeforePersist, performBeforeRemove, performBeforeUpdate
-
Methods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity
getId, getNativeId, isPersisted, setId
-
-
-
-
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 theReminder
abstract one implements a default constructor as it is used to constructs an emptyReminder
instance before setting the attributes. Any concrete reminders should override this method in order to set their specifics attributes.
-
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.
-
getDuration
public int getDuration()
Gets the duration before the start date of aPlannableOnCalendar
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
orZonedDateTime
. 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 inReminder.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 classReminder
- Returns:
- an
OffsetDateTime
value.
-
-