Package dev.dokimos.server.service
Class DatasetService
java.lang.Object
dev.dokimos.server.service.DatasetService
Service for server-owned versioned datasets. Datasets are mutable shells; versions are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionDatasetService(DatasetRepository datasetRepository, DatasetVersionRepository versionRepository, DatasetItemRepository itemRepository, ItemResultRepository itemResultRepository) -
Method Summary
Modifier and TypeMethodDescriptioncreateDataset(String name, String description, TenantScope scope) Creates a dataset whose name is unique within the scope, stamped with the scope's tenant.createVersion(String datasetName, String description, List<CreateVersionRequest.ItemPayload> items, String createdBy, TenantScope scope) Creates a new immutable version of the dataset visible under the scope and inserts all items in one transaction.voiddeleteDataset(String name, TenantScope scope) Deletes a dataset visible under the scope.getDataset(String name, TenantScope scope) Returns the dataset with the given name, visible under the scope.getDatasetDetails(String name, TenantScope scope) Returns full dataset details including the version list, newest first.getLatestVersion(String datasetName, TenantScope scope) Returns the latest version of the dataset, visible under the scope.getVersion(String datasetName, int version, TenantScope scope) Returns a specific version of the dataset, visible under the scope.listDatasets(TenantScope scope) Returns dataset summaries visible under the scope with the latest version number and item count for each.org.springframework.data.domain.Page<DatasetItem> listItems(DatasetVersion version, org.springframework.data.domain.Pageable pageable) Overload for callers that have already resolved aDatasetVersion; avoids the double-fetch path throughgetVersion(java.lang.String, int, dev.dokimos.server.tenant.TenantScope).org.springframework.data.domain.Page<DatasetItem> listItems(String datasetName, int version, org.springframework.data.domain.Pageable pageable, TenantScope scope) Returns items for the given version ordered by ordinal, paginated.promote(PromoteRequest req, String createdBy, TenantScope scope) Promotes run item results into a new version of an existing dataset.
-
Constructor Details
-
DatasetService
public DatasetService(DatasetRepository datasetRepository, DatasetVersionRepository versionRepository, DatasetItemRepository itemRepository, ItemResultRepository itemResultRepository)
-
-
Method Details
-
createDataset
Creates a dataset whose name is unique within the scope, stamped with the scope's tenant. Has no versions untilcreateVersion(java.lang.String, java.lang.String, java.util.List<dev.dokimos.server.dto.v1.CreateVersionRequest.ItemPayload>, java.lang.String, dev.dokimos.server.tenant.TenantScope)is called.- Throws:
IllegalStateException- if a dataset with the same name already exists in the scope (mapped to 409)
-
getDataset
Returns the dataset with the given name, visible under the scope.- Throws:
IllegalArgumentException- if no such dataset exists under the scope (mapped to 404)
-
listDatasets
Returns dataset summaries visible under the scope with the latest version number and item count for each. Collapses to two queries regardless of dataset count. -
getDatasetDetails
@Transactional(readOnly=true) public DatasetDetails getDatasetDetails(String name, TenantScope scope) Returns full dataset details including the version list, newest first. -
deleteDataset
Deletes a dataset visible under the scope. The FK cascade removes its versions and items; runs that referenced any of those versions have theirdataset_version_idset to NULL via the SET NULL FK so the historical run is preserved unlinked.- Throws:
IllegalArgumentException- if no such dataset exists under the scope (mapped to 404)
-
createVersion
@Transactional public DatasetVersion createVersion(String datasetName, String description, List<CreateVersionRequest.ItemPayload> items, String createdBy, TenantScope scope) Creates a new immutable version of the dataset visible under the scope and inserts all items in one transaction. The version and its items are stamped from the dataset's tenant so a scoped parent and child query agree. The pessimistic write lock on the parent dataset row serializes concurrent version creations.- Throws:
IllegalArgumentException- if no such dataset exists under the scope or items is empty
-
promote
@Transactional public DatasetVersionDetails promote(PromoteRequest req, String createdBy, TenantScope scope) Promotes run item results into a new version of an existing dataset. Each referenced item result must be visible under the scope, so a tenant cannot promote another tenant's items. Delegates tocreateVersion(java.lang.String, java.lang.String, java.util.List<dev.dokimos.server.dto.v1.CreateVersionRequest.ItemPayload>, java.lang.String, dev.dokimos.server.tenant.TenantScope)so the version-numbering and locking semantics are identical to a direct create.- Throws:
IllegalArgumentException- if any referenced item result or the dataset is missing or not visible under the scope (mapped to 404)
-
getVersion
@Transactional(readOnly=true) public DatasetVersion getVersion(String datasetName, int version, TenantScope scope) Returns a specific version of the dataset, visible under the scope.- Throws:
IllegalArgumentException- if the dataset or version is missing under the scope
-
getLatestVersion
@Transactional(readOnly=true) public DatasetVersion getLatestVersion(String datasetName, TenantScope scope) Returns the latest version of the dataset, visible under the scope.- Throws:
IllegalArgumentException- if the dataset has no versions under the scope
-
listItems
@Transactional(readOnly=true) public org.springframework.data.domain.Page<DatasetItem> listItems(String datasetName, int version, org.springframework.data.domain.Pageable pageable, TenantScope scope) Returns items for the given version ordered by ordinal, paginated. -
listItems
@Transactional(readOnly=true) public org.springframework.data.domain.Page<DatasetItem> listItems(DatasetVersion version, org.springframework.data.domain.Pageable pageable) Overload for callers that have already resolved aDatasetVersion; avoids the double-fetch path throughgetVersion(java.lang.String, int, dev.dokimos.server.tenant.TenantScope).
-