-
Notifications
You must be signed in to change notification settings - Fork 10
add(staff-association): new model and transformation rules #391
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
Open
zubeydecivelek
wants to merge
1
commit into
CERNDocumentServer:master
Choose a base branch
from
zubeydecivelek:staff-assoc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
103 changes: 103 additions & 0 deletions
103
cds_migrator_kit/rdm/records/transform/models/staff_association.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,103 @@ | ||
| # -*- 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 Staff Association model.""" | ||
| from cds_migrator_kit.rdm.records.transform.models.bulletin_issue import ( | ||
| bull_issue_model, | ||
| ) | ||
| from cds_migrator_kit.transform.overdo import CdsOverdo | ||
|
|
||
|
|
||
| class StaffAssociationModel(CdsOverdo): | ||
| """Translation model for Staff Association.""" | ||
|
|
||
| __query__ = """ | ||
| ( | ||
| 980__:BULLETINSTAFF | ||
| -980__:CERN_BULLETIN_ARTICLE | ||
| -980__:CERN_BULLETIN_ISSUE | ||
| ) | ||
| OR | ||
| ( | ||
| 980__:STAFFASSOCIATION | ||
| 594__:PUB | ||
| ) | ||
| """ | ||
|
|
||
| # Copy-pasted from bulletin issue | ||
| __ignore_keys__ = { | ||
| "0248_a", | ||
| "0248_p", | ||
| "0248_q", | ||
| "100__m", # email of contributor | ||
| "110__a", # corporate author, always CERN, safe to ignore | ||
| "300__a", # number of pages | ||
| "336__a", # DM metadata | ||
| "5831_2", # DM tags 1054836 | ||
| "5831_5", # DM tags | ||
| "5831_a", # DM tags | ||
| "5831_c", # DM tags | ||
| "5831_f", # DM tags | ||
| "5831_i", # DM tags | ||
| "5831_k", # DM tags | ||
| "5831_u", # DM tags | ||
| "5831_3", # DM tags | ||
| "5831_6", # DM tags | ||
| "5831_n", # DM tags | ||
| "5831_b", # DM tags | ||
| "5831_o", # DM tags | ||
| "583__a", # DM tags | ||
| "583__c", # DM tags | ||
| "583__z", # DM tags | ||
| "594__a", # values: "no", "pub" | ||
| "650172", # scheme of subjects | ||
| "6531_9", # scheme of keywords | ||
| "691__a", # draft/online values, redundant | ||
| "700__m", # email of contributor | ||
| "773__p", # title of the "CERN Bulletin" series | ||
| "773__t", # CERN Bulletin value, redundant | ||
| "773__y", # year, duplicate of 260 | ||
| "8560_f", # contact email | ||
| "8564_8", # file id | ||
| "8564_s", # bibdoc id | ||
| "8564_x", # icon thumbnails sizes | ||
| "8564_y", # file description - done by files dump | ||
| "8564_2", # DM metadata | ||
| "8564_q", # DM metadata | ||
| "8564_w", # DM metadata | ||
| "8564_z", # DM metadata | ||
| "8567_2", # DM tags | ||
| "8567_q", # DM tags | ||
| "8567_w", # DM tags | ||
| "8567_d", # DM tags | ||
| "859__a", # TODO: Implement rule for this, 2595/3306 records have this field | ||
| "906__m", # edit rights, will be granted by the community | ||
| "937__c", # last modified by | ||
| "937__s", # last modification date | ||
| "960__a", # base number | ||
| "961__a", # CDS modification tag # TODO | ||
| "961__b", # CDS modification tag # TODO | ||
| "961__c", # CDS modification tag # TODO | ||
| "961__h", # CDS modification tag # TODO | ||
| "961__l", # CDS modification tag # TODO | ||
| "961__x", # CDS modification tag # TODO | ||
| "981__a", # duplicate record id | ||
| # "246_1a", | ||
| # "690C_a", | ||
| } | ||
|
|
||
| _default_fields = { | ||
| # TODO should we keep this custom field? | ||
| "custom_fields": {"journal:journal": {"title": "CERN Bulletin"}}, | ||
| "creators": [{"person_or_org": {"type": "organizational", "name": "CERN"}}], | ||
| } | ||
|
|
||
|
|
||
| staff_association_model = StaffAssociationModel( | ||
| bases=(bull_issue_model,), | ||
| entry_point_group="cds_migrator_kit.migrator.rules.staff_association", | ||
| ) | ||
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
48 changes: 48 additions & 0 deletions
48
cds_migrator_kit/rdm/records/transform/xml_processing/rules/staff_association.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,48 @@ | ||
| # -*- 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 Staff Association rules.""" | ||
|
|
||
| from dojson.errors import IgnoreKey | ||
|
|
||
| from cds_migrator_kit.errors import UnexpectedValue | ||
| from cds_migrator_kit.rdm.records.transform.xml_processing.rules.base import ( | ||
| additional_titles, | ||
| ) | ||
| from cds_migrator_kit.transform.xml_processing.quality.decorators import for_each_value | ||
|
|
||
| from ...models.staff_association import staff_association_model as model | ||
| from .bulletin_issue import collection | ||
| from .publications import internal_notes | ||
|
|
||
| model.over("internal_notes", "^562__")(internal_notes) | ||
| model.over("additional_titles", "(^242__)")(additional_titles) | ||
|
|
||
|
|
||
| @model.over("resource_type", "^980__", override=True) | ||
| def resource_type(self, key, value): | ||
| """Translates resource_type.""" | ||
| value = value.get("a") if "a" in value else value.get("b") | ||
| if value: | ||
| value = value.lower() | ||
| if value in ["bulletinstaff", "staffassociation"]: | ||
| # TODO what is the resource type? | ||
| return {"id": "publication-periodicalarticle"} | ||
| raise UnexpectedValue( | ||
| "Unknown resource type (STAFF ASSOCIATION)", field=key, value=value | ||
| ) | ||
|
|
||
|
|
||
| @model.over("collection", "^690C_", override=True) | ||
| @for_each_value | ||
| def staff_association_collection(self, key, value): | ||
| """Translates collection field.""" | ||
| collection_a = value.get("a", "").strip().lower() | ||
| # Drop sa documents | ||
| if collection_a == "sa documents": | ||
| raise IgnoreKey("collection") | ||
| collection(self, key, value) |
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
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.
Uh oh!
There was an error while loading. Please reload this page.