[PATCH 14 of 14 eac] Some fixes on record_id

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Tue Jul 2 14:54:03 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1561992566 -7200
#      Mon Jul 01 16:49:26 2019 +0200
# Node ID b3efa52f66bde63d36a649a8609c0142306b8e25
# Parent  5115998f280adfa7916aa435931197186006702e
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r b3efa52f66bd
Some fixes on record_id

Fix a problem of extid and eid collision in the database.

diff -r 5115998f280a -r b3efa52f66bd cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Mon Jul 01 11:03:46 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Mon Jul 01 16:49:26 2019 +0200
@@ -1022,7 +1022,7 @@
         """Parse the `control` tag."""
         record_id = self._elem_find(control, 'eac:recordId')
         if record_id is not None and record_id.text and record_id.text.strip():
-            self.record.extid = record_id.text.strip()
+            self.record.extid = 'AR_{}'.format(record_id.text.strip())
             self.record.values['record_id'] = set([to_unicode(record_id.text)])
             self.record_visited(record_id, self.record)
         else:
diff -r 5115998f280a -r b3efa52f66bd cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Mon Jul 01 11:03:46 2019 +0200
+++ b/cubicweb_eac/schema.py	Mon Jul 01 16:49:26 2019 +0200
@@ -63,7 +63,8 @@
 
 
 class NameEntryS(EntityType):
-    """Represent a simple nameEntry tag of an EAC-CPF document."""
+    """Represent a nameEntry present in list in the nameEntryParallel tag.
+    It have to be a child of ParallelNames"""
     language = String(fulltextindexed=True)
     preferred_form = String(fulltextindexed=True)
     alternative_form = String(fulltextindexed=True)
@@ -77,8 +78,7 @@
 
 
 class NameEntry(NameEntryS):
-    """Represent a nameEntry with attributes it can have outside of
-     an nameEntryParallel"""
+    """Represent a unique nameEntry without parents"""
     pass
 
 
