diff --git a/commons/commons-model-extended-serialization/src/main/kotlin/uk/ac/ebi/extended/serialization/service/ExtSerializationServiceExt.kt b/commons/commons-model-extended-serialization/src/main/kotlin/uk/ac/ebi/extended/serialization/service/ExtSerializationServiceExt.kt index a2a46cd3a6..86d5cf9571 100644 --- a/commons/commons-model-extended-serialization/src/main/kotlin/uk/ac/ebi/extended/serialization/service/ExtSerializationServiceExt.kt +++ b/commons/commons-model-extended-serialization/src/main/kotlin/uk/ac/ebi/extended/serialization/service/ExtSerializationServiceExt.kt @@ -5,13 +5,18 @@ import ebi.ac.uk.extended.model.ExtSubmission import ebi.ac.uk.extended.model.allFileList import ebi.ac.uk.extended.model.allSectionsFiles +/** + * Return a sequence with all file list of a submission. Pagetab files are retrieved first, followed by section files + * and file list files. + */ fun ExtSerializationService.fileSequence(submission: ExtSubmission): Sequence { return sequence { - for (fileList in submission.allFileList) { - fileList.file.inputStream().use { deserializeList(it).forEach { yield(it) } } - fileList.pageTabFiles.forEach { yield(it) } - } - submission.allSectionsFiles.forEach { yield(it) } submission.pageTabFiles.forEach { yield(it) } + submission.allFileList.forEach { fileList -> fileList.pageTabFiles.forEach { yield(it) } } + + submission.allSectionsFiles.forEach { yield(it) } + submission.allFileList + .map { it.file } + .forEach { it.inputStream().use { stream -> deserializeList(stream).forEach { file -> yield(file) } } } } } diff --git a/submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/submitter/request/SubmissionRequestIndexer.kt b/submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/submitter/request/SubmissionRequestIndexer.kt index ee2f00de2c..4d4889aa9b 100644 --- a/submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/submitter/request/SubmissionRequestIndexer.kt +++ b/submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/submitter/request/SubmissionRequestIndexer.kt @@ -15,6 +15,11 @@ class SubmissionRequestIndexer( private val requestService: SubmissionRequestPersistenceService, private val filesRequestService: SubmissionRequestFilesPersistenceService, ) { + /** + * Index submission request file by creating records for each one. Note that pagetab files are processed first, + * guarantee by @see uk.ac.ebi.extended.serialization.service.ExtSerializationService.fileSequence to reduce time + * submission main/core data is not available. + */ fun indexRequest(accNo: String, version: Int) { val request = requestService.getPendingRequest(accNo, version) val sub = request.submission