[PATCH eac] Add support for a Citation child on Structure

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Thu Sep 5 09:30:31 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1565106079 -7200
#      Tue Aug 06 17:41:19 2019 +0200
# Node ID 31c5c8e8a1d9e8d64c60603dc8a9e76da7c595b0
# Parent  525d1933c0b081f7be5dc8d1aa2fcd58a99d654a
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 31c5c8e8a1d9
Add support for a Citation child on Structure

diff -r 525d1933c0b0 -r 31c5c8e8a1d9 cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Wed Sep 04 17:34:43 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Tue Aug 06 17:41:19 2019 +0200
@@ -749,6 +749,7 @@
 
     @elem_maybe_none
     @relate_to_record_through('Structure', 'structure_agent')
+    @add_citations_for('Structure')
     @add_items_for('Structure')
     def build_structure(self, elem):
         """Build a `Structure` external entity."""
diff -r 525d1933c0b0 -r 31c5c8e8a1d9 cubicweb_eac/migration/0.9.0_Any.py
--- a/cubicweb_eac/migration/0.9.0_Any.py	Wed Sep 04 17:34:43 2019 +0200
+++ b/cubicweb_eac/migration/0.9.0_Any.py	Tue Aug 06 17:41:19 2019 +0200
@@ -47,6 +47,7 @@
     drop_attribute(etype, 'end_date')
 
 add_relation_definition('NameEntry', 'date_relation', 'DateEntity')
+add_relation_definition('Structure', 'has_citation', 'Citation')
 
 for etype in ('GeneralContext', 'Mandate', 'Occupation', 'History',
               'AgentFunction', 'LegalStatus', 'AgentPlace', 'Structure'):
diff -r 525d1933c0b0 -r 31c5c8e8a1d9 cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Wed Sep 04 17:34:43 2019 +0200
+++ b/cubicweb_eac/schema.py	Tue Aug 06 17:41:19 2019 +0200
@@ -456,7 +456,8 @@
 
 class has_citation(RelationDefinition):
     subject = ('GeneralContext', 'Mandate', 'Occupation', 'History',
-               'AgentFunction', 'LegalStatus', 'AgentPlace', 'Convention')
+               'AgentFunction', 'LegalStatus', 'AgentPlace', 'Convention',
+               'Structure')
     object = 'Citation'
     cardinality = '*1'
     composite = 'subject'
diff -r 525d1933c0b0 -r 31c5c8e8a1d9 test/data/FRAD033_EAC_00001_simplified.xml
--- a/test/data/FRAD033_EAC_00001_simplified.xml	Wed Sep 04 17:34:43 2019 +0200
+++ b/test/data/FRAD033_EAC_00001_simplified.xml	Tue Aug 06 17:41:19 2019 +0200
@@ -241,7 +241,12 @@
         </occupation>
       </occupations>
 
-      <structureOrGenealogy><p>Pour accomplir ses missions ...</p></structureOrGenealogy>
+      <structureOrGenealogy><p>Pour accomplir ses missions ...</p>
+      <citation>L'élément Citation à fournir un lien vers un document externe comme un
+               organigramme ou un arbre généalogique. Pour une présentation plus simple, sous forme
+               de texte, on peut utiliser un ou plusieurs élém.
+      </citation>
+    </structureOrGenealogy>
 
       <!--empty structureOrGenealogy-->
       <structureOrGenealogy></structureOrGenealogy>
diff -r 525d1933c0b0 -r 31c5c8e8a1d9 test/test_dataimport.py
--- a/test/test_dataimport.py	Wed Sep 04 17:34:43 2019 +0200
+++ b/test/test_dataimport.py	Tue Aug 06 17:41:19 2019 +0200
@@ -356,9 +356,17 @@
                                   u'xmlns:xlink="http://www.w3.org/1999/xlink">Pour accomplir '
                                   u'ses missions ...</p>']),
               'description_format': set([u'text/html']),
+              'has_citation': set(['40']),
               'structure_agent': set(['authorityrecord-FRAD033_EAC_00001']),
               },
              ),
+            ('Citation', _gen_extid(),
+             {'note': set([u"L'\xe9l\xe9ment Citation \xe0 fournir un lien vers un document "
+                           u"externe comme un\n               organigramme ou un arbre "
+                           u"g\xe9n\xe9alogique. Pour une pr\xe9sentation plus simple, "
+                           u"sous forme\n               de texte, on peut utiliser un "
+                           u"ou plusieurs \xe9l\xe9m."])},
+             ),
             ('AgentFunction', _gen_extid(),
              {'description': set([u'<p xmlns="urn:isbn:1-931666-33-4" '
                                   u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
@@ -390,11 +398,11 @@
              ),
             ('Occupation', _gen_extid(),
              {'term': set([u'Réunioniste']),
-              'date_relation': set(['44']),
+              'date_relation': set(['45']),
               'description': set([u'Organisation des réunions ...']),
               'description_format': set([u'text/plain']),
               'occupation_agent': set(['authorityrecord-FRAD033_EAC_00001']),
-              'has_citation': set(['45']),
+              'has_citation': set(['46']),
               'equivalent_concept': set(['http://pifgadget.com']),
               },
              ),
@@ -412,7 +420,7 @@
                               u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                               u'xmlns:xlink="http://www.w3.org/1999/xlink">very famous</p>']),
               'content_format': set([u'text/html']),
-              'has_citation': set(['47']),
+              'has_citation': set(['48']),
               'general_context_of': set(['authorityrecord-FRAD033_EAC_00001']),
               }
              ),