diff -r 5115998f280a -r b3efa52f66bd test/test_dataimport.py
--- a/test/test_dataimport.py	Mon Jul 01 11:03:46 2019 +0200
+++ b/test/test_dataimport.py	Mon Jul 01 16:49:26 2019 +0200
@@ -76,32 +76,32 @@
         _gen_extid = map(str, (x for x in count() if x not in (3, 40))).next
         expected = [
             ('EACOtherRecordId', _gen_extid(),
-             {'eac_other_record_id_of': set(['FRAD033_EAC_00001']),
+             {'eac_other_record_id_of': set(['AR_FRAD033_EAC_00001']),
               'value': set([u'1234']),
              },
             ),
             ('EACOtherRecordId', _gen_extid(),
-             {'eac_other_record_id_of': set(['FRAD033_EAC_00001']),
+             {'eac_other_record_id_of': set(['AR_FRAD033_EAC_00001']),
               'value': set([u'ABCD']),
               'local_type': set([u'letters']),
              },
             ),
             ('MaintenanceAg', _gen_extid(),
-             {'agency_of': ['FRAD033_EAC_00001'],
+             {'agency_of': ['AR_FRAD033_EAC_00001'],
               'agency_name': set([u'Gironde. Archives d\xe9partementales']),
               'agency_code': set([u'FR-AD033']),
               'maintenance_status': set([u'new']),
               'publication_status': set([u'approved'])},
             ),
             ('EACSource', _gen_extid(),
-             {'source_agent': set(['FRAD033_EAC_00001']),
+             {'source_agent': set(['AR_FRAD033_EAC_00001']),
               'title': set([u'1. Ouvrages imprimés...']),
               'description': set([u'des bouquins']),
               'description_format': set([u'text/plain']),
               },
              ),
             ('EACSource', _gen_extid(),
-             {'source_agent': set(['FRAD033_EAC_00001']),
+             {'source_agent': set(['AR_FRAD033_EAC_00001']),
               'url': set([u'http://archives.gironde.fr']),
               'title': set([u'Site des Archives départementales de la Gironde']),
              },
@@ -109,7 +109,7 @@
             ('Activity', _gen_extid(),
              {'type': set([u'create']),
               'agent_type': [u'human'],
-              'generated': set(['FRAD033_EAC_00001']),
+              'generated': set(['AR_FRAD033_EAC_00001']),
               'start': set([datetime.datetime(2013, 4, 24, 5, 34, 41)]),
               'end': set([datetime.datetime(2013, 4, 24, 5, 34, 41)]),
               'description': set([u'bla bla']),
@@ -117,7 +117,7 @@
              },
             ),
             ('Activity', _gen_extid(),
-             {'generated': set(['FRAD033_EAC_00001']),
+             {'generated': set(['AR_FRAD033_EAC_00001']),
               'type': set([u'modify']),
               'agent_type': [u'human'],
               'start': set([datetime.datetime(2015, 1, 15, 7, 16, 33)]),
@@ -126,13 +126,13 @@
              },
             ),
             ('LanguageDec', _gen_extid(),
-             {'language_declaration_of': ['FRAD033_EAC_00001'],
+             {'language_declaration_of': ['AR_FRAD033_EAC_00001'],
               'language': set([u'<language xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" languageCode="fre">français</language>']), # noqa
               'script': set([u'<script xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" scriptCode="Latn">latin</script>']) # noqa
              },
             ),
             ('Convention', _gen_extid(),
-             {'convention_of': ['FRAD033_EAC_00001'],
+             {'convention_of': ['AR_FRAD033_EAC_00001'],
               'abbrev': set([u'ISAAR(CPF)']),
               'has_citation': ['10'],
               'description_format': set([u'text/html']),
@@ -144,13 +144,13 @@
              },
             ),
             ('Convention', _gen_extid(),
-             {'convention_of': ['FRAD033_EAC_00001'],
+             {'convention_of': ['AR_FRAD033_EAC_00001'],
               'description_format': set([u'text/html']),
               'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">AFNOR NF Z 44-060, octobre 1983, Catalogue d\u2019auteurs et d\u2019anonymes : forme et\n          structure des vedettes des collectivit\xe9s auteurs.</p>']), # noqa
              },
             ),
             ('Convention', _gen_extid(),
-             {'convention_of': ['FRAD033_EAC_00001'],
+             {'convention_of': ['AR_FRAD033_EAC_00001'],
               'description_format': set([u'text/html']), 'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">Norme ISO 8601 :2004 \xc9l\xe9ments de donn\xe9es et formats d\u2019\xe9change -- \xc9change\n          d\u2019information -- Repr\xe9sentation de la date et de l\u2019heure.</p>']), # noqa
              },
             ),
@@ -160,17 +160,17 @@
             ('NameEntry', _gen_extid(),
              {'parts': set([u'Gironde, Conseil général']),
               'form_variant': set([u'authorized']),
-              'name_entry_for': set(['FRAD033_EAC_00001']),
+              'name_entry_for': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('NameEntry', _gen_extid(),
              {'parts': set([u'CG33']),
               'form_variant': set([u'alternative']),
-              'name_entry_for': set(['FRAD033_EAC_00001']),
+              'name_entry_for': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('ParallelNames', _gen_extid(),
-             {'parallel_names_of': set(['FRAD033_EAC_00001']),
+             {'parallel_names_of': set(['AR_FRAD033_EAC_00001']),
               'simple_name_relation': set(['17', '16']),
               'authorized_form': set([u'AFNOR_Z44-060\n\t'])
              },
@@ -189,7 +189,7 @@
              },
             ),
             ('ParallelNames', _gen_extid(),
-             {'parallel_names_of': set(['FRAD033_EAC_00001']),
+             {'parallel_names_of': set(['AR_FRAD033_EAC_00001']),
               'date_relation': set(['19']),
               'simple_name_relation': set(['20', '21', '22'])
              },
@@ -219,7 +219,7 @@
             ('AgentPlace', _gen_extid(),
              {'name': set([u'Bordeaux (Gironde, France)']),
               'role': set([u'siege']),
-              'place_agent': set(['FRAD033_EAC_00001']),
+              'place_agent': set(['AR_FRAD033_EAC_00001']),
               'place_entry_relation': set(['25']),
               'place_address': set(['23']),
               'equivalent_concept': set(['http://catalogue.bnf.fr/ark:/12148/cb152418385']),
@@ -231,7 +231,7 @@
             ),
             ('AgentPlace', _gen_extid(),
              {'name': set([u'Toulouse (France)']),
-              'place_agent': set(['FRAD033_EAC_00001']),
+              'place_agent': set(['AR_FRAD033_EAC_00001']),
               'place_entry_relation': set(['27']),
               'role': set([u'domicile']),
              },
@@ -242,7 +242,7 @@
             ),
             ('AgentPlace', _gen_extid(),
              {'name': set([u'Lit']),
-              'place_agent': set(['FRAD033_EAC_00001']),
+              'place_agent': set(['AR_FRAD033_EAC_00001']),
               'role': set([u'dodo']),
               'place_entry_relation': set(['29']),
              },
@@ -256,7 +256,7 @@
               'date_relation': set(['31']),
               'description': set([u'Description du statut']),
               'description_format': set([u'text/plain']),
-              'legal_status_agent': set(['FRAD033_EAC_00001']),
+              'legal_status_agent': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('DateEntity', _gen_extid(),
@@ -268,17 +268,17 @@
              {'term': set([u'1. Constitutions françaises']),
               'description': set([u'Description du mandat']),
               'description_format': set([u'text/plain']),
-              'mandate_agent': set(['FRAD033_EAC_00001']),
+              'mandate_agent': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('Language', _gen_extid(),
-             {'language_used_in': ['FRAD033_EAC_00001'],
+             {'language_used_in': ['AR_FRAD033_EAC_00001'],
               'language': set([u'<language xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" languageCode="eng">English\n\t  </language>']), # noqa
               'script': set([u'<script xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" scriptCode="Latn">Latin\n\t  </script>']) # noqa
              },
             ),
             ('Language', _gen_extid(),
-             {'language_used_in': ['FRAD033_EAC_00001'],
+             {'language_used_in': ['AR_FRAD033_EAC_00001'],
               'language': set([u'<language xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" languageCode="spa">Spanish\n\t  </language>']), # noqa
               'script': set([u'<script xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" scriptCode="Latn">Latin\n\t  </script>']) # noqa
              },
@@ -293,7 +293,7 @@
                                               u"L'inspecteur Canardo"])
               ]),
               'text_format': set([u'text/html']),
-              'history_agent': set(['FRAD033_EAC_00001']),
+              'history_agent': set(['AR_FRAD033_EAC_00001']),
               'has_citation': set(['37', '36']),
               'has_event': set(['38', '39']),
               'has_item': set(['41', '42', '43'])
@@ -328,18 +328,18 @@
             ('Structure', _gen_extid(),
              {'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">Pour accomplir ses missions ...</p>']),  # noqa
               'description_format': set([u'text/html']),
-              'structure_agent': set(['FRAD033_EAC_00001']),
+              'structure_agent': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('AgentFunction', _gen_extid(),
              {'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">Quatre grands domaines de compétence...</p>']),  # noqa
               'description_format': set([u'text/html']),
-              'function_agent': set(['FRAD033_EAC_00001']),
+              'function_agent': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('AgentFunction', _gen_extid(),
              {'name': set([u'action sociale']),
-              'function_agent': set(['FRAD033_EAC_00001']),
+              'function_agent': set(['AR_FRAD033_EAC_00001']),
               'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">1. Solidarité\n'  # noqa
                                   u'            blablabla.</p>']),
               'description_format': set([u'text/html']),
@@ -350,7 +350,7 @@
             ),
             ('AgentFunction', _gen_extid(),
              {'name': set([u'environnement']),
-              'function_agent': set(['FRAD033_EAC_00001']),
+              'function_agent': set(['AR_FRAD033_EAC_00001']),
               'equivalent_concept': set([
                   u'http://data.culture.fr/thesaurus/page/ark:/67717/T1-1074']),
              },
@@ -360,7 +360,7 @@
               'date_relation': set(['49']),
               'description': set([u'Organisation des réunions ...']),
               'description_format': set([u'text/plain']),
-              'occupation_agent': set(['FRAD033_EAC_00001']),
+              'occupation_agent': set(['AR_FRAD033_EAC_00001']),
               'has_citation': set(['50']),
               'equivalent_concept': set(['http://pifgadget.com']),
              },
@@ -380,7 +380,7 @@
                               u'xmlns:xlink="http://www.w3.org/1999/xlink">very famous</p>']),
               'content_format': set([u'text/html']),
               'has_citation': set(['52']),
-              'general_context_of': set(['FRAD033_EAC_00001']),
+              'general_context_of': set(['AR_FRAD033_EAC_00001']),
               }
             ),
             ('Citation', _gen_extid(),
@@ -399,7 +399,7 @@
               'description': set([u'Coucou']),
               'description_format': set([u'text/plain']),
               'hierarchical_parent': set(['CG33-DIRADSJ']),
-              'hierarchical_child': set(['FRAD033_EAC_00001']),
+              'hierarchical_child': set(['AR_FRAD033_EAC_00001']),
              },
             ),
             ('DateEntity', _gen_extid(),
@@ -419,7 +419,7 @@
             ),
             ('ChronologicalRelation', _gen_extid(),
              {'chronological_predecessor': set(['whatever']),
-              'chronological_successor': set(['FRAD033_EAC_00001']),
+              'chronological_successor': set(['AR_FRAD033_EAC_00001']),
               'date_relation': set(['56']),
               'entry': set([u'CG32']),
              },
@@ -430,7 +430,7 @@
              },
             ),
             ('ChronologicalRelation', _gen_extid(),
-             {'chronological_predecessor': set(['FRAD033_EAC_00001']),
+             {'chronological_predecessor': set(['AR_FRAD033_EAC_00001']),
               'chronological_successor': set(['/dev/null']),
               'date_relation': set(['58']),
               'xml_wrap': set(['<gloups xmlns="urn:isbn:1-931666-33-4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">hips</gloups>']),  # noqa
@@ -442,7 +442,7 @@
              },
             ),
             ('AssociationRelation', _gen_extid(),
-             {'association_from': set(['FRAD033_EAC_00001']),
+             {'association_from': set(['AR_FRAD033_EAC_00001']),
               'association_to': set(['agent-x']),
              },
             ),
@@ -453,7 +453,7 @@
               'resource_role': set([u'Fonds d\'archives']),
               'resource_relation_resource': set([
                   'http://gael.gironde.fr/ead.html?id=FRAD033_IR_N']),
-              'resource_relation_agent': set(['FRAD033_EAC_00001']),
+              'resource_relation_agent': set(['AR_FRAD033_EAC_00001']),
               'xml_wrap': set(['<he xmlns="urn:isbn:1-931666-33-4" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">joe</he>']),  # noqa
              },
             ),
@@ -469,7 +469,7 @@
                                   '\'s\n\t  communication with its alumni.\n\t  </p>']),
               'r_type': [u'performs'],
               'description_format': set([u'text/html']),
-              'function_relation_agent': set([u'FRAD033_EAC_00001']),
+              'function_relation_agent': set([u'AR_FRAD033_EAC_00001']),
               'function_relation_function': set([u'http://gael.gironde.fr/ead.html?'
                                                  'id=FRAD033_IR_N']),
               'relation_entry': set([u'Alumni communication\n\tmanagement, '
@@ -480,7 +480,7 @@
             ),
             ('EACFunctionRelation', _gen_extid(),
              {'function_relation_function': set([u'FRAD033_IR_N']),
-              'function_relation_agent': set([u'FRAD033_EAC_00001']),
+              'function_relation_agent': set([u'AR_FRAD033_EAC_00001']),
               'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" '
                                   'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                                   'xmlns:xlink="http://www.w3.org/1999/xlink">'
@@ -525,7 +525,7 @@
              {'uri': set([u'http://pifgadget.com']),
             'cwuri': set([u'http://pifgadget.com'])},
             ),
-            ('AuthorityRecord', 'FRAD033_EAC_00001',
+            ('AuthorityRecord', 'AR_FRAD033_EAC_00001',
              {'isni': set([u'22330001300016']),
               'start_date': set([datetime.date(1800, 1, 1)]),
               'end_date': set([datetime.date(2099, 1, 1)]),


More information about the saem-devel mailing list