[PATCH eac V2] Add new `agent_type` attribute for Activity entity

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Wed Aug 28 12:08:50 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1563887776 -7200
#      Tue Jul 23 15:16:16 2019 +0200
# Node ID 28f9f5cdef3425752fd7548496acce55b973b0f5
# Parent  67ecf498201c1998cb49e179a8b965731c54f167
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 28f9f5cdef34
Add new `agent_type` attribute for Activity entity

diff -r 67ecf498201c -r 28f9f5cdef34 cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Tue Jul 23 17:31:41 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Tue Jul 23 15:16:16 2019 +0200
@@ -1067,9 +1067,8 @@
                     values['start'] = set([event_date])
                     values['end'] = set([event_date])
         values.update(self.parse_tag_description(elem, 'eac:eventDescription'))
-        agent = self._elem_find(elem, 'eac:agent')
-        if agent is not None and agent.text:
-            values['agent'] = set([text_type(agent.text)])
+        values.update(self.values_from_xpaths(elem, (('agent', 'eac:agent'),
+                                                     ('agent_type', 'eac:agentType'))))
         yield ExtEntity('Activity', self._gen_extid(), values)
 
     @relate_to_record_through('Convention', 'convention_of')
diff -r 67ecf498201c -r 28f9f5cdef34 cubicweb_eac/migration/0.9.0_Any.py
--- a/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 23 17:31:41 2019 +0200
+++ b/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 23 15:16:16 2019 +0200
@@ -51,3 +51,5 @@
     add_attribute(etype, 'items')
     
 add_relation_type('place_entry_relation')
+
+add_attribute('Activity', 'agent_type')
diff -r 67ecf498201c -r 28f9f5cdef34 cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Tue Jul 23 17:31:41 2019 +0200
+++ b/cubicweb_eac/schema.py	Tue Jul 23 15:16:16 2019 +0200
@@ -47,6 +47,10 @@
 
 Activity.add_relation(String(description=_('the agent responsible for this activity'),
                              indexed=True, fulltextindexed=True), name='agent')
+Activity.add_relation(String(
+    vocabulary=[_('human'), _('machine'), _('unknown')],
+    description=_('the type of the agent linked to the activity'),
+    indexed=True, fulltextindexed=True), name='agent_type')
 
 
 class AuthorityRecord(EntityType):
diff -r 67ecf498201c -r 28f9f5cdef34 test/test_dataimport.py
--- a/test/test_dataimport.py	Tue Jul 23 17:31:41 2019 +0200
+++ b/test/test_dataimport.py	Tue Jul 23 15:16:16 2019 +0200
@@ -120,6 +120,7 @@
              ),
             ('Activity', _gen_extid(),
              {'type': set([u'create']),
+              'agent_type': [u'human'],
               'generated': set(['FRAD033_EAC_00001']),
               'start': set([datetime.datetime(2013, 4, 24, 5, 34, 41)]),
               'end': set([datetime.datetime(2013, 4, 24, 5, 34, 41)]),
@@ -130,6 +131,7 @@
             ('Activity', _gen_extid(),
              {'generated': set(['FRAD033_EAC_00001']),
               'type': set([u'modify']),
+              'agent_type': [u'human'],
               'start': set([datetime.datetime(2015, 1, 15, 7, 16, 33)]),
               'end': set([datetime.datetime(2015, 1, 15, 7, 16, 33)]),
               'agent': set([u'Delphine Jamet'])



More information about the saem-devel mailing list