-
Notifications
You must be signed in to change notification settings - Fork 12
add(ship): new models and transformation rules #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
cds_migrator_kit/rdm/records/transform/xml_processing/rules/ship.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are all the ignored confirmed with SIS? can we upgrade any to globally ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR, thanks!