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

Pivotal ID # 172671360: Warn users about upcoming public release #324

Merged
merged 3 commits into from
Jan 26, 2021
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
@@ -1,6 +1,6 @@
Dear ${USERNAME},

Your submission accession number ${ACC_NO} - "${TITLE}" will be made public on ${RELEASE_DATE}.
Your submission with accession number ${ACC_NO} - "${TITLE}" will be made public on ${RELEASE_DATE}.

If you want to keep your submission private after this date or make it public earlier, please log in to the BioStudies Submission Tool at ${UI_URL}/submissions/submissions and change the release date.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Dear ${USERNAME},

Thank you for submitting your data to BioStudies. Your submission "${TITLE}" has been assigned BioStudies accession number ${ACC_NO}.
Thank you for submitting your data to BioStudies. Your submission "${TITLE}" has been assigned the BioStudies accession number ${ACC_NO}.

You will be able to see it at ${UI_URL}/studies/${ACC_NO} in the next 24 hours. ${RELEASE_MESSAGE}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface SubmissionQueryService {

fun expireSubmission(accNo: String)

fun getExtendedSubmissions(filter: SubmissionFilter, offset: Long, limit: Int): Page<ExtSubmission>
fun getExtendedSubmissions(filter: SubmissionFilter, offset: Long, limit: Int): Page<Result<ExtSubmission>>

fun getSubmissionsByUser(userId: Long, filter: SubmissionFilter): List<BasicSubmission>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ internal class SubmissionMongoQueryService(
submissionRepo.saveAll(actives)
}

override fun getExtendedSubmissions(filter: SubmissionFilter, offset: Long, limit: Int): Page<ExtSubmission> {
TODO("Not yet implemented")
}
override fun getExtendedSubmissions(
filter: SubmissionFilter,
offset: Long,
limit: Int
): Page<Result<ExtSubmission>> = TODO("Not yet implemented")

override fun getSubmissionsByUser(userId: Long, filter: SubmissionFilter): List<BasicSubmission> {
TODO("Not yet implemented")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ internal open class SubmissionRepository(
}

@Transactional(readOnly = true)
override fun getExtendedSubmissions(filter: SubmissionFilter, offset: Long, limit: Int): Page<ExtSubmission> {
override fun getExtendedSubmissions(
filter: SubmissionFilter,
offset: Long,
limit: Int
): Page<Result<ExtSubmission>> {
val filterSpecs = SubmissionFilterSpecification(filter)
val pageable = OffsetPageRequest(offset, limit, Sort.by(defaultOrder))

return submissionRepository
.findAll(filterSpecs.specification, pageable, EntityGraphs.named(SIMPLE_GRAPH))
.map { getExtByAccNoAndVersion(it.accNo, it.version) }
.map { runCatching { getExtByAccNoAndVersion(it.accNo, it.version) } }
}

override fun getSubmissionsByUser(userId: Long, filter: SubmissionFilter): List<BasicSubmission> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import ac.uk.ebi.biostd.submission.web.model.ExtPageRequest
import ebi.ac.uk.extended.model.ExtSubmission
import ebi.ac.uk.extended.model.FileMode.COPY
import ebi.ac.uk.security.integration.components.IUserPrivilegesService
import mu.KotlinLogging
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageImpl

private val logger = KotlinLogging.logger {}

class ExtSubmissionService(
private val persistenceService: SubmissionRequestService,
Expand All @@ -25,7 +29,14 @@ class ExtSubmissionService(
fun getExtendedSubmissions(request: ExtPageRequest): Page<ExtSubmission> {
val filter = SubmissionFilter(
rTimeFrom = request.fromRTime, rTimeTo = request.toRTime, released = request.released)
return submissionRepository.getExtendedSubmissions(filter, request.offset, request.limit)

val page = submissionRepository
.getExtendedSubmissions(filter, request.offset, request.limit)
.onEach { it.onFailure { logger.error { it.message ?: it.localizedMessage } } }
.map { it.getOrNull() }
val submissions = page.content.filterNotNull()

return PageImpl(submissions, page.pageable, submissions.size.toLong())
}

private fun validateUser(user: String) = require(userPrivilegesService.canSubmitExtended(user)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestController
class SubmissionResource(
private val submissionsWebHandler: SubmissionsWebHandler
) {

@GetMapping
@ApiOperation("Get the basic data for the submissions that matches the given filter")
@ApiImplicitParams(value = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ac.uk.ebi.biostd.persistence.common.request.SaveSubmissionRequest
import ac.uk.ebi.biostd.persistence.common.request.SubmissionFilter
import ac.uk.ebi.biostd.persistence.common.service.SubmissionQueryService
import ac.uk.ebi.biostd.persistence.common.service.SubmissionRequestService
import ac.uk.ebi.biostd.persistence.exception.ExtSubmissionMappingException
import ac.uk.ebi.biostd.submission.web.model.ExtPageRequest
import ebi.ac.uk.extended.model.ExtSubmission
import ebi.ac.uk.extended.model.FileMode.COPY
Expand All @@ -20,7 +21,8 @@ import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageImpl
import org.springframework.data.domain.Pageable

@ExtendWith(MockKExtension::class)
class ExtSubmissionServiceTest(
Expand Down Expand Up @@ -48,7 +50,7 @@ class ExtSubmissionServiceTest(
}

@Test
fun `filtering extended submissions`(@MockK page: Page<ExtSubmission>) {
fun `filtering extended submissions`(@MockK extSubmission: ExtSubmission) {
val filter = slot<SubmissionFilter>()
val request = ExtPageRequest(
fromRTime = "2019-09-21T15:00:00Z",
Expand All @@ -57,8 +59,19 @@ class ExtSubmissionServiceTest(
offset = 1,
limit = 2)

val pageable = Pageable.unpaged()
val result1 = Result.success(extSubmission)
val result2 = Result.failure<ExtSubmission>(ExtSubmissionMappingException("S-TEST123", "error"))
val results = mutableListOf(result1, result2)
val page = PageImpl(results, pageable, 2L)

every { submissionRepository.getExtendedSubmissions(capture(filter), 1, 2) } returns page
testInstance.getExtendedSubmissions(request)

val result = testInstance.getExtendedSubmissions(request)
assertThat(result.content).hasSize(1)
assertThat(result.content.first()).isEqualTo(extSubmission)
assertThat(result.pageable).isEqualTo(pageable)
assertThat(result.totalElements).isEqualTo(1L)

val submissionFilter = filter.captured
assertThat(submissionFilter.released).isTrue()
Expand Down