Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cds_migrator_kit/rdm/records/transform/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,18 @@
"witch is433": "IS433",
"isoltrap": "IS394",
"is485 (rex-isolde)": "IS485",
"charm": "ea-irrad mixed-field",
}

# 693__e values that are keywords rather than real experiments (curated as
# "mots clef"), mapped to subjects instead of cern:experiments
EXPERIMENTS_AS_SUBJECTS = ["d3", "r104", "r105a"]

# Legacy accelerator names remapped to vocabulary ids before lookup
ACCELERATOR_ALIASES = {
"cern aa": "antiproton accumulator",
Comment thread
kpsherva marked this conversation as resolved.
Resolved
}

# Public research publication resource types that are auto-included in the CERN Research community.
CERN_SCIENTIFIC_RESOURCE_TYPES = {
"publication-dissertation", # Already included by the migrator for thesis records.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
UnexpectedValue,
)
from cds_migrator_kit.rdm.records.transform.config import (
ACCELERATOR_ALIASES,
EXPERIMENT_ALIASES,
EXPERIMENTS_AS_SUBJECTS,
)
Expand Down Expand Up @@ -169,6 +170,9 @@ def apply(self, ctx):
"cern recognized expt.",
]:
continue
accelerator = ACCELERATOR_ALIASES.get(
accelerator.lower().strip(), accelerator
)
result = search_vocabulary(accelerator, "accelerators")
if result and result not in accelerators_out:
accelerators_out.append(result)
Expand Down
47 changes: 47 additions & 0 deletions cds_migrator_kit/rdm/records/transform/models/hse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CERN.
#
# CDS-RDM is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

"""CDS-RDM HSE model."""
from cds_migrator_kit.rdm.records.transform.models._config import IGNORE_SYSTEM_KEYS
from cds_migrator_kit.rdm.records.transform.models.base_publication_record import (
rdm_base_publication_model,
)
from cds_migrator_kit.transform.overdo import CdsOverdo


class HseModel(CdsOverdo):
"""Translation model for HSE records."""

__query__ = """595__:CERN-HSE"""

__ignore_keys__ = IGNORE_SYSTEM_KEYS | {
"100__j",
"300__c", # value only '9 p': 2712787, 2789695
"506__a", # Access note restrictions, only 2 records have "Free" but they are restricted
"595__a", # Unneeded: CERN-HSE or "To be check by ..."
"690C_a", # Duplicate of 980__a resource type
# "6531_9", # keyword scheme
"700__j",
"720__a", # Author's duplicate
"7870_r", # detailed description of record relation (2862345)
# Drop citation field https://cds.cern.ch/record/202927/
"913__t", # Citation field
"913__y", # Citation field
"913__v", # Citation field
"913__c", # Citation field
}

_default_fields = {
"custom_fields": {},
"record_restriction": "public", # All HSE papers are public, but some of them are missing 963:PUBLIC
}


hse_model = HseModel(
bases=(rdm_base_publication_model,),
entry_point_group="cds_migrator_kit.migrator.rules.hse",
)
28 changes: 28 additions & 0 deletions cds_migrator_kit/rdm/records/transform/models/radio_protection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CERN.
#
# CDS-RDM is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

"""CDS-RDM Radio Protection model."""
from cds_migrator_kit.rdm.records.transform.models.hse import HseModel, hse_model


class RadioProtectionModel(HseModel):
"""Translation model for Radio Protection records."""

__query__ = """980__:RP_RESTRICTED"""

_default_fields = {
"resource_type": {
"id": "publication-preprint"
}, # Default (only 2 articles which the rules will update)
"custom_fields": {},
}


radio_protection_model = RadioProtectionModel(
bases=(hse_model,), # inherits the HSE rules
entry_point_group="cds_migrator_kit.migrator.rules.radio_protection",
)
96 changes: 96 additions & 0 deletions cds_migrator_kit/rdm/records/transform/xml_processing/rules/hse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CERN.
#
# CDS-RDM is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

"""CDS-RDM HSE rules."""

from dojson.errors import IgnoreKey

from cds_migrator_kit.errors import UnexpectedValue
from cds_migrator_kit.transform.xml_processing.quality.decorators import (
for_each_value,
)

from ...models.hse import hse_model as model

# from .base import copyrights as base_copyright
# from .base import licenses as base_licenses
from .base import note as base_note
from .hr import corpo_author
from .it import imprint
from .research import resource_type as research_resource_type

# from dojson.utils import filter_values, force_list


# from cds_migrator_kit.transform.xml_processing.rules.base import (
# description as base_description,
# )


model.over("creators", "(^110__)")(corpo_author)
model.over("imprint_info", "(^250__)")(imprint) # Only one record: 156663


@model.over("physical_copies", "^964__", override=True)
@for_each_value
def physical_copies(self, key, value):
"""Translates physical copies field."""
number_of_copies = value.get("a").strip()
if number_of_copies and number_of_copies not in [
"0002",
"0001",
"0004",
"0003",
"0005",
]:
raise UnexpectedValue(subfield="a", value=number_of_copies, field=key)
raise IgnoreKey("physical_copies")


