Class BaseSubmissionService<T extends Task,S extends Submission<T>,U>

java.lang.Object
at.jku.dke.etutor.task_app.services.BaseSubmissionService<T,S,U>
Type Parameters:
T - The task type.
S - The submission type.
U - The type of the submission input used in SubmitSubmissionDto.
All Implemented Interfaces:
SubmissionService<U>

public abstract class BaseSubmissionService<T extends Task,S extends Submission<T>,U> extends Object implements SubmissionService<U>
This class provides methods for managing Submissions.
  • Field Details

    • LOG

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

      protected final SubmissionRepository<S extends Submission<T>> submissionRepository
      The submission repository.
    • taskRepository

      protected final TaskRepository<T extends Task> taskRepository
      The task repository.
  • Constructor Details

    • BaseSubmissionService

      protected BaseSubmissionService(SubmissionRepository<S> submissionRepository, TaskRepository<T> taskRepository)
      Creates a new instance of class BaseSubmissionService.
      Parameters:
      submissionRepository - The submission repository.
      taskRepository - The task repository.
  • Method Details

    • enqueue

      @PreAuthorize("hasAuthority(\'SUBMIT\')") public UUID enqueue(@Valid @Valid SubmitSubmissionDto<U> submission)
      Enqueues the submission for evaluation.
      Specified by:
      enqueue in interface SubmissionService<T extends Task>
      Parameters:
      submission - The submission.
      Returns:
      The submission identifier.
    • execute

      @PreAuthorize("hasAuthority(\'SUBMIT\')") public GradingResultDto execute(@Valid @Valid SubmitSubmissionDto<U> submission, boolean persist)
      Executes the submission and returns the evaluation results.
      Specified by:
      execute in interface SubmissionService<T extends Task>
      Parameters:
      submission - The submission.
      persist - Whether the submission should be stored permanently.
      Returns:
      The evaluation results.
    • createSubmissionEntity

      protected abstract S createSubmissionEntity(SubmitSubmissionDto<U> dto)
      Creates a new submission entity.
      Parameters:
      dto - The submission data.
      Returns:
      The created submission.
      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 type specific submission attributes. The other attributes are set by the caller.
    • evaluate

      protected abstract GradingDto evaluate(SubmitSubmissionDto<U> dto)
      Evaluates the submission.
      Parameters:
      dto - The submission data transfer object.
      Returns:
      The evaluation results.
    • getEvaluationResult

      @Transactional(readOnly=true) @PreAuthorize("hasAuthority(\'SUBMIT\')") public GradingDto getEvaluationResult(UUID id)
      Returns the evaluation results for the specified submission.
      Specified by:
      getEvaluationResult in interface SubmissionService<T extends Task>
      Parameters:
      id - The submission identifier.
      Returns:
      The evaluation results or null if the result is not available.
      Throws:
      jakarta.persistence.EntityNotFoundException - If the submission does not exist.
    • getSubmissions

      @Transactional(readOnly=true) @PreAuthorize("hasAuthority(\'READ_SUBMISSION\')") public org.springframework.data.domain.Page<SubmissionDto<U>> getSubmissions(org.springframework.data.domain.Pageable page, String userFilter, Long taskFilter, String assignmentFilter, SubmissionMode modeFilter)
      Returns all submissions for the requested page.
      Specified by:
      getSubmissions in interface SubmissionService<T extends Task>
      Parameters:
      page - The page and sorting information.
      userFilter - Optional user filter string (applies equals to userId attribute).
      taskFilter - Optional task filter string (applies equals to taskId attribute).
      assignmentFilter - Optional assignment filter string (applies equals to assignmentId attribute).
      modeFilter - Optional mode filter (applies equals to mode attribute).
      Returns:
      List of submissions
    • getFilterSpecification

      protected org.springframework.data.jpa.domain.Specification<S> getFilterSpecification(String userFilter, Long taskFilter, String assignmentFilter, SubmissionMode modeFilter)
      Returns the filter specification for the given filter parameters.
      Parameters:
      userFilter - The user filter.
      taskFilter - The task filter.
      assignmentFilter - The assignment filter.
      modeFilter - The mode filter.
      Returns:
      The filter specification.
    • mapSubmissionToDto

      protected SubmissionDto<U> mapSubmissionToDto(S submission)
      Maps the submission to a DTO.
      Parameters:
      submission - The submission.
      Returns:
      The DTO.
    • mapSubmissionToSubmissionData

      protected abstract U mapSubmissionToSubmissionData(S submission)
      Maps the submission to a DTO.
      Parameters:
      submission - The submission.
      Returns:
      The DTO.
    • delete

      @Transactional @PreAuthorize("hasAuthority(\'SUBMIT\')") public void delete(UUID id)
      Deletes the submission with the specified identifier.
      Specified by:
      delete in interface SubmissionService<T extends Task>
      Parameters:
      id - The submission identifier.