Repository navigation
components: ensure unique cdsrn - #569
Conversation
| return | ||
| else: | ||
| # Update the alternate identifiers with the new PIDs, but don't mint | ||
| record.metadata["identifiers"] = data["metadata"].get("identifiers", []) |
There was a problem hiding this comment.
not sure if this will cover the case:
- user adds report number + another identifier, let's say legacy recid
- report number has a duplicate -> throws a validation error.
legacy recid is not remembered in the form, is it? all the alt identifiers will be wiped out if I am reading this correctly.
There was a problem hiding this comment.
I have updated the code, so this should not happen anymore, added a test case too.
| ) | ||
|
|
||
|
|
||
| def alternate_identifier_minter(scheme, value, uuid): |
There was a problem hiding this comment.
do we need this utitlity ? can we use the .create directly
@ntarocco side question: in this case service (via component) access the data layer directly. Are we OK with that or should we find another way to manage it?
There was a problem hiding this comment.
I don't think that there are much alternatives, because we don't have a data layer exposing all the needed APIs. Most of our data layer objects are DB models that allows direct access, they are not wrapped exposing rich APIs.
Do you have other ideas?
cad0652 to
06e1030
Compare
06e1030 to
72aa170
Compare
| # This should raise PIDAlreadyExists error | ||
| record9 = RDMRecord.publish(draft9._record) | ||
| with pytest.raises(PIDAlreadyExists): | ||
| component.publish(administrator.identity, draft=draft9._record, record=record9) |
There was a problem hiding this comment.
Thanks for adding all these tests, super good.
Can you please only change the identity, and always use the normal user and not system or admin whenever possible?
|
check how long the scan should be |
|
on the draft lets mint with "reserved" status |
6d77955 to
bb798a1
Compare
palkerecsenyi
left a comment
There was a problem hiding this comment.
Looks good! I appreciate the nicely commented tests :)
| alternate_identifiers_map = {} | ||
| for id in data["metadata"].get("identifiers", []): | ||
| if id["scheme"] in alt_id_schemes: | ||
| alternate_identifiers_map.setdefault(id["scheme"], []).append( | ||
| id["identifier"] | ||
| ) | ||
| if not alternate_identifiers_map: | ||
| # If no mintable identifiers, return early | ||
| return |
There was a problem hiding this comment.
Maybe we could extract this into a shared method to reduce code duplication? But not really a huge deal since it's only used twice.
| CDS_CERN_SCIENTIFIC_COMMUNITY_ID = "CHANGE_ME" | ||
| """The id of the CERN Scientific community.""" | ||
|
|
||
| CDS_CERN_MINT_ALTERNATE_IDS = {"cdsrn": "CDS Reference"} |
There was a problem hiding this comment.
didn't we say to have CDS report number as a name in the end? @ntarocco
There was a problem hiding this comment.
I would say so, what was the outcome to this question in your interviews? (pinging @zzacharo too)
There was a problem hiding this comment.
From LHCb I remember that in their system the column name was "CDS reportnumber" but in their team they were calling it actually CDS reference number...
There was a problem hiding this comment.
to be scheduled for next deployment
38703f7 to
986a8d8
Compare
| # Only delete the PIDs not in draft anymore, i.e. targetting this record | ||
| db.session.delete(pid) |
There was a problem hiding this comment.
Great, thanks for the fix above, in the next PR, can you please add something like (pseudocode):
assert pid.pid_type not in [recid, doi, oai]
It is just a safety check!
closes: #370
cdsrnpid_typeSteps: