[PATCH eac] Add support for a date child for NameEntry entity

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Tue Aug 27 10:14:41 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1563895901 -7200
#      Tue Jul 23 17:31:41 2019 +0200
# Node ID 67ecf498201c1998cb49e179a8b965731c54f167
# Parent  4cf1a36772e0a3b90708c9df87e69fc69454c5f3
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 67ecf498201c
Add support for a date child for NameEntry entity

diff -r 4cf1a36772e0 -r 67ecf498201c cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Tue Aug 20 10:49:06 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Tue Jul 23 17:31:41 2019 +0200
@@ -446,7 +446,8 @@
         if not name_entries:
             raise MissingTag('nameEntry', 'identity')
         for name_entry in name_entries:
-            yield self.build_name_entry(name_entry)
+            for extentity in self.build_name_entry(name_entry):
+                yield extentity
         parallel_name_entries = self._elem_findall(identity, 'eac:nameEntryParallel')
         for parallel_name_entry in parallel_name_entries:
             for extentity in self.build_parallel(parallel_name_entry):
@@ -598,6 +599,7 @@
         return desc, desc_format
 
     @relate_to_record_through('NameEntry', 'name_entry_for')
+    @add_dates_for('NameEntry')
     def build_name_entry(self, element):
         """Build a NameEntry external entity."""
         self.record_visited(element, self.record)
@@ -613,7 +615,7 @@
             values['form_variant'] = set([u'authorized'])
         elif self._elem_find(element, 'eac:alternativeForm') is not None:
             values['form_variant'] = set([u'alternative'])
-        return ExtEntity('NameEntry', self._gen_extid(), values)
+        yield ExtEntity('NameEntry', self._gen_extid(), values)
 
     @elem_maybe_none
     def build_agent_kind(self, elem):
diff -r 4cf1a36772e0 -r 67ecf498201c cubicweb_eac/entities.py
--- a/cubicweb_eac/entities.py	Tue Aug 20 10:49:06 2019 +0200
+++ b/cubicweb_eac/entities.py	Tue Jul 23 17:31:41 2019 +0200
@@ -235,7 +235,7 @@
     fetch_attrs, cw_fetch_order = fetch_config(('event',))
 
 
-class NameEntry(AnyEntity):
+class NameEntry(DateRelationMixin, AnyEntity):
     __regid__ = 'NameEntry'
     fetch_attrs, cw_fetch_order = fetch_config(('language',
                                                 'preferred_form',
diff -r 4cf1a36772e0 -r 67ecf498201c cubicweb_eac/migration/0.9.0_Any.py
--- a/cubicweb_eac/migration/0.9.0_Any.py	Tue Aug 20 10:49:06 2019 +0200
+++ b/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 23 17:31:41 2019 +0200
@@ -44,6 +44,8 @@
     drop_attribute(etype, 'start_date')
     drop_attribute(etype, 'end_date')
 
+add_relation_definition('NameEntry', 'date_relation', 'DateEntity')
+
 for etype in ('GeneralContext', 'Mandate', 'Occupation', 'History',
               'AgentFunction', 'LegalStatus', 'AgentPlace', 'Structure'):
     add_attribute(etype, 'items')
diff -r 4cf1a36772e0 -r 67ecf498201c cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Tue Aug 20 10:49:06 2019 +0200
+++ b/cubicweb_eac/schema.py	Tue Jul 23 17:31:41 2019 +0200
@@ -113,7 +113,8 @@
     subject = ('ParallelNames', 'HierarchicalRelation', 'HistoricalEvent',
                'ChronologicalRelation', 'AssociationRelation',
                'AgentFunction', 'EACFunctionRelation', 'LegalStatus',
-               'Mandate', 'Occupation', 'AgentPlace', 'EACResourceRelation')
+               'Mandate', 'Occupation', 'AgentPlace', 'EACResourceRelation',
+               'NameEntry')
     object = 'DateEntity'
     cardinality = '*1'
     composite = 'subject'
diff -r 4cf1a36772e0 -r 67ecf498201c test/test_schema.py
--- a/test/test_schema.py	Tue Aug 20 10:49:06 2019 +0200
+++ b/test/test_schema.py	Tue Jul 23 17:31:41 2019 +0200
@@ -105,8 +105,8 @@
             ])},
             'DateEntity': {('date_relation', 'object'): set([
                 'HistoricalEvent', 'AgentFunction', 'EACFunctionRelation',
-                'LegalStatus', 'Mandate', 'Occupation', 'AgentPlace', 'EACResourceRelation',
-                'ParallelNames'
+                'LegalStatus', 'Mandate', 'NameEntry', 'Occupation', 'AgentPlace',
+                'EACResourceRelation', 'ParallelNames'
             ])},
             'PlaceEntry': {('place_entry_relation', 'object'): set([
                 'HistoricalEvent', 'AgentFunction', 'EACFunctionRelation',



More information about the saem-devel mailing list