Package dev.dokimos.server.service
Class AnnotationService
java.lang.Object
dev.dokimos.server.service.AnnotationService
Service for human review annotations on run item results. Each item result holds at most one
annotation;
upsert(java.util.UUID, java.util.UUID, dev.dokimos.server.dto.v1.AnnotationRequest, java.lang.String, dev.dokimos.server.tenant.TenantScope) creates it on first call and updates the same row thereafter.
The run-membership gate is tenant-scoped. requireItemResultInRun(java.util.UUID, java.util.UUID, dev.dokimos.server.tenant.TenantScope) loads the run through the
scoped run finder rather than trusting the URL runId, so a tenant cannot annotate another
tenant's item by presenting a (foreign-run, foreign-item) pair: the foreign run is invisible and the
gate returns a 404.
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationService(AnnotationRepository annotationRepository, ItemResultRepository itemResultRepository, ExperimentRunRepository runRepository) -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(UUID runId, UUID itemResultId, TenantScope scope) Removes the annotation for the given run item result if one exists.get(UUID runId, UUID itemResultId, TenantScope scope) Returns the annotation for the given run item result, scoped to the caller's tenant.upsert(UUID runId, UUID itemResultId, AnnotationRequest req, String principalId, TenantScope scope) Creates or updates the single annotation for the given item result.
-
Constructor Details
-
AnnotationService
public AnnotationService(AnnotationRepository annotationRepository, ItemResultRepository itemResultRepository, ExperimentRunRepository runRepository)
-
-
Method Details
-
upsert
@Transactional public AnnotationView upsert(UUID runId, UUID itemResultId, AnnotationRequest req, String principalId, TenantScope scope) Creates or updates the single annotation for the given item result. The run must be visible under the scope and the item result must belong to it. On an existing annotation this overwrites its fields and stampsupdatedAt; thecreatedByprincipal is recorded only when the annotation is first created. The new annotation is stamped with the run's tenant.- Throws:
IllegalArgumentException- if the run is not visible under the scope, or the item result does not exist or does not belong to the run (mapped to 404)
-
get
@Transactional(readOnly=true) public AnnotationView get(UUID runId, UUID itemResultId, TenantScope scope) Returns the annotation for the given run item result, scoped to the caller's tenant.- Throws:
IllegalArgumentException- if the run is not visible under the scope, the item result does not belong to the run, or it has no annotation (mapped to 404)
-
delete
Removes the annotation for the given run item result if one exists. No-op when the item result is un-annotated.- Throws:
IllegalArgumentException- if the run is not visible under the scope or the item result does not belong to the run (mapped to 404)
-