diff --git a/cds_migrator_kit/rdm/migration_config.py b/cds_migrator_kit/rdm/migration_config.py index c4827504..4be35615 100644 --- a/cds_migrator_kit/rdm/migration_config.py +++ b/cds_migrator_kit/rdm/migration_config.py @@ -551,7 +551,7 @@ def resolve_record_pid(pid): "label": "EP approval", # shown in UI buttons/headings "referee_group": "cds-ph-ep-publication", # CERN e-group slug "report_number": { - "prefix": "CERN-TH-EP", # literal prefix, e.g. "CERN-EP" + "prefix": "CERN-EP", # literal prefix, e.g. "CERN-EP" "include_year": True, # append the current year after prefix "counter_digits": 3, # zero-padding width, e.g. 3 → "001" }, @@ -606,4 +606,14 @@ def resolve_record_pid(pid): "counter_digits": 3, }, }, + "7277793b-5fce-458a-a3c4-e05a6cc43c69": { + # ship + "label": "EP approval", # shown in UI buttons/headings + "referee_group": "cds-ph-ep-publications-referee-non-lhc", # CERN e-group slug + "report_number": { + "prefix": "CERN-EP", # literal prefix, e.g. "CERN-EP" + "include_year": True, # append the current year after prefix + "counter_digits": 3, # zero-padding width, e.g. 3 → "001" + }, + }, } diff --git a/cds_migrator_kit/rdm/records/transform/models/_config.py b/cds_migrator_kit/rdm/records/transform/models/_config.py index a091d438..15b3cf54 100644 --- a/cds_migrator_kit/rdm/records/transform/models/_config.py +++ b/cds_migrator_kit/rdm/records/transform/models/_config.py @@ -15,10 +15,11 @@ # "035__z", # oai harvest tag "037__c", # arxiv subject "100__m", # email of contributor - # "245__9", # Provenance of title + "245__9", # Provenance of title # "270__m", # Contact email "300__a", # number of pages - # "520__9", # Provenance of the description + "500__9", # Provenance of the note + "520__9", # Provenance of the description # "540__3", # Material of the license # "540__9", # Also material of the license # "542__3", # Also material of the license diff --git a/cds_migrator_kit/rdm/records/transform/models/ship.py b/cds_migrator_kit/rdm/records/transform/models/ship.py new file mode 100644 index 00000000..6068d468 --- /dev/null +++ b/cds_migrator_kit/rdm/records/transform/models/ship.py @@ -0,0 +1,49 @@ +# -*- 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 SHIP research model.""" + +from cds_migrator_kit.rdm.records.transform.models._config import IGNORE_SYSTEM_KEYS +from cds_migrator_kit.rdm.records.transform.models.research import ( + ResearchModel, + research_model, +) + + +class SHIPResearchModel(ResearchModel): + """Translation model for SHIP records.""" + + __query__ = ( + "((980__.a:NOTE OR 980__.a:Note OR 980__.a:ConferencePaper) AND 690C_.a:SHiP) OR " + "980__.a:SHiPPUBDRAFTFINAL OR 980__.a:SHiP_Papers OR " + "(980__.a:INTNOTE AND 693__.e:SHiP) " + "-980__:DELETED -980__.a:DUMMY" + ) + + __ignore_keys__ = IGNORE_SYSTEM_KEYS | { + "100__v", # complete affiliation + "0247_9", # provenance of the DOI + "035__h", # oai identifiers + "035__d", # oai identifiers + "035__t", # oai identifiers + "035__u", # oai identifiers + "035__m", # oai identifiers + "110__u", # Confirmed with SIS + "270__m", # document contact email + "540__3", # material of license + "542__3", # copyright material + "700__v", # complete affiliation + "773__o", # Duplicate meeting title + "8564_z", # automatic process with EP value:Stamped by WebSubmit + "903__s", # public + } + + +ship_research_model = SHIPResearchModel( + bases=(research_model,), + entry_point_group="cds_migrator_kit.migrator.rdm.rules.ship", +) diff --git a/cds_migrator_kit/rdm/records/transform/xml_processing/rules/research.py b/cds_migrator_kit/rdm/records/transform/xml_processing/rules/research.py index 96ad40b2..a9616fe5 100644 --- a/cds_migrator_kit/rdm/records/transform/xml_processing/rules/research.py +++ b/cds_migrator_kit/rdm/records/transform/xml_processing/rules/research.py @@ -743,6 +743,7 @@ def resource_type(self, key, value): "slide": {"id": "presentation"}, "faser_papers": {"id": "publication-article"}, "demsuppliers": {"id": "other"}, + "ship_papers": {"id": "publication-article"}, "lhcf_papers": {"id": "publication-article"}, "lhcf_proc": {"id": "publication-conferenceproceeding"}, "lhcf_reports": {"id": "publication-report"}, diff --git a/cds_migrator_kit/rdm/records/transform/xml_processing/rules/ship.py b/cds_migrator_kit/rdm/records/transform/xml_processing/rules/ship.py new file mode 100644 index 00000000..6ec2e780 --- /dev/null +++ b/cds_migrator_kit/rdm/records/transform/xml_processing/rules/ship.py @@ -0,0 +1,58 @@ +# -*- 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 SHIP research rules.""" + +from dojson.errors import IgnoreKey +from dojson.utils import for_each_value + +from cds_migrator_kit.errors import UnexpectedValue +from cds_migrator_kit.transform.xml_processing.quality.parsers import StringValue + +from ...models.ship import ship_research_model as model +from .faser_publication import spokesperson + +model.over("request_reviewers", "(^905__|^906__)", override=True)(spokesperson) + + +@model.over("document_type", "^594__") +def document_type(self, key, value): + """Confirmed with SIS, we can ignore this since the record already has a resource type.""" + document_type = value.get("a").strip().lower() + if document_type and document_type not in [ + "int", + "conferencepaper", + "note", + ]: + raise UnexpectedValue(f"Invalid document type: {document_type}") + raise IgnoreKey("document_type") + + +@model.over("related_identifiers", "(^78502|^78002)") +@for_each_value +def related_works(self, key, value): + """Translates related identifiers.""" + description = StringValue(value.get("i")).parse().strip().lower() + recid = value.get("w") + report_number = value.get("r") + rel_ids = self.get("related_identifiers", []) + if "superseded by" == description: + relation_type = "isobsoletedby" + elif "supersedes" == description: + relation_type = "obsoletes" + else: + raise UnexpectedValue(f"Invalid relation type: {description}") + new_id = { + "identifier": recid, + "scheme": "cds", + "relation_type": {"id": relation_type}, + "resource_type": {"id": "other"}, + } + if new_id not in rel_ids: + return new_id + + raise IgnoreKey("related_identifiers") diff --git a/setup.cfg b/setup.cfg index 2b3a47fb..922ee713 100644 --- a/setup.cfg +++ b/setup.cfg @@ -78,6 +78,7 @@ cds_migrator_kit.migrator.models = lhcf = cds_migrator_kit.rdm.records.transform.models.lhcf:lhcf_model antares = cds_migrator_kit.rdm.records.transform.models.antares:antares_research_model lcd = cds_migrator_kit.rdm.records.transform.models.lcd:lcd_research_model + ship = cds_migrator_kit.rdm.records.transform.models.ship:ship_research_model research_comm_model = cds_migrator_kit.rdm.records.transform.models.research_committee:research_comm_model fap = cds_migrator_kit.rdm.records.transform.models.fap:fap_model ssn = cds_migrator_kit.rdm.records.transform.models.summer_student_report:sspn_model @@ -126,6 +127,11 @@ cds_migrator_kit.migrator.rdm.rules.research = base = cds_migrator_kit.transform.xml_processing.rules.base base_records = cds_migrator_kit.rdm.records.transform.xml_processing.rules.base research = cds_migrator_kit.rdm.records.transform.xml_processing.rules.research +cds_migrator_kit.migrator.rdm.rules.ship = + base = cds_migrator_kit.transform.xml_processing.rules.base + base_records = cds_migrator_kit.rdm.records.transform.xml_processing.rules.base + research = cds_migrator_kit.rdm.records.transform.xml_processing.rules.research + ship = cds_migrator_kit.rdm.records.transform.xml_processing.rules.ship cds_migrator_kit.migrator.rdm.rules.small_exp = base = cds_migrator_kit.transform.xml_processing.rules.base base_records = cds_migrator_kit.rdm.records.transform.xml_processing.rules.base