-
Notifications
You must be signed in to change notification settings - Fork 1
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 # 184977702: Assign DOIs Automatically #736
Pivotal ID # 184977702: Assign DOIs Automatically #736
Conversation
- Validate the required DOI fields - Perform the request to register the DOI for the submission
Avoid requesting already existing DOI records
submission/submission-webapp/src/itest/kotlin/ac/uk/ebi/biostd/itest/itest/ITestListener.kt
Show resolved
Hide resolved
...ssion/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/submitter/SubmissionSubmitter.kt
Outdated
Show resolved
Hide resolved
submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/exceptions/DoiExceptions.kt
Show resolved
Hide resolved
- Calculate the DOI as part of the submission processing - Add an attribute to the extended model in order to keep track of the DOIs - Add logic to handle previous versions
Fields serialization
- Fix serialization - Add iTest
- Finish mapping - Solve warnings - Remove unused code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great please check comments
commons/commons-bio/src/main/kotlin/ebi/ac/uk/model/extensions/SubExt.kt
Outdated
Show resolved
Hide resolved
submission/submission-webapp/src/itest/kotlin/ac/uk/ebi/biostd/itest/itest/ITestListener.kt
Outdated
Show resolved
Hide resolved
private val properties: DoiProperties, | ||
) { | ||
fun calculateDoi(accNo: String, rqt: SubmitRequest): String? { | ||
val doi = rqt.submission.attributes.find { it.name == DOI.name } ?: return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you an use created doi extension bellow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is the find
method from the Attributable
returns null either if the attribute is not present or the value itself is null and at this point, we are only concerned about the attribute presence
submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/service/DoiService.kt
Outdated
Show resolved
Hide resolved
add(FILE_PARAM, FileSystemResource(requestFile)) | ||
} | ||
|
||
webClient.post(properties.endpoint, RequestParams(headers, body)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recomend to use functions so it becomes
val headers = httpHeadersOf(contentType to MULTIPART_FORM_DATA)
val body = linkedMultiValueMapOf(
USER_PARAM to properties.user,
PASSWORD_PARAM to properties.password,
OPERATION_PARAM to OPERATION_PARAM_VALUE,
FILE_PARAM to FileSystemResource(requestFile)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great functionality but it's part of the bio-webclient
module which is not used in the submitter
module and I think it shouldn't be. Instead, I moved this method to commons-http
which seems like the best place for this general functionality to be so it can be used in every module.
submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/service/DoiService.kt
Show resolved
Hide resolved
submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/service/DoiService.kt
Show resolved
Hide resolved
submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/service/DoiService.kt
Outdated
Show resolved
Hide resolved
submission/submitter/src/main/kotlin/ac/uk/ebi/biostd/submission/model/DoiRequest.kt
Outdated
Show resolved
Hide resolved
submission/submitter/src/test/kotlin/ac/uk/ebi/biostd/submission/service/DoiServiceTest.kt
Outdated
Show resolved
Hide resolved
- Simplify DOI service code - Use common http methods - Fix warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM please consider comments
@ChangeLog | ||
class ChangeLog010 { | ||
@ChangeSet(order = "010", id = "DOI Field", author = "System") | ||
fun changeSet010(template: MongockTemplate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you need to sync this part with last merge
return request.doi | ||
} | ||
|
||
private fun getContributors(sub: Submission): List<Contributor> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider
private fun getContributors(sub: Submission): List<Contributor> {
val organizations = getOrganizations(sub).associateBy({ it.accNo }, { it.name })
val contributors = sub.allSections().filter { it.type == AUTHOR_TYPE }
return contributors
.map { it.asContributor(organizations) }
.ifEmpty { throw MissingDoiFieldException(AUTHOR_TYPE) }
}
private fun Section.asContributor(organizations: Map<String, String>): Contributor {
val names = requireNotNull(find(NAME_ATTR)) { throw InvalidAuthorNameException() }
val org = requireNotNull(find(AFFILIATION_ATTR)) { throw MissingAuthorAffiliationException() }
val affiliation = requireNotNull(organizations[org]) { throw InvalidAuthorAffiliationException(names, org) }
val (name, surname) = names.split("\\s".toRegex())
return Contributor(
name = name,
surname = surname,
affiliation = affiliation,
orcid = find(ORCID_ATTR)
)
}
private fun getOrganizations(sub: Submission): List<Organization> {
return sub
.allSections().filter { it.type == ORG_TYPE }
.map { it.asOrganization() }
.ifEmpty { throw MissingDoiFieldException(ORG_TYPE) }
}
private fun Section.asOrganization(): Organization {
val accNo = requireNotNull(accNo) { throw InvalidOrgException() }
val name = requireNotNull(find(NAME_ATTR)) { throw InvalidOrgNameException(accNo) }
return Organization(accNo, name)
}
https://www.pivotaltracker.com/story/show/184977702