@@ -428,7 +436,7 @@
             ('HierarchicalRelation', _gen_extid(),
              {'entry': set([u"Gironde. Conseil général. Direction de l'administration et de "
                             u"la sécurité juridique"]),
-              'date_relation': set(['49']),
+              'date_relation': set(['50']),
               'description': set([u'Coucou']),
               'description_format': set([u'text/plain']),
               'hierarchical_parent': set(['CG33-DIRADSJ']),
@@ -453,7 +461,7 @@
             ('ChronologicalRelation', _gen_extid(),
              {'chronological_predecessor': set(['whatever']),
               'chronological_successor': set(['authorityrecord-FRAD033_EAC_00001']),
-              'date_relation': set(['51']),
+              'date_relation': set(['52']),
               'entry': set([u'CG32']),
               },
              ),
@@ -465,7 +473,7 @@
             ('ChronologicalRelation', _gen_extid(),
              {'chronological_predecessor': set(['authorityrecord-FRAD033_EAC_00001']),
               'chronological_successor': set(['/dev/null']),
-              'date_relation': set(['53']),
+              'date_relation': set(['54']),
               'xml_wrap': set(['<gloups xmlns="urn:isbn:1-931666-33-4"'
                                u' xmlns:xsi="http://www.w3.org/2001/XML'
                                u'Schema-instance" xmlns:xlink="http://'
@@ -478,7 +486,7 @@
               },
              ),
             ('IdentityRelation', _gen_extid(),
-             {'date_relation': ['55'],
+             {'date_relation': ['56'],
               'entry': [u'Trash'],
               'identity_from': ['authorityrecord-FRAD033_EAC_00001'],
               'identity_to': ['/dev/null'],
@@ -490,7 +498,7 @@
              {'start_date': [datetime.date(2042, 1, 1)]}
              ),
             ('FamilyRelation', _gen_extid(),
-             {'date_relation': ['57'],
+             {'date_relation': ['58'],
               'entry': [u'CG32'],
               'family_from': ['authorityrecord-FRAD033_EAC_00001'],
               'family_to': ['whatever']}
@@ -506,7 +514,7 @@
              ),
             ('EACResourceRelation', _gen_extid(),
              {'agent_role': set([u'creatorOf']),
-              'date_relation': set(['60']),
+              'date_relation': set(['61']),
               'xml_attributes': set([u'{"{http://www.w3.org/1999/xlink}actuate": "onRequest", '
                                      u'"{http://www.w3.org/1999/xlink}show": "new", '
                                      u'"{http://www.w3.org/1999/xlink}type": "simple"}']),
@@ -568,7 +576,7 @@
                                   'and abolishment of schools.\n\t  </p>']),
               'r_type': set([u'controls']),
               'description_format': set([u'text/html']),
-              'date_relation': set(['63']),
+              'date_relation': set(['64']),
               'relation_entry': set([u'Establishment and abolishment\n\tof schools\n\t']),
               'xml_attributes': set([u'{}'])
               },
@@ -589,7 +597,7 @@
               'description_format': set([u'text/html']),
               'relation_entry': set([u'Some relation entry\n          ']),
               'xml_attributes': set([u'{}']),
-              'date_relation': ['65'],
+              'date_relation': ['66'],
               },
              ),
             ('DateEntity', _gen_extid(),
@@ -608,7 +616,7 @@
               'description_format': set([u'text/html']),
               'relation_entry': set([u'Some relation entry\n          ']),
               'xml_attributes': set([u'{}']),
-              'date_relation': ['67'],
+              'date_relation': ['68'],
               },
              ),
             ('DateEntity', _gen_extid(),
@@ -685,8 +693,8 @@
                           'languageUsed': set([172, 179]),
                           'localControl': set([54]),
                           'source': set([76]),  # empty.
-                          'structureOrGenealogy': set([247]),  # empty.
-                          'biogHist': set([307, 310]),  # empty.
+                          'structureOrGenealogy': set([252]),  # empty.
+                          'biogHist': set([312, 315]),  # empty.
                           })
 
     def check_order_entities(self, entities, expected):
@@ -820,7 +828,7 @@
                                cwuri=u'http://data.culture.fr/thesaurus/page/ark:/67717/T1-1074')
             cnx.commit()
             created, updated = testutils.eac_import(cnx, fpath)
-            self.assertEqual(len(created), 77)
+            self.assertEqual(len(created), 78)
             self.assertEqual(updated, set())
             rset = cnx.find('AuthorityRecord', isni=u'22330001300016')
             self.assertEqual(len(rset), 1)
diff -r 525d1933c0b0 -r 31c5c8e8a1d9 test/test_schema.py
--- a/test/test_schema.py	Wed Sep 04 17:34:43 2019 +0200
+++ b/test/test_schema.py	Tue Aug 06 17:41:19 2019 +0200
@@ -102,6 +102,7 @@
             'Citation': {('has_citation', 'object'): set([
                 'GeneralContext', 'Mandate', 'Occupation', 'AgentFunction',
                 'AgentPlace', 'History', 'LegalStatus', 'Convention',
+                'Structure'
             ])},
             'DateEntity': {('date_relation', 'object'): set([
                 'HistoricalEvent', 'AgentFunction', 'EACFunctionRelation',


More information about the saem-devel mailing list