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 inSubmitSubmissionDto
.
- 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
Submission
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
The logger used in this class.protected final SubmissionRepository
<S> The submission repository.protected final TaskRepository
<T> The task repository. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseSubmissionService
(SubmissionRepository<S> submissionRepository, TaskRepository<T> taskRepository) Creates a new instance of classBaseSubmissionService
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract S
Creates a new submission entity.void
Deletes the submission with the specified identifier.enqueue
(@Valid SubmitSubmissionDto<U> submission) Enqueues the submission for evaluation.protected abstract GradingDto
evaluate
(SubmitSubmissionDto<U> dto) Evaluates the submission.execute
(@Valid SubmitSubmissionDto<U> submission, boolean persist) Executes the submission and returns the evaluation results.Returns the evaluation results for the specified submission.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.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.protected SubmissionDto
<U> mapSubmissionToDto
(S submission) Maps the submission to a DTO.protected abstract U
mapSubmissionToSubmissionData
(S submission) Maps the submission to a DTO.
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOGThe logger used in this class. -
submissionRepository
The submission repository. -
taskRepository
The task repository.
-
-
Constructor Details
-
BaseSubmissionService
protected BaseSubmissionService(SubmissionRepository<S> submissionRepository, TaskRepository<T> taskRepository) Creates a new instance of classBaseSubmissionService
.- 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 interfaceSubmissionService<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 interfaceSubmissionService<T extends Task>
- Parameters:
submission
- The submission.persist
- Whether the submission should be stored permanently.- Returns:
- The evaluation results.
-
createSubmissionEntity
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
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 interfaceSubmissionService<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 interfaceSubmissionService<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
Maps the submission to a DTO.- Parameters:
submission
- The submission.- Returns:
- The DTO.
-
mapSubmissionToSubmissionData
Maps the submission to a DTO.- Parameters:
submission
- The submission.- Returns:
- The DTO.
-
delete
Deletes the submission with the specified identifier.- Specified by:
delete
in interfaceSubmissionService<T extends Task>
- Parameters:
id
- The submission identifier.
-