diff --git a/invenio.cfg b/invenio.cfg index 86dd3b38..b44c3518 100644 --- a/invenio.cfg +++ b/invenio.cfg @@ -574,6 +574,11 @@ RDM_RECORDS_RELATED_IDENTIFIERS_SCHEMES = { "validator": schemes.is_indico, "datacite": "INDICO" }, + "edms": { + "label": _("EDMS"), + "validator": schemes.is_edms, + "datacite": "EDMS" + }, "hal": { "label": "HAL", "validator": schemes.is_hal, diff --git a/site/cds_rdm/schemes.py b/site/cds_rdm/schemes.py index e86a6a93..93f5c847 100644 --- a/site/cds_rdm/schemes.py +++ b/site/cds_rdm/schemes.py @@ -22,7 +22,9 @@ cds_rdm_regexp = re.compile(r"[a-z0-9]{5}-[a-z0-9]{5}", flags=re.I) legacy_cds_pattern = re.compile(r"^\d+$", flags=re.I) is_indico_regexp = re.compile(r"^[a-zA-Z0-9]+$", flags=re.I) -inis_pattern = re.compile(r'^(?:\d+|RN:\d+)$', flags=re.I) +inis_pattern = re.compile(r"^(?:\d+|RN:\d+)$", flags=re.I) +edms_pattern = re.compile(r"^\d+$", flags=re.I) + def is_aleph(val): """Test if argument is an Aleph ID. @@ -55,7 +57,6 @@ def is_inis(val): return inis_pattern.match(val) - def inis(): """Define validator for `custom_scheme`.""" return { @@ -64,7 +65,6 @@ def inis(): } - def is_inspire(val): """Test if argument is an Inspire ID. @@ -88,6 +88,25 @@ def is_indico(val): return str(val).isdigit() +def is_edms(val): + """Test if argument is an EDMS document number.""" + return edms_pattern.match(str(val)) + + +def generate_edms_url(scheme, value): + """Generate EDMS url.""" + return f"https://edms.cern.ch/document/{value}" + + +def edms(): + """Define scheme for EDMS links.""" + return { + "validator": is_edms, + "normalizer": lambda value: str(value), + "url_generator": generate_edms_url, + } + + def indico(): """Define scheme for Indico Links.""" return { @@ -106,7 +125,6 @@ def inspire(): } - def inspire_author(): """Define validator for Inspire author.""" return { diff --git a/site/pyproject.toml b/site/pyproject.toml index 177c26f2..b4ce4111 100644 --- a/site/pyproject.toml +++ b/site/pyproject.toml @@ -38,6 +38,7 @@ inspire = "cds_rdm.schemes:inspire" inspire_author = "cds_rdm.schemes:inspire_author" cds = "cds_rdm.schemes:cds" indico = "cds_rdm.schemes:indico" +edms = "cds_rdm.schemes:edms" [project.entry-points."invenio_db.alembic"] cds_rdm = "cds_rdm:alembic" diff --git a/site/tests/conftest.py b/site/tests/conftest.py index 851e7772..dd606ec4 100644 --- a/site/tests/conftest.py +++ b/site/tests/conftest.py @@ -225,6 +225,11 @@ def app_config(app_config, mock_datacite_client): "validator": schemes.is_indico, "datacite": "INDICO", }, + "edms": { + "label": _("EDMS"), + "validator": schemes.is_edms, + "datacite": "EDMS", + }, } app_config["LOGGING_CONSOLE_LEVEL"] = "INFO" app_config["JOBS_LOGGING_LEVEL"] = "INFO"