Skip to content

Commit

Permalink
import: fix get_contribution_link
Browse files Browse the repository at this point in the history
* Uses correct `DE-101` id's for GND links.
* Corrects SLSP, GND, LOC subjects dojson.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep committed Feb 27, 2023
1 parent 3ef22b9 commit c4453b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rero_ils/dojson/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,7 @@ def build_identifier(data):
'RERO-RAMEAU': 'RERO-RAMEAU',
'IDREF': 'IdRef',
'GND': 'GND',
'DE-588': 'GND'
'DE-101': 'GND'
}
result = {}
data_0 = utils.force_list(data.get('0'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,18 @@ def perform_subdivisions(field):
value, subfield_code_per_tag[creator_tag_key]), '.', '.')
field_key = 'genreForm' if tag_key == '655' else config_field_key
subfields_0 = utils.force_list(value.get('0'))

cont_id = None
if subfields_0:
cont_id = subfields_0[0]
for subfield_0 in subfields_0:
if 'DE-101' in subfield_0:
cont_id = subfield_0.replace('DE-101', 'gnd')
break
if data_type in [DocumentSubjectType.PERSON,
DocumentSubjectType.ORGANISATION] and subfields_0:
ref = get_contribution_link(marc21.bib_id, marc21.rero_id,
subfields_0[0], key)
DocumentSubjectType.ORGANISATION] and cont_id:
ref = get_contribution_link(
marc21.bib_id, marc21.bib_id, cont_id, key)
if ref:
subject = {
'$ref': ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ def perform_subdivisions(field):
field_key = 'genreForm' if tag_key == '655' else config_field_key
subfields_0 = utils.force_list(value.get('0'))
if data_type in ['bf:Person', 'bf:Organisation'] and subfields_0:
ref = get_contribution_link(marc21.bib_id, marc21.rero_id,
subfields_0[0], key)
ref = get_contribution_link(
marc21.bib_id, marc21.bib_id, subfields_0[0], key)
if ref:
subject = {
'$ref': ref,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/documents/test_documents_dojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -5060,6 +5060,7 @@ def test_marc21_to_subjects_imported():
<datafield tag="919" ind1=" " ind2=" ">
<subfield code="a">Sekundarstufe</subfield>
<subfield code="0">(DE-588)4077347-4</subfield>
<subfield code="0">(DE-101)040773477</subfield>
<subfield code="2">gnd</subfield>
</datafield>
</record>
Expand Down

0 comments on commit c4453b1

Please sign in to comment.