Interface Replacement<T extends Replacement<T>>
-
- All Superinterfaces:
Entity<T,UuidIdentifier>
,IdentifiableEntity
,Serializable
- All Known Implementing Classes:
ReplacementImpl
public interface Replacement<T extends Replacement<T>> extends Entity<T,UuidIdentifier>
A replacement of a user by another one in a given period of time to exercise the responsibilities of the former for all the tasks in which he's implied. A given task could be performed by the substitute if and only if he does already play the role required by the task; in other terms the substitute and the incumbent must plays the same role(s) otherwise the substitute will be unable to exercise the responsibilities of the incumbent.- Author:
- mmoquillon
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Replacement.Constructor
Constructor of a replacement between two users in a given workflow instance and over a given period of time.static interface
Replacement.Repository
Repository storing the replacements and backing the actual used data source of such replacements.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Replacement.Constructor
between(User incumbent, User substitute)
Prepares the construction of a replacement between the two specified users.default void
delete()
Deletes this replacement in the persistence context.static <T extends Replacement<T>>
Optional<T>get(String replacementId)
Gets the replacement with the specified unique identifier.static <T extends Replacement<T>>
ReplacementList<T>getAll(String workflowInstanceId)
Gets all the replacements that are defined in the specified workflow instance.static <T extends Replacement<T>>
ReplacementList<T>getAllBy(User substitute, String workflowInstanceId)
Gets all the replacements exercised by the specified user in the specified workflow instance.static <T extends Replacement<T>>
ReplacementList<T>getAllOf(User incumbent, String workflowInstanceId)
Gets all the replacements of the specified user in the specified workflow instance.static <T extends Replacement<T>>
ReplacementList<T>getAllWith(User incumbent, User substitute, String workflowInstanceId)
Gets all the replacements in which the specified users are implied and that are defined in the specified workflow instance.User
getIncumbent()
Gets the incumbent of responsibilities of tasks that is replaced in a given period of time.Period
getPeriod()
Gets the period in days over which this replacement is enabled.User
getSubstitute()
Gets the substitute of the incumbent to exercise his responsibilities on some tasks.String
getWorkflowInstanceId()
Gets the unique identifier of the instance of the workflow in which this replacement is done.default boolean
isSameAs(Replacement<T> replacement)
Is this replacement same as the specified one?default T
save()
Saves or updates this replacement within the persistence context.Replacement<T>
setPeriod(Period period)
Sets a new period in days over which this replacement will be enabled.Replacement<T>
setSubstitute(User user)
Sets a new substitute to this replacement.-
Methods inherited from interface org.silverpeas.core.persistence.datasource.model.Entity
createdBy, createdBy, getCreationDate, getCreator, getCreatorId, getLastUpdateDate, getLastUpdater, getLastUpdaterId, getVersion, hasBeenModified, markAsModified, updatedBy, updatedBy
-
Methods inherited from interface org.silverpeas.core.persistence.datasource.model.IdentifiableEntity
getId, isPersisted
-
-
-
-
Method Detail
-
get
static <T extends Replacement<T>> Optional<T> get(String replacementId)
Gets the replacement with the specified unique identifier. Each replacement is unique, whatever the workflow in which they were created.- Parameters:
replacementId
- the unique identifier of a replacement.- Returns:
- optionally the replacement with the specified identifier. Nothing if no such replacement exists.
-
getAllOf
static <T extends Replacement<T>> ReplacementList<T> getAllOf(User incumbent, String workflowInstanceId)
Gets all the replacements of the specified user in the specified workflow instance.- Type Parameters:
T
- the class implementing theReplacement
interface.- Parameters:
incumbent
- the user for which the replacements were constructed and persisted.workflowInstanceId
- the unique identifier of a workflow instance.- Returns:
- a list of replacements. If no such replacements exist, then an empty list is returned.
-
getAllBy
static <T extends Replacement<T>> ReplacementList<T> getAllBy(User substitute, String workflowInstanceId)
Gets all the replacements exercised by the specified user in the specified workflow instance.- Type Parameters:
T
- the class implementing theReplacement
interface.- Parameters:
substitute
- the user exercising the replacements.workflowInstanceId
- the unique identifier of a workflow instance.- Returns:
- a list of replacements. If no such replacements exist, then an empty list is returned.
-
getAllWith
static <T extends Replacement<T>> ReplacementList<T> getAllWith(User incumbent, User substitute, String workflowInstanceId)
Gets all the replacements in which the specified users are implied and that are defined in the specified workflow instance.- Type Parameters:
T
- the class implementing theReplacement
interface.- Parameters:
incumbent
- the user to replace.substitute
- the user exercising the replacements.workflowInstanceId
- the unique identifier of a workflow instance.- Returns:
- a list of replacements. If no such replacements exist, then an empty list is returned.
-
getAll
static <T extends Replacement<T>> ReplacementList<T> getAll(String workflowInstanceId)
Gets all the replacements that are defined in the specified workflow instance.- Type Parameters:
T
- the class implementing theReplacement
interface.- Parameters:
workflowInstanceId
- the unique identifier of a workflow instance.- Returns:
- a list of all the replacements in the specified workflow instance. If no replacements exist, then an empty list is returned.
-
between
static Replacement.Constructor between(User incumbent, User substitute)
Prepares the construction of a replacement between the two specified users.- Parameters:
incumbent
- the user that have to be replaced.substitute
- the user that will replace the former.- Returns:
- a constructor of replacements.
-
getIncumbent
User getIncumbent()
Gets the incumbent of responsibilities of tasks that is replaced in a given period of time.- Returns:
- the user that is replaced.
-
getSubstitute
User getSubstitute()
Gets the substitute of the incumbent to exercise his responsibilities on some tasks.- Returns:
- the user to whom this replacement was done.
-
setSubstitute
Replacement<T> setSubstitute(User user)
Sets a new substitute to this replacement.- Parameters:
user
- the user that will replace the incumbent of some tasks- Returns:
- itself.
-
getPeriod
Period getPeriod()
Gets the period in days over which this replacement is enabled. The start and end dates of the period areLocalDate
instances.- Returns:
- a period in days.
-
setPeriod
Replacement<T> setPeriod(Period period)
Sets a new period in days over which this replacement will be enabled. The start date and end date of the period should beLocalDate
instances.- Parameters:
period
- the new period of this replacement.- Returns:
- itself.
-
getWorkflowInstanceId
String getWorkflowInstanceId()
Gets the unique identifier of the instance of the workflow in which this replacement is done.- Returns:
- the unique identifier of a workflow instance.
-
save
default T save()
Saves or updates this replacement within the persistence context. A unique identifier aver all of the workflow instances will be attributed to the newly saved replacement. This identifier can then be used to retrieve later this replacement among its counterparts.- Returns:
- the saved or updated replacement.
-
delete
default void delete()
Deletes this replacement in the persistence context. If the replacement isn't persisted, nothing is done.
-
isSameAs
default boolean isSameAs(Replacement<T> replacement)
Is this replacement same as the specified one?This method differs from equality as they don't compare the same thing: the
equals
method in Java is a comparator by identity, meaning two objects are compared by their unique identifier (either by their OID for non-persistent object or by their persistence identifier for persistent object). TheisSameAs
method is a comparator by value, meaning two objects are compared by their state; so two equal objects (that is referring to a same object) can be different by their state: one representing a given state of the referred object whereas the other represents another state of the referred object.- Parameters:
replacement
- the attendees to compare with.- Returns:
- true if the given replacement is the same has the current one.
-
-