From c12ace30385fc607a9cf331820ed0a0fa849d289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Marie=CC=81thoz?= Date: Thu, 6 Apr 2023 12:02:11 +0200 Subject: [PATCH] entity: renames bf:Concept to bf:Topic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johnny MarieĢthoz --- data/documents_big.json | 102 +++++++++--------- data/documents_small.json | 58 +++++----- rero_ils/dojson/utils.py | 23 ++-- .../dojson/contrib/marc21tojson/slsp/model.py | 20 ++-- .../dojson/contrib/marc21tojson/utils.py | 2 +- .../document_contribution-v0.0.1.json | 4 +- .../document_entity_local-v0.0.1.json | 7 +- rero_ils/modules/entities/models.py | 1 - 8 files changed, 100 insertions(+), 117 deletions(-) diff --git a/data/documents_big.json b/data/documents_big.json index 15c846c769..a945b1f4ef 100644 --- a/data/documents_big.json +++ b/data/documents_big.json @@ -8651,7 +8651,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Bio-bibliography" } } @@ -15798,11 +15798,11 @@ }, { "audienceType": "school_level", - "value": "target_school_harmos11" + "value": "target_school_harmos1" }, { "audienceType": "school_level", - "value": "target_school_harmos1" + "value": "target_school_harmos11" } ] }, @@ -58698,7 +58698,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Early works to 1800" } } @@ -58725,7 +58725,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Poetry" } } @@ -59663,13 +59663,13 @@ } ], "intendedAudience": [ - { - "audienceType": "understanding_level", - "value": "target_understanding_secondary_level_2" - }, { "audienceType": "school_level", "value": "target_school_upper_secondary" + }, + { + "audienceType": "understanding_level", + "value": "target_understanding_secondary_level_2" } ] }, @@ -74386,7 +74386,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Biography" } } @@ -77701,7 +77701,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77716,7 +77716,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77731,7 +77731,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77746,7 +77746,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77767,7 +77767,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77788,7 +77788,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77803,7 +77803,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77824,7 +77824,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -77845,7 +77845,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -82789,11 +82789,11 @@ }, { "audienceType": "school_level", - "value": "target_school_harmos11" + "value": "target_school_harmos10" }, { "audienceType": "school_level", - "value": "target_school_harmos10" + "value": "target_school_harmos11" } ], "contribution": [ @@ -90665,8 +90665,8 @@ "$ref": "https://mef.rero.ch/api/agents/idref/13370744X" }, "role": [ - "cmp", - "prf" + "prf", + "cmp" ] }, { @@ -97738,19 +97738,19 @@ "intendedAudience": [ { "audienceType": "school_level", - "value": "target_school_harmos3" + "value": "target_school_harmos4" }, { "audienceType": "school_level", - "value": "target_school_harmos4" + "value": "target_school_harmos3" }, { "audienceType": "school_level", - "value": "target_school_harmos5" + "value": "target_school_harmos6" }, { "audienceType": "school_level", - "value": "target_school_harmos6" + "value": "target_school_harmos5" }, { "audienceType": "school_level", @@ -107222,19 +107222,19 @@ "intendedAudience": [ { "audienceType": "school_level", - "value": "target_school_harmos2" + "value": "target_school_harmos1" }, { "audienceType": "school_level", - "value": "target_school_harmos1" + "value": "target_school_harmos2" }, { "audienceType": "school_level", - "value": "target_school_harmos3" + "value": "target_school_harmos4" }, { "audienceType": "school_level", - "value": "target_school_harmos4" + "value": "target_school_harmos3" } ] }, @@ -130357,7 +130357,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -130378,7 +130378,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -130411,7 +130411,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -130432,7 +130432,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -130453,7 +130453,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -134986,7 +134986,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Bio-bibliography" } } @@ -143897,11 +143897,11 @@ }, { "audienceType": "school_level", - "value": "target_school_harmos11" + "value": "target_school_harmos10" }, { "audienceType": "school_level", - "value": "target_school_harmos10" + "value": "target_school_harmos11" } ], "partOf": [ @@ -155295,8 +155295,8 @@ "authorized_access_point": "Grandjean, Cl\u00e9ment" }, "role": [ - "pht", - "aut" + "aut", + "pht" ] } ], @@ -161826,7 +161826,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Correspondence" } } @@ -161847,7 +161847,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Correspondence" } } @@ -161868,7 +161868,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Correspondence" } } @@ -172408,21 +172408,21 @@ } ], "intendedAudience": [ + { + "audienceType": "school_level", + "value": "target_school_harmos1" + }, { "audienceType": "school_level", "value": "target_school_harmos11" }, { "audienceType": "school_level", - "value": "target_school_harmos1" + "value": "target_school_upper_secondary" }, { "audienceType": "understanding_level", "value": "target_understanding_secondary_level_2" - }, - { - "audienceType": "school_level", - "value": "target_school_upper_secondary" } ], "subjects": [ @@ -188870,7 +188870,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Periodicals" } } @@ -208460,7 +208460,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Bio-bibliography" } } diff --git a/data/documents_small.json b/data/documents_small.json index ddcfe76e34..84b3d63211 100644 --- a/data/documents_small.json +++ b/data/documents_small.json @@ -5867,7 +5867,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Bio-bibliography" } } @@ -6341,8 +6341,8 @@ "authorized_access_point": "Binet, Christian" }, "role": [ - "aut", - "ill" + "ill", + "aut" ] } ], @@ -7856,15 +7856,15 @@ }, { "audienceType": "school_level", - "value": "target_school_harmos9" + "value": "target_school_harmos10" }, { "audienceType": "school_level", - "value": "target_school_harmos11" + "value": "target_school_harmos9" }, { "audienceType": "school_level", - "value": "target_school_harmos10" + "value": "target_school_harmos11" } ], "partOf": [ @@ -13652,7 +13652,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Early works to 1800" } } @@ -13679,7 +13679,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Poetry" } } @@ -14796,11 +14796,11 @@ }, { "audienceType": "school_level", - "value": "target_school_harmos4" + "value": "target_school_harmos3" }, { "audienceType": "school_level", - "value": "target_school_harmos3" + "value": "target_school_harmos4" } ] }, @@ -27041,7 +27041,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Biography" } } @@ -29870,14 +29870,14 @@ ], "sequence_numbering": "No 1(2005)-", "intendedAudience": [ - { - "audienceType": "school_level", - "value": "target_school_tertiary" - }, { "audienceType": "understanding_level", "value": "target_understanding_tertiary" }, + { + "audienceType": "school_level", + "value": "target_school_tertiary" + }, { "audienceType": "understanding_level", "value": "target_understanding_hep_trainers" @@ -33204,7 +33204,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33219,7 +33219,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33234,7 +33234,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33249,7 +33249,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33270,7 +33270,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33291,7 +33291,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33306,7 +33306,7 @@ "subdivisions": [ { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33327,7 +33327,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -33348,7 +33348,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Exhibitions" } } @@ -39442,7 +39442,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -39463,7 +39463,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -39496,7 +39496,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -39517,7 +39517,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } @@ -39538,7 +39538,7 @@ }, { "entity": { - "type": "bf:Concept", + "type": "bf:Topic", "authorized_access_point": "Congresses" } } diff --git a/rero_ils/dojson/utils.py b/rero_ils/dojson/utils.py index e8d5c96611..875f5ffdc1 100644 --- a/rero_ils/dojson/utils.py +++ b/rero_ils/dojson/utils.py @@ -1987,25 +1987,22 @@ def build_identifier(data): :param data: data to build the identifiedBy from. :returns: identifiedBy from $0 or None. """ - sources = { + sources_mapping = { 'RERO': 'RERO', - 'RERO-RAMEAU': 'RERO-RAMEAU', + 'RERO-RAMEAU': 'RERO', 'IDREF': 'IdRef', 'GND': 'GND', 'DE-101': 'GND' } - result = {} - data_0 = utils.force_list(data.get('0')) - if data_0: - match = re_identified.match(data_0[0]) - if match: + if data_0 := utils.force_list(data.get('0')): + if match := re_identified.match(data_0[0]): try: - result['value'] = match.group(2) source = match.group(1) - identifier_type = sources.get(source.upper()) - if identifier_type: - result['type'] = identifier_type + result = { + 'value': match.group(2), + 'type': sources_mapping.get(source.upper()) + } + return {k: v for k, v in result.items() if v} except IndexError: - result = {} click.echo(f'WARNING creating identifier: {data_0}') - return result or None + return None diff --git a/rero_ils/modules/documents/dojson/contrib/marc21tojson/slsp/model.py b/rero_ils/modules/documents/dojson/contrib/marc21tojson/slsp/model.py index ff63dbb1b6..6353e135c0 100644 --- a/rero_ils/modules/documents/dojson/contrib/marc21tojson/slsp/model.py +++ b/rero_ils/modules/documents/dojson/contrib/marc21tojson/slsp/model.py @@ -401,25 +401,17 @@ def marc21_to_subjects_6XX(self, key, value): subfields_0 = utils.force_list(value.get('0')) if data_type in [EntityType.PERSON, EntityType.ORGANISATION] \ and subfields_0: - ref = get_contribution_link( - marc21.bib_id, marc21.bib_id, subfields_0[0], key) - if ref: + if ref := get_contribution_link(marc21.bib_id, marc21.bib_id, + subfields_0[0], key): subject = { '$ref': ref, 'type': data_type, } if not subject.get('$ref'): - identifier = build_identifier(value) - if identifier: - subject['identifiedBy'] = identifier - subfields_2 = utils.force_list(value.get('2')) - - if identifier \ - and data_type == EntityType.TOPIC \ - and len(subfields_2) > 0 \ - and subfields_2[0].lower() == 'rero': - identifier['type'] = 'RERO-RAMEAU' - if identifier: + if identifier := build_identifier(value): + sub_2 = next(iter(utils.force_list(value.get('2') or [])), '') + if data_type == EntityType.TOPIC and sub_2.lower() == 'rero': + identifier['type'] = 'RERO' subject['identifiedBy'] = identifier if field_key != 'genreForm': perform_subdivisions(subject, value) diff --git a/rero_ils/modules/documents/dojson/contrib/marc21tojson/utils.py b/rero_ils/modules/documents/dojson/contrib/marc21tojson/utils.py index b6bb37221e..665345d129 100644 --- a/rero_ils/modules/documents/dojson/contrib/marc21tojson/utils.py +++ b/rero_ils/modules/documents/dojson/contrib/marc21tojson/utils.py @@ -1999,7 +1999,7 @@ def format_date_c(date): def perform_subdivisions(field, value): """Perform subject subdivisions from MARC field.""" subdivisions = { - 'v': EntityType.CONCEPT, + 'v': EntityType.TOPIC, 'x': EntityType.TOPIC, 'y': EntityType.TEMPORAL, 'z': EntityType.PLACE diff --git a/rero_ils/modules/documents/jsonschemas/documents/document_contribution-v0.0.1.json b/rero_ils/modules/documents/jsonschemas/documents/document_contribution-v0.0.1.json index 10551fed99..babf271776 100644 --- a/rero_ils/modules/documents/jsonschemas/documents/document_contribution-v0.0.1.json +++ b/rero_ils/modules/documents/jsonschemas/documents/document_contribution-v0.0.1.json @@ -46,7 +46,7 @@ ], "properties": { "entity": { - "$ref": "https://bib.rero.ch/schemas/documents/document_entity_local-v0.0.1.json" + "$ref": "https://bib.rero.ch/schemas/documents/document_contribution_local-v0.0.1.json" }, "role": { "$ref": "https://bib.rero.ch/schemas/documents/document_contribution_role-v0.0.1.json" @@ -62,4 +62,4 @@ } } } -} \ No newline at end of file +} diff --git a/rero_ils/modules/documents/jsonschemas/documents/document_entity_local-v0.0.1.json b/rero_ils/modules/documents/jsonschemas/documents/document_entity_local-v0.0.1.json index fda9164628..b1cc11dc1f 100644 --- a/rero_ils/modules/documents/jsonschemas/documents/document_entity_local-v0.0.1.json +++ b/rero_ils/modules/documents/jsonschemas/documents/document_entity_local-v0.0.1.json @@ -150,10 +150,9 @@ "subtype": { "title": "Type", "type": "string", - "default": "bf:Person", + "default": "bf:Topic", "enum": [ "bf:Topic", - "bf:Concept", "bf:Place", "bf:Temporal" ], @@ -162,10 +161,6 @@ "templateOptions": { "itemCssClass": "col-lg-6", "options": [ - { - "label": "bf:Concept", - "value": "bf:Concept" - }, { "label": "bf:Topic", "value": "bf:Topic" diff --git a/rero_ils/modules/entities/models.py b/rero_ils/modules/entities/models.py index b5cf0f3fed..5b5130407d 100644 --- a/rero_ils/modules/entities/models.py +++ b/rero_ils/modules/entities/models.py @@ -48,7 +48,6 @@ class EntityType: """Class holding all available entity types.""" AGENT = 'bf:Agent' - CONCEPT = 'bf:Concept' ORGANISATION = 'bf:Organisation' PERSON = 'bf:Person' PLACE = 'bf:Place'