Class VersioningService
java.lang.Object
com.eurodyn.qlack.fuse.acv.service.VersioningService
Provides functionality to persist and retrieve versions of a given entity
object.
- Author:
- European Dynamics SA
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected VersionDTO
convertToVersionDTO
(org.javers.shadow.Shadow shadow) long
createVersion
(@NonNull String author, @NonNull Object obj, String commitMessage) Persists a current state of a given domain object, creating so a createVersion of this object.long
createVersion
(@NonNull String author, @NonNull Object obj, String commitMessage, @NonNull Map<String, String> commitProperties) Persists a current state of a given domain object, creating so a createVersion of this object.findVersions
(@NonNull Object object) Queries for an object's versions.<T> T
retrieveLatestVersion
(T object) Returns the latest version of the requested object.<T> T
retrieveVersion
(T object, long version) Returns a specific version of the requested object.
-
Field Details
-
COMMIT_MESSAGE_KEY
- See Also:
-
-
Constructor Details
-
VersioningService
@Autowired public VersioningService(org.javers.core.Javers javers)
-
-
Method Details
-
createVersion
public long createVersion(@NonNull @NonNull String author, @NonNull @NonNull Object obj, String commitMessage) Persists a current state of a given domain object, creating so a createVersion of this object.- Parameters:
author
- the author who commits the changesobj
- the object to be committedcommitMessage
- a message regarding the commit- Returns:
- the number of the persisted version
-
createVersion
public long createVersion(@NonNull @NonNull String author, @NonNull @NonNull Object obj, String commitMessage, @NonNull @NonNull Map<String, String> commitProperties) Persists a current state of a given domain object, creating so a createVersion of this object.- Parameters:
author
- the author who commits the changesobj
- the object to be committedcommitMessage
- a message regarding the commitcommitProperties
- additional commit properties- Returns:
- the new version number
-
findVersions
Queries for an object's versions.- Parameters:
object
- the object to retrieve versions for- Returns:
- A list of VersionDTO's, ordered in reverse chronological order
-
retrieveVersion
public <T> T retrieveVersion(T object, long version) Returns a specific version of the requested object.
Throws a QDoesNotExistException when the requested version does not exist.- Type Parameters:
T
- the class of the object to retrieve the version for- Parameters:
object
- the object to retrieve the specific versions forversion
- the version to retrieve- Returns:
- the object in the requested version
-
retrieveLatestVersion
public <T> T retrieveLatestVersion(T object) Returns the latest version of the requested object.
Throws a QDoesNotExistException when the requested version does not exist.- Type Parameters:
T
- the class of the object to retrieve the latest version for- Parameters:
object
- the object to retrieve the latest version for- Returns:
- the latest version of the requested object
-
convertToVersionDTO
-