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 in ModifyTaskGroupDto.
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 TaskGroups.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      The logger used in this class.
    • repository

      protected final TaskGroupRepository<G extends TaskGroup> repository
      The task group repository.
  • Constructor Details

  • Method Details

    • get

      @Transactional(readOnly=true) public Optional<G> get(long id)
      Returns the task group with the specified identifier.
      Specified by:
      get in interface TaskGroupService<G extends TaskGroup,S>
      Parameters:
      id - The identifier.
      Returns:
      The task group or an empty result if the task group does not exist.
    • create

      Creates a new task group.
      Specified by:
      create in interface TaskGroupService<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

      Updates an existing task group.
      Specified by:
      update in interface TaskGroupService<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

      @Transactional public void delete(long id)
      Deletes the task group with the specified identifier.
      Specified by:
      delete in interface TaskGroupService<G extends TaskGroup,S>
      Parameters:
      id - The identifier of the task group to delete.
    • createTaskGroup

      protected abstract G createTaskGroup(long id, ModifyTaskGroupDto<S> dto)
      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

      protected abstract void updateTaskGroup(G taskGroup, ModifyTaskGroupDto<S> dto)
      Sets the task group type specific attributes of the task group.
      Parameters:
      taskGroup - task The task group.
      dto - The new task group data.
    • mapToReturnData

      protected TaskGroupModificationResponseDto mapToReturnData(G taskGroup, boolean create)
      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

      protected void beforeCreate(G taskGroup, ModifyTaskGroupDto<S> dto)
      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

      protected void afterCreate(G taskGroup, ModifyTaskGroupDto<S> dto)
      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

      protected void afterUpdate(G taskGroup, ModifyTaskGroupDto<S> dto)
      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.