Interface Entity<E extends Entity<E,I>,I extends EntityIdentifier>
-
- Type Parameters:
E
- specify the class name of the entity itself which is handled by a repository manager.I
- the identifier class name used byEntity
for its primary key definition.
- All Superinterfaces:
IdentifiableEntity
,Serializable
- All Known Subinterfaces:
Replacement<T>
- All Known Implementing Classes:
Attendee
,Calendar
,CalendarComponent
,ExternalAttendee
,InternalAttendee
,PersistentResourceDateReminder
,ReplacementImpl
,SilverpeasJpaEntity
,Variable
,VariableScheduledValue
public interface Entity<E extends Entity<E,I>,I extends EntityIdentifier> extends IdentifiableEntity
An entity is an object managed or handled by Silverpeas and that can be persisted into a data source. This interface must be implemented by all Silverpeas entity definitions that have to be persisted. It provides signatures for the following technical data :- entity identifier
- entity "created by" (a free string)
- entity user creator (if "created by" is a known user id)
- entity create date
- entity "last updated by" (a free string)
- entity last user updater (if "last updated by" is a known user id)
- entity last update date
- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description E
createdBy(User creator)
Sets explicitly the user who has created the entity (in the persistence context).E
createdBy(User creator, Date creationDate)
sets the user who has created the entity (in the persistence environment) with the date of the creation.Date
getCreationDate()
Gets the date of the entity creation (in the persistence environment).User
getCreator()
Gets the user which has created the entity (in the persistence environment).String
getCreatorId()
Gets unique identifier of the user that has created this entity.Date
getLastUpdateDate()
Gets the last date and time of the entity update (in the persistence context).User
getLastUpdater()
Gets the last user which has updated the entity (in the persistence context).String
getLastUpdaterId()
Gets the unique identifier of the last updater of this entity.Long
getVersion()
Gets the version of the entity (in the persistence context).boolean
hasBeenModified()
Indicates if the entity has been modified at least one time.void
markAsModified()
By default, if no functional data is changed, last update date, last updated by and version technical data are not automatically updated on entity save operation.E
updatedBy(User updater)
Sets explicitly the last user who has updated the entity (in the persistence context).E
updatedBy(User updater, Date updateDate)
sets the user who has updated the entity (in the persistence context) with the date of the update.-
Methods inherited from interface org.silverpeas.core.persistence.datasource.model.IdentifiableEntity
getId, isPersisted
-
-
-
-
Method Detail
-
getCreationDate
Date getCreationDate()
Gets the date of the entity creation (in the persistence environment).- Returns:
- the date at which this entity was created.
-
getCreatorId
String getCreatorId()
Gets unique identifier of the user that has created this entity.- Returns:
- the unique identifier of the creator.
-
getCreator
User getCreator()
Gets the user which has created the entity (in the persistence environment). (if "created by" is a known user id)- Returns:
- the creator.
-
createdBy
E createdBy(User creator)
Sets explicitly the user who has created the entity (in the persistence context). The creation date will be set at now.The Silverpeas persistence system sets automatically the creator from the operation context in the current thread and it sets automatically the creation date at the date the entity is persisted. By using this method, you overrides this behaviour.
- Parameters:
creator
- the creator of this entity.- Returns:
- itself.
-
createdBy
E createdBy(User creator, Date creationDate)
sets the user who has created the entity (in the persistence environment) with the date of the creation.The Silverpeas persistence system sets automatically the creator from the operation context in the current thread and it sets automatically the creation date at the date the entity is persisted. By using this method, you overrides this behaviour.
- Parameters:
creator
- the creator of this entity.creationDate
- the date at which the entity is created.- Returns:
- itself.
-
getLastUpdateDate
Date getLastUpdateDate()
Gets the last date and time of the entity update (in the persistence context). If the entity wasn't yet updated since its inception, then the creation date is returned.- Returns:
- the last date at which this entity was updated.
-
getLastUpdaterId
String getLastUpdaterId()
Gets the unique identifier of the last updater of this entity.- Returns:
- the unique identifier of the last updater.
-
getLastUpdater
User getLastUpdater()
Gets the last user which has updated the entity (in the persistence context). If the entity hasn't yet been updated since its inception, then the creator is considered the last user that touched the entity and hence it is returned.- Returns:
- the last updater.
-
updatedBy
E updatedBy(User updater)
Sets explicitly the last user who has updated the entity (in the persistence context). The last update date will be set at now.The Silverpeas persistence system sets automatically the updater from the operation context in the current thread and it sets automatically the update date at the date the entity is updated in the persistence context. By using this method, you overrides this behaviour.
- Parameters:
updater
- the last updater to set.- Returns:
- itself.
-
updatedBy
E updatedBy(User updater, Date updateDate)
sets the user who has updated the entity (in the persistence context) with the date of the update.The Silverpeas persistence system sets automatically the updater from the operation context in the current thread and it sets automatically the update date at the date the entity is updated in the persistence cotnext. By using this method, you overrides this behaviour.
- Parameters:
updater
- the user who updates this entity.updateDate
- the date at which the entity is updated.- Returns:
- itself.
-
getVersion
Long getVersion()
Gets the version of the entity (in the persistence context).- Returns:
- the version of this entity.
-
hasBeenModified
boolean hasBeenModified()
Indicates if the entity has been modified at least one time.- Returns:
- true if this entity was modified since its first fetching from the database. False otherwise.
-
markAsModified
void markAsModified()
By default, if no functional data is changed, last update date, last updated by and version technical data are not automatically updated on entity save operation. But in some cases, it could be useful that this three above technical data are updated, even if functional data are not changed. So, calling this method ensures that last update date, last updated by and version will be updated.
-
-