@model.over("internal_notes", "^595__")
@for_each_value
def note_hse(self, key, value):
"""Translates notes. HSE Articles query is 595__:CERN-HSE."""
_note = (value.get("a") or "").strip()
if _note in ("CERN-HSE", "To be check by Salome"):
raise IgnoreKey("internal_notes")
else:
return base_note(self, key, value)


# Reuse the generic 980__/697C_ resource type rule. HSE papers have no default,
# a record without a match is rejected by ``ResourceTypeMapper``.
model.over("resource_type", "(^980__)|(^697C_)", override=True)(research_resource_type)


# @model.over("rights", "^540__", override=True)
Comment thread
sakshamarora1 marked this conversation as resolved.
Resolved
# @for_each_value
# @filter_values
# def licenses(self, key, value):
# """Translates rights."""
# material = value.get("3")
# if material and material.lower() not in ["publication"]:
# raise UnexpectedValue(subfield="3", value=material, field=key)
# license = base_licenses(self, key, value)
# return license[0]


# @model.over("copyright", "^542__", override=True)
# def copyrights(self, key, value):
# """Translates copyright."""
# material = value.get("3")
# if material and material.lower() not in ["publication"]:
# raise UnexpectedValue(subfield="3", value=material, field=key)
# return base_copyright(self, key, value)
# @model.over("description", "^520__", override=True)
# def description(self, key, value):
# """Translates description."""
# abstract_number = value.get("9")
# # TODO: can we ignore?
# if abstract_number and abstract_number not in ["JACoW", "submitter"]:
# raise UnexpectedValue(subfield="9", value=abstract_number, field=key)
# return base_description(self, key, value)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CERN.
#
# CDS-RDM is free software; you can redistribute it and/or modify it under
# the terms of the MIT License; see LICENSE file for more details.

"""CDS-RDM Radio Protection rules."""

from ...models.radio_protection import radio_protection_model as model
from .research import resource_type as research_resource_type

# The rules (including the 980__/697C_ resource type) are inherited from the HSE
# model, only the model defaults differ (resource_type: publication-preprint).

# Radio Protection also has the document type in the 490__a series. Clean the
# value to the legacy document types known by the generic rule, it shares the
# rank with 980__ so the highest priority value wins. Replaces the inherited
# series rule.
SERIES_TO_DOCUMENT_TYPE = {
"internal report": "report",
"rp annual report": "report",
"divisionnal report": "report",
"technical inspection": "report",
"technical notes": "technical note",
"technical memorandum": "technical note",
}


@model.over("resource_type", "^490__", override_tag=True)
def series_resource_type(self, key, value):
"""Translates resource_type from the 490__a series."""
series = (value.get("a") or "").strip().lower()
cleaned = {"a": SERIES_TO_DOCUMENT_TYPE.get(series, series)}
return research_resource_type(self, key, cleaned)
6 changes: 6 additions & 0 deletions migration_cli/collections/hse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: hse
queries:
- q: "595__:CERN-HSE"
dump_file_prefix: hse
communities:
- hse
8 changes: 8 additions & 0 deletions migration_cli/collections/radio_protection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: radio_protection
queries:
- q: "980__:RP_RESTRICTED"
dump_file_prefix: radio_protection
flags:
restricted: true
communities:
- radio-protection
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ cds_migrator_kit.migrator.models =
it = cds_migrator_kit.rdm.records.transform.models.it:it_model
it_meetings = cds_migrator_kit.rdm.records.transform.models.it_meetings:it_meetings_model
hr = cds_migrator_kit.rdm.records.transform.models.hr:hr_model
hse = cds_migrator_kit.rdm.records.transform.models.hse:hse_model
radio_protection = cds_migrator_kit.rdm.records.transform.models.radio_protection:radio_protection_model
sy = cds_migrator_kit.rdm.records.transform.models.sy:sy_model
te = cds_migrator_kit.rdm.records.transform.models.te:te_model
en = cds_migrator_kit.rdm.records.transform.models.en:en_model
Expand Down Expand Up @@ -183,6 +185,12 @@ cds_migrator_kit.migrator.rules.hr =
base = cds_migrator_kit.transform.xml_processing.rules.base
base_records = cds_migrator_kit.rdm.records.transform.xml_processing.rules.base
hr = cds_migrator_kit.rdm.records.transform.xml_processing.rules.hr
cds_migrator_kit.migrator.rules.hse =
base = cds_migrator_kit.transform.xml_processing.rules.base
base_records = cds_migrator_kit.rdm.records.transform.xml_processing.rules.base
hse = cds_migrator_kit.rdm.records.transform.xml_processing.rules.hse
cds_migrator_kit.migrator.rules.radio_protection =
radio_protection = cds_migrator_kit.rdm.records.transform.xml_processing.rules.radio_protection
cds_migrator_kit.migrator.rules.sy =
base = cds_migrator_kit.transform.xml_processing.rules.base
base_records = cds_migrator_kit.rdm.records.transform.xml_processing.rules.base
Expand Down
Loading