Class CalendarEventOccurrence
- java.lang.Object
-
- org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<E,I>
-
- org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<CalendarEventOccurrence,ExternalStringIdentifier>
-
- org.silverpeas.core.calendar.CalendarEventOccurrence
-
- All Implemented Interfaces:
Serializable
,Occurrence
,Contribution
,Plannable
,WithPermanentLink
,Instance<Contribution>
,Nameable
,IdentifiableEntity
,WithReminder
,Securable
,SilverpeasResource
@Entity public class CalendarEventOccurrence extends BasicJpaEntity<CalendarEventOccurrence,ExternalStringIdentifier> implements IdentifiableEntity, Occurrence, Contribution, WithReminder, WithPermanentLink
The occurrence of an event in a Silverpeas calendar. It is an instance of an event in the timeline of a calendar; it represents an event starting and ending at a given date or datetime in the calendar.A non-recurrent event is a singleton, meaning that is has only one single instance occurring in the calendar (so the name occurrence). A recurrent event has one or more occurrences in the timeline. It occurs several time in the calendar in a regular way according to its recurrence rule; at each time such an event occurs is represented by an occurrence.
By default, the occurrences of an event aren't persisted, but they are generated from the period of time at which occurs the event and, if any, from its recurrence rule. If an occurrence of a non-recurrent event is deleted, then the related event is deleted. If an occurrence of a recurrent event is deleted, then an exception is added into the recurrence rule of the event. This operation is done with one of the following methods:
delete()
,deleteSinceMe()
. If an occurrence of a non-recurrent event is modified, then the modification is directly applied to the event itself (as it is a singleton). If an occurrence of a recurrent event is modified, then the modification is applied to the occurrence only and this occurrence is persisted as a modification related to the recurrence rule of the concerned event.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<CalendarEventOccurrence>
COMPARATOR_BY_DATE_ASC
static Comparator<CalendarEventOccurrence>
COMPARATOR_BY_DATE_DESC
static Comparator<CalendarEventOccurrence>
COMPARATOR_BY_ORIGINAL_DATE_ASC
static String
TYPE
-
Constructor Summary
Constructors Modifier Constructor Description protected
CalendarEventOccurrence()
Constructor for only persistence context.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CalendarComponent
asCalendarComponent()
Gets theCalendarComponent
representation of this occurrence.boolean
canBeAccessedBy(User user)
Is the specified user can access this contribution?CalendarEvent.EventOperationResult
delete()
Deletes only this occurrence among the occurrences of the event it comes from.CalendarEvent.EventOperationResult
deleteSinceMe()
Deletes this occurrence and all the forthcoming occurrences of the same event.boolean
equals(Object o)
AttendeeSet
getAttendees()
AttributeSet
getAttributes()
Gets the attributes of this event occurrence.static Optional<CalendarEventOccurrence>
getBy(CalendarEvent event, Temporal occurrenceStartDate)
Gets optionally an event occurrence from the specified data.static Optional<CalendarEventOccurrence>
getById(String id)
Gets optionally an event occurrence by its identifier.CalendarEvent
getCalendarEvent()
Gets the event from which this occurrence was spawned.CategorySet
getCategories()
Gets the categories of this event occurrence.Optional<WysiwygContent>
getContent()
Gets the content of this event occurrence.String
getContributionType()
Gets the type of this contribution.Date
getCreationDate()
Gets the date at which the resource has been created.User
getCreator()
Gets the user that has created the resource.String
getDescription()
Gets the description of this event occurrence.Temporal
getEndDate()
The end date or datetime of the occurrence.ContributionIdentifier
getIdentifier()
Gets the unique identifier of this contribution.Date
getLastUpdateDate()
Gets the last date at which this occurrence has been updated.User
getLastUpdater()
Gets the user that has lastly updated the resource.String
getLocation()
Gets the location of this event occurrence.Temporal
getOriginalStartDate()
Gets the original start date of this occurrence.Optional<CalendarEvent>
getParent()
Gets the possible parent object from which the instance could be spawn.Period
getPeriod()
Gets the period of this occurrence in the calendar.String
getPermalink()
Priority
getPriority()
Gets the priority of this event occurrence.<T extends Contribution>
Optional<ResourcePath<T>>getResourcePath()
long
getSequence()
Gets the revision sequence number of this event occurrence within a sequence of revisions.Temporal
getStartDate()
The start date or datetime of the occurrence.String
getTitle()
Gets the title of this event occurrence.VisibilityLevel
getVisibilityLevel()
Gets the level of visibility of this event occurrence.int
hashCode()
boolean
isBefore(CalendarEventOccurrence occurrence)
Is this occurrence actually occurs before the specified occurrence?boolean
isModifiedSince(CalendarEventOccurrence previous)
Is the properties of this event occurrence was modified since its last specified state?boolean
isOnAllDay()
Is this event occurrence occurring on all the day(s)?void
setDay(LocalDate newDay)
Changes the planning of this occurrence in the calendar.void
setDescription(String description)
Sets a new description for this event occurrence.void
setLocation(String location)
Sets a new location for this event occurrence.void
setPeriod(Period newPeriod)
Changes the planning of this occurrence in the calendar.void
setPriority(Priority priority)
Sets a new priority to this event occurrence.void
setTitle(String title)
CalendarEvent.EventOperationResult
update()
Updates only this occurrence among the occurrences of the event it comes from.CalendarEvent.EventOperationResult
updateFrom(CalendarEventOccurrence occurrence)
Updates this occurrence with the state of the specified occurrence.CalendarEvent.EventOperationResult
updateSinceMe()
Updates this occurrence and all the forthcoming occurrences of the same event with the changes in this occurrence.-
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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.contribution.model.Contribution
getModel, getName, isIndexable
-
Methods inherited from interface org.silverpeas.core.persistence.datasource.model.IdentifiableEntity
getId, isPersisted
-
Methods inherited from interface org.silverpeas.core.calendar.Occurrence
getId
-
Methods inherited from interface org.silverpeas.core.security.Securable
canBeDeletedBy, canBeFiledInBy, canBeModifiedBy
-
-
-
-
Field Detail
-
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
-
COMPARATOR_BY_ORIGINAL_DATE_ASC
public static final Comparator<CalendarEventOccurrence> COMPARATOR_BY_ORIGINAL_DATE_ASC
-
COMPARATOR_BY_DATE_ASC
public static final Comparator<CalendarEventOccurrence> COMPARATOR_BY_DATE_ASC
-
COMPARATOR_BY_DATE_DESC
public static final Comparator<CalendarEventOccurrence> COMPARATOR_BY_DATE_DESC
-
-
Method Detail
-
getBy
public static Optional<CalendarEventOccurrence> getBy(CalendarEvent event, Temporal occurrenceStartDate)
Gets optionally an event occurrence from the specified data.- Parameters:
event
- an event.occurrenceStartDate
- a start date.- Returns:
- the computed occurrence identifier.
-
getById
public static Optional<CalendarEventOccurrence> getById(String id)
Gets optionally an event occurrence by its identifier.If the occurrence exists into the persistence, it is returned. Otherwise, it is generated.
Otherwise and if start date is valid, the occurrence is generated.
- Parameters:
id
- the identifier of the aimed occurrence.- Returns:
- an optional calendar event occurrence.
-
getParent
public Optional<CalendarEvent> getParent()
Description copied from interface:Instance
Gets the possible parent object from which the instance could be spawn.- Specified by:
getParent
in interfaceInstance<Contribution>
- Returns:
- an optional parent instance of type U.
-
getIdentifier
public ContributionIdentifier getIdentifier()
Description copied from interface:Contribution
Gets the unique identifier of this contribution.- Specified by:
getIdentifier
in interfaceContribution
- Specified by:
getIdentifier
in interfaceSilverpeasResource
- Returns:
- the unique identifier of the contribution.
-
getCreator
public User getCreator()
Description copied from interface:SilverpeasResource
Gets the user that has created the resource.- Specified by:
getCreator
in interfaceSilverpeasResource
- Returns:
- a
User
in Silverpeas.
-
getCreationDate
public Date getCreationDate()
Description copied from interface:SilverpeasResource
Gets the date at which the resource has been created.- Specified by:
getCreationDate
in interfaceSilverpeasResource
- Returns:
- the date of creation of the resource.
-
getLastUpdater
public User getLastUpdater()
Description copied from interface:SilverpeasResource
Gets the user that has lastly updated the resource. If the resource doesn't have such an information, then this method should return the user that has created the resource.- Specified by:
getLastUpdater
in interfaceSilverpeasResource
- Returns:
- a
User
in Silverpeas.
-
canBeAccessedBy
public boolean canBeAccessedBy(User user)
Description copied from interface:Contribution
Is the specified user can access this contribution?By default
Securable.canBeAccessedBy(User)
is implemented so that a user can access a contribution if it has enough rights to access the application instance in which is managed this contribution.
Indeed, this behavior is mostly the common one.
But In the case the application instance distributes its contribution along of a categorization tree and the nodes of this tree support access rights, then the user must have also the rights to access the node to which belongs the content.
Of course it could exist other access rules...- Specified by:
canBeAccessedBy
in interfaceContribution
- Specified by:
canBeAccessedBy
in interfaceSecurable
- Parameters:
user
- a user in Silverpeas.- Returns:
- true if the user can access this content, false otherwise.
-
getContributionType
public String getContributionType()
Description copied from interface:Contribution
Gets the type of this contribution. The type is a label that identifies uniquely a kind of contribution handled by a Silverpeas application. By default, this method returns the simple name of the class implementing this interface.- Specified by:
getContributionType
in interfaceContribution
- Returns:
- the label of the type of this contribution.
-
getCalendarEvent
public CalendarEvent getCalendarEvent()
Gets the event from which this occurrence was spawned.From the returned event, the title, the description or any other event properties can be modified. Nevertheless, the change can be effective only by invoking the
update
method of either theCalendarEvent
to apply the modifications to all occurrences or this occurrence to apply the modifications only to this occurrence. Only the period at which the event occur in the calendar cannot be used to update this occurrence. For doing, please use either thesetPeriod
or thesetDay
method ofCalendarEventOccurrence
.- Returns:
- the event from which this occurrence is instantiated.
-
getStartDate
public Temporal getStartDate()
Description copied from interface:Occurrence
The start date or datetime of the occurrence. It is the inclusive lower bound of the period into which this occurrence occurs in a calendar. If this occurrence is on all days, then gets a date. Otherwise, gets a datetime in UTC/Greenwich. on the timeline.- Specified by:
getStartDate
in interfaceOccurrence
- Returns:
- a temporal instance of
LocalDate
if the occurrence takes all the day or a temporal instance ofOffsetDateTime
in UTC/Greenwich otherwise.
-
getEndDate
public Temporal getEndDate()
Description copied from interface:Occurrence
The end date or datetime of the occurrence. It is the exclusive upper bound of the period into which this occurrence occurs in a calendar. If this occurrence is on all days, then gets a date. Otherwise, gets a datetime in UTC/Greenwich.- Specified by:
getEndDate
in interfaceOccurrence
- Returns:
- a temporal instance of
LocalDate
if the occurrence takes all the day or a temporal instance ofOffsetDateTime
in UTC/Greenwich otherwise.
-
getResourcePath
public <T extends Contribution> Optional<ResourcePath<T>> getResourcePath()
Description copied from interface:Contribution
Gets the
of the contribution represented by the given identifier.Returns empty by default if not implemented.
- Specified by:
getResourcePath
in interfaceContribution
- Type Parameters:
T
- the type the contribution.- Returns:
- the optional
ResourcePath
instance.
-
getOriginalStartDate
public Temporal getOriginalStartDate()
Gets the original start date of this occurrence. If the start date wasn't modified, then the returning date should be the same as the start date returned by the methodgetStartDate()
.- Returns:
- the original start date of this occurrence of calendar event.
-
setPeriod
public void setPeriod(Period newPeriod)
Changes the planning of this occurrence in the calendar. The change will be effectively performed once theupdate
method invoked.
-
getPeriod
public Period getPeriod()
Gets the period of this occurrence in the calendar.
-
setDay
public void setDay(LocalDate newDay)
Changes the planning of this occurrence in the calendar. The change will be effectively performed once theupdate
method invoked.- Parameters:
newDay
- the new day at which this occurrence will occur or has actually occurred.
-
getTitle
public String getTitle()
Gets the title of this event occurrence. The title is either the one of the related event or the one that was modified for this occurrence.- Specified by:
getTitle
in interfaceContribution
- Returns:
- the title of the event occurrence.
-
setTitle
public void setTitle(String title)
-
getAttendees
public AttendeeSet getAttendees()
-
getDescription
public String getDescription()
Gets the description of this event occurrence. The description is either the one of the related event or the one that was modified for this occurrence.- Specified by:
getDescription
in interfaceContribution
- Specified by:
getDescription
in interfaceNameable
- Returns:
- the description of the event occurrence.
-
setDescription
public void setDescription(String description)
Sets a new description for this event occurrence.- Parameters:
description
- a new description related to this event occurrence.
-
getLocation
public String getLocation()
Gets the location of this event occurrence. The location is either the one of the related event or the one that was modified for this occurrence.- Returns:
- the location of the event occurrence.
-
setLocation
public void setLocation(String location)
Sets a new location for this event occurrence.- Parameters:
location
- the new location where this occurrence should take place.
-
getAttributes
public AttributeSet getAttributes()
Gets the attributes of this event occurrence. The attributes are either those related to the event or those that were modified for this occurrence.- Returns:
- the extra attributes of the event occurrence.
-
getPriority
public Priority getPriority()
Gets the priority of this event occurrence. The priority is the one that is set for the event.- Returns:
- the priority of the event occurrence.
-
setPriority
public void setPriority(Priority priority)
Sets a new priority to this event occurrence.- Parameters:
priority
- the new priority of this event occurrence.
-
getCategories
public CategorySet getCategories()
Gets the categories of this event occurrence. The categories are those that are set for the event.- Returns:
- the categories of the event occurrence.
-
getVisibilityLevel
public VisibilityLevel getVisibilityLevel()
Gets the level of visibility of this event occurrence. The visibility level is the one that is set for the event.- Returns:
- the level of visibility of the event occurrence.
-
isOnAllDay
public boolean isOnAllDay()
Is this event occurrence occurring on all the day(s)?- Returns:
- true if this event occurrence is occurring on all its day(s).
-
getSequence
public long getSequence()
Gets the revision sequence number of this event occurrence within a sequence of revisions. Any changes to some properties of this event occurrence increment this sequence number. This number is mainly dedicated with the synchronization or syndication mechanism of event instances with external calendars. Its meaning comes from the icalendar specification.- Returns:
- the sequence number of this event occurrence.
- See Also:
CalendarComponent.getSequence()
-
getLastUpdateDate
public Date getLastUpdateDate()
Gets the last date at which this occurrence has been updated.- Specified by:
getLastUpdateDate
in interfaceSilverpeasResource
- Returns:
- the last update date.
-
getContent
public Optional<WysiwygContent> getContent()
Gets the content of this event occurrence. The content is the one of the event, and it cannot be modified per occurrence but for the whole event occurrence(s).- Returns:
- optionally the content of the event.
-
getPermalink
public String getPermalink()
- Specified by:
getPermalink
in interfaceWithPermanentLink
-
isBefore
public boolean isBefore(CalendarEventOccurrence occurrence)
Is this occurrence actually occurs before the specified occurrence?- Parameters:
occurrence
- another occurrence with which the start date is compared.- Returns:
- true if this occurrence starts before the specified another one. False otherwise.
-
asCalendarComponent
public CalendarComponent asCalendarComponent()
Gets theCalendarComponent
representation of this occurrence. Any change to the returned calendar component will change also the related occurrence.- Returns:
- a
CalendarComponent
instance representing this event occurrence (without the specific properties related to an event occurrence).
-
updateSinceMe
public CalendarEvent.EventOperationResult updateSinceMe()
Updates this occurrence and all the forthcoming occurrences of the same event with the changes in this occurrence.If the event is non-recurrent, then the event is itself updated. Otherwise, a new event is created for this occurrence and for all the forthcoming occurrences with the modifications carried by this occurrence. The recurrence of the original event is updated to end up at this occurrence minus one day (the recurrence end date is inclusive).
In the case the temporal period of the occurrences is modified, the participation status of all the attendees in the occurrences is cleared.
This is equivalent to
EventOperationResult result = event.updateSince(this)
- Returns:
- the result of the update.
- See Also:
CalendarEvent.updateSince(CalendarEventOccurrence)
-
update
public CalendarEvent.EventOperationResult update()
Updates only this occurrence among the occurrences of the event it comes from.If the event is non-recurrent, then the event is itself updated. Otherwise, the changes in this occurrence are persisted and its sequence number is incremented by one, diverging then from the sequence number of the event it comes from.
In the case the temporal period of the occurrence is modified, the participation status of all the attendees in this occurrence is cleared.
This is equivalent to
EventOperationResult result = event.updateOnly(this)
- Returns:
- the result of the update.
- See Also:
CalendarEvent.updateOnly(CalendarEventOccurrence)
-
updateFrom
public CalendarEvent.EventOperationResult updateFrom(CalendarEventOccurrence occurrence)
Updates this occurrence with the state of the specified occurrence.- Parameters:
occurrence
- an event occurrence from which this occurrence will be updated.- Returns:
- the result of the update.
-
deleteSinceMe
public CalendarEvent.EventOperationResult deleteSinceMe()
Deletes this occurrence and all the forthcoming occurrences of the same event.If the event is non-recurrent, then the event is itself deleted. Otherwise, the original starting date of this occurrence and of all the forthcoming occurrences are added in the exception dates of the event's recurrence rule. If some occurrences were persisted, then they are all removed from the persistence context.
This is equivalent to
EventOperationResult result = event.deleteSince(this)
- Returns:
- the result of the deletion.
- See Also:
CalendarEvent.deleteSince(CalendarEventOccurrence)
-
delete
public CalendarEvent.EventOperationResult delete()
Deletes only this occurrence among the occurrences of the event it comes from.If the event is non-recurrent, then the event is itself deleted. Otherwise, the original starting date of this occurrence is added in the exception dates of the event's recurrence rule. If the occurrence was previously persisted, then it is removed from the persistence context.
This is equivalent to
EventOperationResult result = event.deleteOnly(this)
- Returns:
- the result of the deletion.
- See Also:
CalendarEvent.deleteOnly(CalendarEventOccurrence)
-
isModifiedSince
public boolean isModifiedSince(CalendarEventOccurrence previous)
Is the properties of this event occurrence was modified since its last specified state? The attendees in this event occurrence aren't taken into account as they aren't considered as a property of an event occurrence.- Parameters:
previous
- a previous state of this event occurrence.- Returns:
- true if the state of this event occurrence is different with the specified one.
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classAbstractJpaEntity<CalendarEventOccurrence,ExternalStringIdentifier>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractJpaEntity<CalendarEventOccurrence,ExternalStringIdentifier>
-
-