diff --git a/src/hermes/commands/deposit/base.py b/src/hermes/commands/deposit/base.py index 0a8e10f5..d9ff4389 100644 --- a/src/hermes/commands/deposit/base.py +++ b/src/hermes/commands/deposit/base.py @@ -59,7 +59,14 @@ def prepare(self) -> None: @abc.abstractmethod def map_metadata(self) -> None: - """Map the given metadata to the target schema of the deposition platform.""" + """Map the given metadata to the target schema of the deposition platform. + + When mapping metadata, make sure to add traces to the HERMES software, e.g. via + DataCite's ``relatedIdentifier`` using the ``isCompiledBy`` relation. Ideally, the value + of the relation target should be of the respective type for DOIs in your metadata + schema, with the value itself being the DOI for the version of the HERMES software + you are using. + """ pass def is_initial_publication(self) -> bool: diff --git a/src/hermes/commands/deposit/invenio.py b/src/hermes/commands/deposit/invenio.py index a613ac30..e88066c6 100644 --- a/src/hermes/commands/deposit/invenio.py +++ b/src/hermes/commands/deposit/invenio.py @@ -22,7 +22,7 @@ from hermes.error import MisconfigurationError from hermes.model.context import CodeMetaContext from hermes.model.path import ContextPath -from hermes.utils import hermes_user_agent +from hermes.utils import hermes_doi, hermes_user_agent _log = logging.getLogger("cli.deposit.invenio") @@ -392,6 +392,20 @@ def create_new_version(self) -> None: old_deposit = response.json() self.links.update(old_deposit["links"]) + def related_identifiers(self): + """Return desired related identifiers. + + In all cases, we add HERMES as ``isCompiledBy`` relation to be able to trace and + advertise HERMES usage across publication repositories. + """ + return [ + { + "identifier": hermes_doi, + "relation": "isCompiledBy", + "scheme": "doi", + }, + ] + def update_metadata(self) -> None: """Update the metadata of a draft.""" @@ -570,7 +584,7 @@ def _codemeta_to_invenio_deposition(self) -> dict: # TODO: A good source for this could be `tool.poetry.keywords` in pyproject.toml. "keywords": None, "notes": None, - "related_identifiers": None, + "related_identifiers": self.related_identifiers(), # TODO: Use `contributors`. In the case of the hermes workflow itself, the # contributors are currently all in `creators` already. So for now, we set this # to `None`. Change this when relationship between authors and contributors can diff --git a/src/hermes/commands/deposit/rodare.py b/src/hermes/commands/deposit/rodare.py index e42dd36d..c164e342 100644 --- a/src/hermes/commands/deposit/rodare.py +++ b/src/hermes/commands/deposit/rodare.py @@ -82,34 +82,35 @@ def create_initial_version(self) -> None: f"HERMES may be used for subsequent releases. {self.robis_url}" ) - def _codemeta_to_invenio_deposition(self) -> dict: - """Update the deposition metadata from the parent class. - - Deposits on Rodare require a connection to the publication database Robis. To - make this connection, the deposit metadata has to contain the field ``pub_id`` - which can be used to find the publication at - ``https://www.hzdr.de/publications/Publ-{pub_id}``. + def related_identifiers(self): + """Update the related identifiers with link to Robis. - Additionally (this is not required by Rodare), we make a connection via related - identifiers. + Add the Robis Publ-Id as a related identifier. This is additional metadata which + is not required by Rodare or Robis. It helps users find the related publication + on Robis at ``https://www.hzdr.de/publications/Publ-{pub_id}``. An example publication on Rodare: https://rodare.hzdr.de/api/records/2 The associated Robis page: https://www.hzdr.de/publications/Publ-27151 """ - pub_id = self.config.robis_pub_id - deposition_metadata = super()._codemeta_to_invenio_deposition() - - robis_identifier = { - "identifier": self.robis_publication_url.format(pub_id=pub_id), - "relation": "isIdenticalTo", - "scheme": "url", - } - - related_identifiers: list = deposition_metadata.get("related_identifiers", []) - related_identifiers.append(robis_identifier) + identifiers = super().related_identifiers() + identifiers.append( + { + "identifier": self.robis_publication_url.format( + pub_id=self.config.robis_pub_id + ), + "relation": "isIdenticalTo", + "scheme": "url", + } + ) + return identifiers - deposition_metadata["related_identifiers"] = related_identifiers - deposition_metadata["pub_id"] = pub_id + def _codemeta_to_invenio_deposition(self) -> dict: + """Update the deposition metadata with Robis Publ-Id. + Deposits on Rodare require a connection to the publication database Robis. To + make this connection, the deposit metadata has to contain the field ``pub_id``. + """ + deposition_metadata = super()._codemeta_to_invenio_deposition() + deposition_metadata["pub_id"] = self.config.robis_pub_id return deposition_metadata diff --git a/src/hermes/utils.py b/src/hermes/utils.py index 94a530d3..20ab5f58 100644 --- a/src/hermes/utils.py +++ b/src/hermes/utils.py @@ -13,4 +13,7 @@ hermes_version = hermes_metadata["version"] hermes_homepage = hermes_metadata["home-page"] +# TODO: Fetch this from somewhere +hermes_doi = "10.5281/zenodo.13311079" # hermes v0.8.1 + hermes_user_agent = f"{hermes_name}/{hermes_version} ({hermes_homepage})"