Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query metadata for reviewcards #994

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data class SubmissionIdMapping(
override val accession: Accession,
override val version: Version,
val submissionId: String,
val dataUseTerms: DataUseTerms? = null,
) : AccessionVersionInterface

fun <T : AccessionVersionInterface> List<T>.toPairs() = map { Pair(it.accession, it.version) }
Expand Down Expand Up @@ -154,6 +153,7 @@ data class SequenceEntryStatus(
val group: String,
val isRevocation: Boolean = false,
val submissionId: String,
val dataUseTerms: DataUseTerms,
) : AccessionVersionInterface

data class UnprocessedData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ class DataUseTermsController(
description = "The accession of the sequence entry " +
"for which the data use terms should be retrieved",
) @PathVariable accession: Accession,
) = dataUseTermsDatabaseService.getDataUseTerms(accession)
) = dataUseTermsDatabaseService.getDataUseTermsHistory(accession)
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class SubmissionController(
organism: Organism,
@RequestBody body: Accessions,
@UsernameFromJwt username: String,
): List<SequenceEntryStatus> = submissionDatabaseService.revoke(body.accessions, username, organism)
): List<SubmissionIdMapping> = submissionDatabaseService.revoke(body.accessions, username, organism)

@Operation(description = CONFIRM_REVOCATION_DESCRIPTION)
@ResponseStatus(HttpStatus.NO_CONTENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DataUseTermsDatabaseService(
}
}

fun getDataUseTerms(accession: Accession): List<DataUseTermsHistoryEntry> {
fun getDataUseTermsHistory(accession: Accession): List<DataUseTermsHistoryEntry> {
val accessionDataUseTermsHistory = DataUseTermsTable
.select { DataUseTermsTable.accessionColumn eq accession }
.sortedBy { it[DataUseTermsTable.changeDateColumn] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.loculus.backend.api.Status.AWAITING_APPROVAL_FOR_REVOCATION
import org.loculus.backend.api.Status.HAS_ERRORS
import org.loculus.backend.api.Status.IN_PROCESSING
import org.loculus.backend.api.Status.RECEIVED
import org.loculus.backend.api.SubmissionIdMapping
import org.loculus.backend.api.SubmittedProcessedData
import org.loculus.backend.api.UnprocessedData
import org.loculus.backend.controller.BadRequestException
Expand Down Expand Up @@ -375,7 +376,11 @@ class SubmissionDatabaseService(
val listOfStatuses = statusesFilter ?: Status.entries

sequenceEntriesTableProvider.get(organism).let { table ->
var query = table
val query = table
.join(DataUseTermsTable, JoinType.LEFT, additionalConstraint = {
(table.accessionColumn eq DataUseTermsTable.accessionColumn) and
(DataUseTermsTable.isNewestDataUseTerms)
})
.slice(
table.accessionColumn,
table.versionColumn,
Expand All @@ -385,6 +390,8 @@ class SubmissionDatabaseService(
table.groupNameColumn,
table.organismColumn,
table.submittedAtColumn,
DataUseTermsTable.dataUseTermsTypeColumn,
DataUseTermsTable.restrictedUntilColumn,
)
.select(
where = {
Expand All @@ -407,12 +414,16 @@ class SubmissionDatabaseService(
row[table.groupNameColumn],
row[table.isRevocationColumn],
row[table.submissionIdColumn],
dataUseTerms = DataUseTerms.fromParameters(
DataUseTermsType.fromString(row[DataUseTermsTable.dataUseTermsTypeColumn]),
row[DataUseTermsTable.restrictedUntilColumn],
),
)
}
}
}

fun revoke(accessions: List<Accession>, username: String, organism: Organism): List<SequenceEntryStatus> {
fun revoke(accessions: List<Accession>, username: String, organism: Organism): List<SubmissionIdMapping> {
log.info { "revoking ${accessions.size} sequences" }

accessionPreconditionValidator.validateAccessions(
Expand Down Expand Up @@ -471,12 +482,9 @@ class SubmissionDatabaseService(
table.statusIs(AWAITING_APPROVAL_FOR_REVOCATION)
},
).map {
SequenceEntryStatus(
SubmissionIdMapping(
it[table.accessionColumn],
it[table.versionColumn],
AWAITING_APPROVAL_FOR_REVOCATION,
it[table.groupNameColumn],
it[table.isRevocationColumn],
it[table.submissionIdColumn],
)
}.sortedBy { it.accession }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,15 @@ class UploadDatabaseService(
result.toList()
} ?: emptyList()

val result = if (submissionParams is SubmissionParams.OriginalSubmissionParams) {
if (submissionParams is SubmissionParams.OriginalSubmissionParams) {
dataUseTermsDatabaseService.setNewDataUseTerms(
submissionParams.username,
insertionResult.map { it.accession },
submissionParams.dataUseTerms,
)

insertionResult.map {
SubmissionIdMapping(
it.accession,
it.version,
it.submissionId,
submissionParams.dataUseTerms,
)
}
} else {
insertionResult
}

return@transaction result
return@transaction insertionResult
}

fun deleteUploadData(uploadId: String) {
Expand Down
3 changes: 3 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ server.forward-headers-strategy=framework
spring.servlet.multipart.max-file-size=5000MB
spring.servlet.multipart.max-request-size=5000MB


server.compression.enabled=true

spring.datasource.driverClassName=org.postgresql.Driver

springdoc.show-actuator=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.mockk.every
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.loculus.backend.api.DataUseTerms
import org.loculus.backend.api.SequenceEntryStatus
import org.loculus.backend.api.Status
import org.loculus.backend.controller.EndpointTest
Expand Down Expand Up @@ -68,6 +69,7 @@ class CitationEndpointsTest(
"mock-group",
false,
"mock-submission-id",
DataUseTerms.Open,
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class RevokeEndpointTest(
.andExpect(jsonPath("\$.length()").value(DefaultFiles.NUMBER_OF_SEQUENCES))
.andExpect(jsonPath("\$[0].accession").value(firstAccession))
.andExpect(jsonPath("\$[0].version").value(2))
.andExpect(jsonPath("\$[0].status").value("AWAITING_APPROVAL_FOR_REVOCATION"))
.andExpect(jsonPath("\$[0].isRevocation").value(true))

convenienceClient.getSequenceEntryOfUser(accession = firstAccession, version = 2)
.assertStatusIs(AWAITING_APPROVAL_FOR_REVOCATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class SubmissionConvenienceClient(

fun prepareDefaultSequenceEntriesToAwaitingApprovalForRevocation(
organism: String = DEFAULT_ORGANISM,
): List<SequenceEntryStatus> {
): List<SubmissionIdMapping> {
val accessionVersions = prepareDefaultSequenceEntriesToApprovedForRelease(organism = organism)
return revokeSequenceEntries(accessionVersions.map { it.accession }, organism = organism)
}
Expand Down Expand Up @@ -247,7 +247,7 @@ class SubmissionConvenienceClient(
fun revokeSequenceEntries(
listOfSequencesToRevoke: List<Accession>,
organism: String = DEFAULT_ORGANISM,
): List<SequenceEntryStatus> =
): List<SubmissionIdMapping> =
deserializeJsonResponse(client.revokeSequenceEntries(listOfSequencesToRevoke, organism = organism))

fun confirmRevocation(
Expand Down
34 changes: 29 additions & 5 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-chartjs-2": "^5.2.0",
"react-confirm-alert": "^3.0.6",
"react-dom": "^18.2.0",
"react-tooltip": "^5.26.2",
"unplugin-icons": "^0.18.2",
"winston": "^3.11.0",
"zod": "^3.22.4"
Expand Down
Loading
Loading