From fdcd349d86683efbbd1888ae6e170d4f1bbc6d14 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Tue, 17 Sep 2024 18:17:37 +0200 Subject: [PATCH 1/4] refactor(backend): rename enum SiloVersionStatus to VersionStatus and document the enum --- .../org/loculus/backend/api/SubmissionTypes.kt | 8 ++++---- .../loculus/backend/model/ReleasedDataModel.kt | 18 +++++++++++------- .../submission/GetReleasedDataEndpointTest.kt | 12 ++++++------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt b/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt index 44f0fcbf9..4e066b233 100644 --- a/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt +++ b/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt @@ -295,10 +295,10 @@ enum class PreprocessingStatus { FINISHED, } -enum class SiloVersionStatus { - REVOKED, - REVISED, - LATEST_VERSION, +enum class VersionStatus { + REVOKED, // Not the highest version, and a higher version is a revocation + REVISED, // Not the highest, and there is no higher revocation + LATEST_VERSION, // Highest version } enum class CompressionFormat(val compressionName: String) { diff --git a/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt b/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt index 0e001782c..a576bc146 100644 --- a/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt +++ b/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt @@ -13,7 +13,7 @@ import org.loculus.backend.api.DataUseTerms import org.loculus.backend.api.GeneticSequence import org.loculus.backend.api.Organism import org.loculus.backend.api.ProcessedData -import org.loculus.backend.api.SiloVersionStatus +import org.loculus.backend.api.VersionStatus import org.loculus.backend.config.BackendConfig import org.loculus.backend.service.submission.RawProcessedData import org.loculus.backend.service.submission.SubmissionDatabaseService @@ -47,7 +47,7 @@ class ReleasedDataModel( latestVersions: Map, latestRevocationVersions: Map, ): ProcessedData { - val siloVersionStatus = computeSiloVersionStatus(rawProcessedData, latestVersions, latestRevocationVersions) + val siloVersionStatus = computeVersionStatus(rawProcessedData, latestVersions, latestRevocationVersions) val currentDataUseTerms = computeDataUseTerm(rawProcessedData) val restrictedDataUseTermsUntil = if (currentDataUseTerms is DataUseTerms.Restricted) { @@ -102,22 +102,26 @@ class ReleasedDataModel( DataUseTerms.Open } - private fun computeSiloVersionStatus( + // LATEST_VERSION: Highest version + // REVOKED: Not highest version, higher version is a revocation + // REVISED: Not the highest version, and there's no higher version that is a revocation + // Note: a revocation entry is only REVOKED when there's a higher version that is a revocation + private fun computeVersionStatus( rawProcessedData: RawProcessedData, latestVersions: Map, latestRevocationVersions: Map, - ): SiloVersionStatus { + ): VersionStatus { val isLatestVersion = (latestVersions[rawProcessedData.accession] == rawProcessedData.version) if (isLatestVersion) { - return SiloVersionStatus.LATEST_VERSION + return VersionStatus.LATEST_VERSION } latestRevocationVersions[rawProcessedData.accession]?.let { if (it > rawProcessedData.version) { - return SiloVersionStatus.REVOKED + return VersionStatus.REVOKED } } - return SiloVersionStatus.REVISED + return VersionStatus.REVISED } } diff --git a/backend/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt b/backend/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt index 61be000fe..d4a5c4eb9 100644 --- a/backend/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt +++ b/backend/src/test/kotlin/org/loculus/backend/controller/submission/GetReleasedDataEndpointTest.kt @@ -20,8 +20,8 @@ import org.hamcrest.Matchers.not import org.junit.jupiter.api.Test import org.loculus.backend.api.GeneticSequence import org.loculus.backend.api.ProcessedData -import org.loculus.backend.api.SiloVersionStatus import org.loculus.backend.api.Status +import org.loculus.backend.api.VersionStatus import org.loculus.backend.controller.DEFAULT_GROUP_NAME import org.loculus.backend.controller.DEFAULT_USER_NAME import org.loculus.backend.controller.EndpointTest @@ -134,23 +134,23 @@ class GetReleasedDataEndpointTest( assertThat( response.findAccessionVersionStatus(accession, revokedVersion1), - `is`(SiloVersionStatus.REVOKED.name), + `is`(VersionStatus.REVOKED.name), ) assertThat( response.findAccessionVersionStatus(accession, revokedVersion2), - `is`(SiloVersionStatus.REVOKED.name), + `is`(VersionStatus.REVOKED.name), ) assertThat( response.findAccessionVersionStatus(accession, revocationVersion3), - `is`(SiloVersionStatus.REVISED.name), + `is`(VersionStatus.REVISED.name), ) assertThat( response.findAccessionVersionStatus(accession, revisedVersion4), - `is`(SiloVersionStatus.REVISED.name), + `is`(VersionStatus.REVISED.name), ) assertThat( response.findAccessionVersionStatus(accession, latestVersion5), - `is`(SiloVersionStatus.LATEST_VERSION.name), + `is`(VersionStatus.LATEST_VERSION.name), ) } From ad545f43c4c390edfc91fa49978228f497db7d7f Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Tue, 17 Sep 2024 18:20:19 +0200 Subject: [PATCH 2/4] One more name change --- .../kotlin/org/loculus/backend/model/ReleasedDataModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt b/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt index a576bc146..8c3b26f09 100644 --- a/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt +++ b/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt @@ -47,7 +47,7 @@ class ReleasedDataModel( latestVersions: Map, latestRevocationVersions: Map, ): ProcessedData { - val siloVersionStatus = computeVersionStatus(rawProcessedData, latestVersions, latestRevocationVersions) + val versionStatus = computeVersionStatus(rawProcessedData, latestVersions, latestRevocationVersions) val currentDataUseTerms = computeDataUseTerm(rawProcessedData) val restrictedDataUseTermsUntil = if (currentDataUseTerms is DataUseTerms.Restricted) { @@ -69,7 +69,7 @@ class ReleasedDataModel( ("submittedAtTimestamp" to LongNode(rawProcessedData.submittedAtTimestamp.toTimestamp())) + ("releasedAtTimestamp" to LongNode(rawProcessedData.releasedAtTimestamp.toTimestamp())) + ("releasedDate" to TextNode(rawProcessedData.releasedAtTimestamp.toUtcDateString())) + - ("versionStatus" to TextNode(siloVersionStatus.name)) + + ("versionStatus" to TextNode(versionStatus.name)) + ("dataUseTerms" to TextNode(currentDataUseTerms.type.name)) + ("dataUseTermsRestrictedUntil" to restrictedDataUseTermsUntil) + ("versionComment" to TextNode(rawProcessedData.versionComment)) From 13fc9453d2ae28403b933114a53a88936631c68d Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Tue, 17 Sep 2024 18:36:05 +0200 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Theo Sanderson --- .../main/kotlin/org/loculus/backend/api/SubmissionTypes.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt b/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt index 4e066b233..c6d1bd1ac 100644 --- a/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt +++ b/backend/src/main/kotlin/org/loculus/backend/api/SubmissionTypes.kt @@ -296,9 +296,9 @@ enum class PreprocessingStatus { } enum class VersionStatus { - REVOKED, // Not the highest version, and a higher version is a revocation - REVISED, // Not the highest, and there is no higher revocation - LATEST_VERSION, // Highest version + REVOKED, // This is not the highest version of the sequence entry, and a higher version is a revocation + REVISED, // This is not the highest version of the sequence entry, and no higher version is a revocation + LATEST_VERSION, // This is the highest version of the sequence entry } enum class CompressionFormat(val compressionName: String) { From acbbc98b744876a765838fb7363c4225774f05a6 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Tue, 17 Sep 2024 18:37:43 +0200 Subject: [PATCH 4/4] Apply suggestions from code review --- .../kotlin/org/loculus/backend/model/ReleasedDataModel.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt b/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt index 8c3b26f09..e996d9f59 100644 --- a/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt +++ b/backend/src/main/kotlin/org/loculus/backend/model/ReleasedDataModel.kt @@ -102,9 +102,9 @@ class ReleasedDataModel( DataUseTerms.Open } - // LATEST_VERSION: Highest version - // REVOKED: Not highest version, higher version is a revocation - // REVISED: Not the highest version, and there's no higher version that is a revocation + // LATEST_VERSION: This is the highest version of the sequence entry + // REVOKED: This is not the highest version of the sequence entry, and a higher version is a revocation + // REVISED: This is not the highest version of the sequence entry, and no higher version is a revocation // Note: a revocation entry is only REVOKED when there's a higher version that is a revocation private fun computeVersionStatus( rawProcessedData: RawProcessedData,