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

gvandevelde guillaume.vandevelde at logilab.fr
Wed Aug 28 11:35:54 CEST 2019


On 8/28/19 11:27 AM, Frank Bessou wrote:
>
>
> On 28/08/2019 11:23, gvandevelde wrote:
>>
>> On 8/28/19 10:58 AM, Frank Bessou wrote:
>>>
>>>
>>> On 28/08/2019 10:15, Guillaume Vandevelde wrote:
>>>> # HG changeset patch
>>>> # User Guillaume Vandevelde <gvandevelde at logilab.fr>
>>>> # Date 1563887776 -7200
>>>> #      Tue Jul 23 15:16:16 2019 +0200
>>>> # Node ID 999d2390ec6fefc19205dae04cfd7d9f2002319b
>>>> # Parent  67ecf498201c1998cb49e179a8b965731c54f167
>>>> # Available At http://hg.logilab.org/review/cubes/eac
>>>> #              hg pull http://hg.logilab.org/review/cubes/eac -r 
>>>> 999d2390ec6f
>>>> Add new `agent_type` attribute for Activity entity
>>>
>>> Activity is not an EAC tag ? I couldn't find it on 
>>> https://eac.staatsbibliothek-berlin.de/schema/taglibrary/cpfTagLibrary2018_EN.pdf 
>>>
>> Not, Activity is a cubicweb model used for the 
>> maintenanceHistory/maintenanceEvent tag
>>>>
>>>> diff -r 67ecf498201c -r 999d2390ec6f 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 999d2390ec6f 
>>>> 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 999d2390ec6f 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,8 @@
>>>>     Activity.add_relation(String(description=_('the agent 
>>>> responsible for this activity'),
>>>>                                indexed=True, fulltextindexed=True), 
>>>> name='agent')
>>>> +Activity.add_relation(String(description=_('the type of the agent 
>>>> linked to the activity'),
>>>> +                             indexed=True, fulltextindexed=True), 
>>>> name='agent_type')
>>>
>>> Shouldn't there be a vocabulary constraint for this attribute ?
>>>
>> Why a constraint should be needed ?
>
> From the EAC spec:
>
>
> For each maintenance event described in a<maintenanceEvent> element, 
> the type of agent given in the<agent> element must be given as 
> "human", "machine", or"unknown."
>
> Shouldn't we constrain agent_type value domain to be {'human', 
> 'machine', 'unknown'} ?
>
Yeah I'll do that, it's not really used right now but the database witll 
be more coherent with it
>>>>       class AuthorityRecord(EntityType):
>>>> diff -r 67ecf498201c -r 999d2390ec6f 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