[PATCH eac V5] Add some attribute to EACRessourceRelation

gvandevelde guillaume.vandevelde at logilab.fr
Mon Aug 12 14:21:12 CEST 2019


Bad command, this changeset is to be check as a V1.

On 8/12/19 2:16 PM, Guillaume Vandevelde wrote:
> # HG changeset patch
> # User Guillaume Vandevelde <gvandevelde at logilab.fr>
> # Date 1564500697 -7200
> #      Tue Jul 30 17:31:37 2019 +0200
> # Node ID d5d2f40e13f857cb7602d5bb0c14abdb3f7c15f5
> # Parent  7f368a4aff38e7c176c27d808a51d8be2d3b4c0b
> # Available At http://hg.logilab.org/review/cubes/eac
> #              hg pull http://hg.logilab.org/review/cubes/eac -r d5d2f40e13f8
> Add some attribute to EACRessourceRelation
>
> Add support for the <relationEntry> and xml attributes
> for EACResourceRelation
>
> diff -r 7f368a4aff38 -r d5d2f40e13f8 cubicweb_eac/dataimport.py
> --- a/cubicweb_eac/dataimport.py	Tue Jul 30 17:31:37 2019 +0200
> +++ b/cubicweb_eac/dataimport.py	Tue Jul 30 17:31:37 2019 +0200
> @@ -890,6 +890,9 @@
>               'resource_relation_resource': set([obj_uri]),
>               'resource_relation_agent': set([self.record.extid]),
>           }
> +        relation_entry = self._elem_find(elem, 'eac:relationEntry')
> +        if relation_entry is not None:
> +            values['relation_entry'] = set([text_type(relation_entry.text)])
>           resource_role = elem.attrib.get('{%(xlink)s}role' % self.namespaces)
>           if resource_role:
>               values['resource_role'] = set([text_type(resource_role)])
> @@ -900,6 +903,13 @@
>           if dates:
>               values.update(dates)
>           values.update(self.parse_tag_description(elem))
> +        attrib = {k: v for (k, v) in dict(elem.attrib).items() if k not in {
> +            'relationRelationType',
> +            '{%(xlink)s}role' % self.namespaces,
> +            '{%(xlink)s}href' % self.namespaces,
> +        }}
> +        if attrib:
> +            values.update({'attributes': set([text_type(attrib)])})
>           yield ExtEntity('EACResourceRelation', self._gen_extid(), values)
>   
>       @filter_none
> diff -r 7f368a4aff38 -r d5d2f40e13f8 cubicweb_eac/migration/0.9.0_Any.py
> --- a/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 30 17:31:37 2019 +0200
> +++ b/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 30 17:31:37 2019 +0200
> @@ -2,3 +2,5 @@
>   add_entity_type('HistoricalEvent')
>   add_entity_type('Convention')
>   add_entity_type('EACFunctionRelation')
> +add_attribute('EACResourceRelation', 'attributes')
> +add_attribute('EACResourceRelation', 'relation_entry')
> diff -r 7f368a4aff38 -r d5d2f40e13f8 cubicweb_eac/schema.py
> --- a/cubicweb_eac/schema.py	Tue Jul 30 17:31:37 2019 +0200
> +++ b/cubicweb_eac/schema.py	Tue Jul 30 17:31:37 2019 +0200
> @@ -404,11 +404,13 @@
>       """Represent a relation between an AuthorityRecord and a remote resource in the
>       EAC-CPF model.
>       """
> +    relation_entry = RichString(fulltextindexed=True)
>       agent_role = String(description=_('type of relation the agent has to the resource'),
>                           internationalizable=True)
>       resource_role = String(description=_('type or nature of the remote resource'),
>                              internationalizable=True)
>       description = RichString(fulltextindexed=True)
> +    attributes = String(fulltextindexed=True)
>   
>   
>   class resource_relation_agent(RelationDefinition):
> diff -r 7f368a4aff38 -r d5d2f40e13f8 test/data/FRAD033_EAC_00001_simplified.xml
> --- a/test/data/FRAD033_EAC_00001_simplified.xml	Tue Jul 30 17:31:37 2019 +0200
> +++ b/test/data/FRAD033_EAC_00001_simplified.xml	Tue Jul 30 17:31:37 2019 +0200
> @@ -269,6 +269,7 @@
>             <fromDate>1673</fromDate>
>             <toDate>1963</toDate>
>           </dateRange>
> +	<relationEntry>Gironde. Conseil général. Direction de l'administration et de la sécurité juridique</relationEntry>
>         </resourceRelation>
>         <functionRelation
>   	  functionRelationType="performs"
> diff -r 7f368a4aff38 -r d5d2f40e13f8 test/test_dataimport.py
> --- a/test/test_dataimport.py	Tue Jul 30 17:31:37 2019 +0200
> +++ b/test/test_dataimport.py	Tue Jul 30 17:31:37 2019 +0200
> @@ -381,6 +381,8 @@
>               ),
>               ('EACResourceRelation', _gen_extid(),
>                {'agent_role': set([u'creatorOf']),
> +              'attributes': set([u"{'{http://www.w3.org/1999/xlink}show': 'new', '{http://www.w3.org/1999/xlink}actuate': 'onRequest', '{http://www.w3.org/1999/xlink}type': 'simple', 'resourceRelationType': 'creatorOf'}"]), # noqa
> +              'relation_entry': set([u'Gironde. Conseil g\xe9n\xe9ral. Direction de l\'administration et de la s\xe9curit\xe9 juridique']),
>                 'resource_role': set([u'Fonds d\'archives']),
>                 'resource_relation_resource': set([
>                     'http://gael.gironde.fr/ead.html?id=FRAD033_IR_N']),
>



More information about the saem-devel mailing list