org.silverpeas.persistence.model
Class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>

java.lang.Object
  extended by org.silverpeas.persistence.model.AbstractEntity<ENTITY,IDENTIFIER_TYPE>
Type Parameters:
ENTITY - specify the class name of the entity itself which is handled by a repository manager.
IDENTIFIER_TYPE - the identifier class name used by ENTITY for its primary key definition.
All Implemented Interfaces:
Serializable, Cloneable, Entity<ENTITY,IDENTIFIER_TYPE>
Direct Known Subclasses:
AbstractJpaEntity

public abstract class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
extends Object
implements Cloneable, Entity<ENTITY,IDENTIFIER_TYPE>

This abstract class must be extended by all Silverpeas entity definitions that have to be persisted.

The entity extensions must handle performBeforePersist() and performBeforeUpdate() methods.

Author:
Yohann Chastagnier
See Also:
Serialized Form

Constructor Summary
AbstractEntity()
           
 
Method Summary
 ENTITY clone()
           
 boolean equals(Object obj)
           
 String getComponentInstanceId()
          By default, if not implemented by child classes, an exception is thrown.
 UserDetail getCreator()
          Gets the user which has created the entity (in the persistence environment).
 UserDetail getLastUpdater()
          Gets the last user which has updated the entity (in the persistence environment).
 boolean hasBeenModified()
          Indicates if the entity has been modified at least one time.
 int hashCode()
           
 boolean isPersisted()
          Indicates if the entity is persisted (commonly if the entity has an id)
protected  void performBeforePersist()
          This method contains all (technical) informations that must be performed on a entity create.
protected  void performBeforeUpdate()
          This method contains all (technical) informations that must be performed on a entity update.
protected abstract  ENTITY setCreateDate(Date createDate)
           
abstract  ENTITY setCreatedBy(String createdBy)
           
 ENTITY setCreator(UserDetail creator)
          Sets the user which has created the entity (in the persistence environment).
protected abstract  ENTITY setId(String id)
          Sets the id of the entity.
protected abstract  ENTITY setLastUpdateDate(Date lastUpdateDate)
           
abstract  ENTITY setLastUpdatedBy(String lastUpdatedBy)
           
 ENTITY setLastUpdater(UserDetail updater)
          Sets the last user which has updated the entity (in the persistence environment).
protected abstract  ENTITY setVersion(Long version)
          Sets the version of the entity.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.silverpeas.persistence.model.Entity
getCreateDate, getCreatedBy, getId, getLastUpdateDate, getLastUpdatedBy, getVersion, markAsModified
 

Constructor Detail

AbstractEntity

public AbstractEntity()
Method Detail

setId

protected abstract ENTITY setId(String id)
Sets the id of the entity.

Parameters:
id - the new id of the entity.
Returns:
the entity instance.

getComponentInstanceId

public String getComponentInstanceId()
By default, if not implemented by child classes, an exception is thrown.

Specified by:
getComponentInstanceId in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:
the identifier of the component instance which the entity is attached.

setVersion

protected abstract ENTITY setVersion(Long version)
Sets the version of the entity.

Parameters:
version -
Returns:

performBeforePersist

protected void performBeforePersist()
This method contains all (technical) informations that must be performed on a entity create.


performBeforeUpdate

protected void performBeforeUpdate()
This method contains all (technical) informations that must be performed on a entity update.


setCreatedBy

public abstract ENTITY setCreatedBy(String createdBy)

setCreateDate

protected abstract ENTITY setCreateDate(Date createDate)

setLastUpdatedBy

public abstract ENTITY setLastUpdatedBy(String lastUpdatedBy)

setLastUpdateDate

protected abstract ENTITY setLastUpdateDate(Date lastUpdateDate)

getCreator

public UserDetail getCreator()
Description copied from interface: Entity
Gets the user which has created the entity (in the persistence environment). (if "created by" is a known user id)

Specified by:
getCreator in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:

setCreator

public ENTITY setCreator(UserDetail creator)
Description copied from interface: Entity
Sets the user which has created the entity (in the persistence environment).

Specified by:
setCreator in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:

getLastUpdater

public UserDetail getLastUpdater()
Description copied from interface: Entity
Gets the last user which has updated the entity (in the persistence environment). (if "last updated by" is a known user id)

Specified by:
getLastUpdater in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:

setLastUpdater

public ENTITY setLastUpdater(UserDetail updater)
Description copied from interface: Entity
Sets the last user which has updated the entity (in the persistence environment).

Specified by:
setLastUpdater in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:

isPersisted

public boolean isPersisted()
Description copied from interface: Entity
Indicates if the entity is persisted (commonly if the entity has an id)

Specified by:
isPersisted in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:

hasBeenModified

public boolean hasBeenModified()
Description copied from interface: Entity
Indicates if the entity has been modified at least one time.

Specified by:
hasBeenModified in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE>
Returns:

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

clone

public ENTITY clone()
Overrides:
clone in class Object


Copyright © 2016 Silverpeas. All Rights Reserved.