Class BaseTaskGroupService<G extends TaskGroup,S>
java.lang.Object
at.jku.dke.etutor.task_app.services.BaseTaskGroupService<G,S>
- Type Parameters:
G
- The task group type.S
- The type of the additional data used inModifyTaskGroupDto
.
- All Implemented Interfaces:
TaskGroupService<G,
S>
@PreAuthorize("hasAuthority(\'CRUD\')")
public abstract class BaseTaskGroupService<G extends TaskGroup,S>
extends Object
implements TaskGroupService<G,S>
This class provides methods for managing
TaskGroup
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
The logger used in this class.protected final TaskGroupRepository
<G> The task group repository. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseTaskGroupService
(TaskGroupRepository<G> repository) Creates a new instance of classBaseTaskGroupService
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterCreate
(G taskGroup, ModifyTaskGroupDto<S> dto) Called after the task group is stored in the database.protected void
afterDelete
(long id) Called after the task group with the specified identifier is deleted.protected void
afterUpdate
(G taskGroup, ModifyTaskGroupDto<S> dto) Called after the task group is updated in the database.protected void
beforeCreate
(G taskGroup, ModifyTaskGroupDto<S> dto) Called before the task group is stored in the database.protected void
beforeDelete
(long id) Called before the task group with the specified identifier is deleted.create
(long id, @Valid ModifyTaskGroupDto<S> dto) Creates a new task group.protected abstract G
createTaskGroup
(long id, ModifyTaskGroupDto<S> dto) Creates a new task group.void
delete
(long id) Deletes the task group with the specified identifier.get
(long id) Returns the task group with the specified identifier.protected TaskGroupModificationResponseDto
mapToReturnData
(G taskGroup, boolean create) Maps the task group to the data that should be returned to the task administration UI.update
(long id, @Valid ModifyTaskGroupDto<S> dto) Updates an existing task group.protected abstract void
updateTaskGroup
(G taskGroup, ModifyTaskGroupDto<S> dto) Sets the task group type specific attributes of the task group.
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOGThe logger used in this class. -
repository
The task group repository.
-
-
Constructor Details
-
BaseTaskGroupService
Creates a new instance of classBaseTaskGroupService
.- Parameters:
repository
- The task group repository.
-
-
Method Details
-
get
Returns the task group with the specified identifier.- Specified by:
get
in interfaceTaskGroupService<G extends TaskGroup,
S> - Parameters:
id
- The identifier.- Returns:
- The task group or an empty result if the task group does not exist.
-
create
@Transactional public TaskGroupModificationResponseDto create(long id, @Valid @Valid ModifyTaskGroupDto<S> dto) Creates a new task group.- Specified by:
create
in interfaceTaskGroupService<G extends TaskGroup,
S> - Parameters:
id
- The task group identifier.dto
- The task group data.- Returns:
- The data that should be sent to the task administration UI (might be
null
). - Throws:
DuplicateKeyException
- If a task group with the specified identifier already exists.
-
update
@Transactional public TaskGroupModificationResponseDto update(long id, @Valid @Valid ModifyTaskGroupDto<S> dto) Updates an existing task group.- Specified by:
update
in interfaceTaskGroupService<G extends TaskGroup,
S> - Parameters:
id
- The task group identifier.dto
- The new task group data.- Returns:
- The data that should be sent to the task administration UI (might be
null
). - Throws:
jakarta.persistence.EntityNotFoundException
- If the task group does not exist.
-
delete
Deletes the task group with the specified identifier.- Specified by:
delete
in interfaceTaskGroupService<G extends TaskGroup,
S> - Parameters:
id
- The identifier of the task group to delete.
-
createTaskGroup
Creates a new task group.- Parameters:
id
- The task group identifier.dto
- The task group data.- Returns:
- The created task group.
- Implementation Requirements:
- This method SHOULD NOT save the entity to the database as this is done by the caller. This method SHOULD ONLY set the task group type specific attributes of the task group. The other attributes are set by the caller.
-
updateTaskGroup
Sets the task group type specific attributes of the task group.- Parameters:
taskGroup
- task The task group.dto
- The new task group data.
-
mapToReturnData
Maps the task group to the data that should be returned to the task administration UI.- Parameters:
taskGroup
- The task group.create
-true
, if the specified task group was just created;false
if the task group was updated.- Returns:
- The data to send.
-
beforeCreate
Called before the task group is stored in the database.Override this method to perform additional actions before creating the task group.
- Parameters:
taskGroup
- The task group to create.dto
- The new task group data.
-
afterCreate
Called after the task group is stored in the database.This method runs in the same transaction as the calling method. Override this method to perform additional actions after creating the task group.
- Parameters:
taskGroup
- The created task group.dto
- The new task group data.
-
afterUpdate
Called after the task group is updated in the database.This method runs in the same transaction as the calling method. Override this method to perform additional actions after updating the task group.
- Parameters:
taskGroup
- The updated taskGroup.dto
- The new task group data.
-
beforeDelete
protected void beforeDelete(long id) Called before the task group with the specified identifier is deleted.Override this method to perform additional actions before deleting the task group.
- Parameters:
id
- The identifier of the task group to delete.
-
afterDelete
protected void afterDelete(long id) Called after the task group with the specified identifier is deleted.This method runs in the same transaction as the calling method. Override this method to perform additional actions after deleting the task group.
- Parameters:
id
- The identifier of the deleted task group.
-