[PATCH saem_ref V2] [entities/eac] export ark as recordId

Sylvain Thénault sylvain.thenault at logilab.fr
Wed Mar 1 12:41:35 CET 2017


applied with requirement on seda droped since relevant cset has been
integrate


Le 28/02/2017 à 11:33, Philippe Pepiot a écrit :
> # HG changeset patch
> # User Philippe Pepiot <philippe.pepiot at logilab.fr>
> # Date 1488275369 -3600
> #      Tue Feb 28 10:49:29 2017 +0100
> # Node ID bad77a138b241a146836a1022689ecea56d1815d
> # Parent  652a2d37a30916d7a4c52716220679a4f5eeab7a
> # Available At https://hg.logilab.org/review/cubes/saem_ref
> #              hg pull https://hg.logilab.org/review/cubes/saem_ref -r bad77a138b24
> # Tested at: https://jenkins.logilab.org/job/cubicweb-saem_ref/110/
> [entities/eac] export ark as recordId
>
> Export ark as <recordId> and add eventually imported record_id to
> <otherRecordId>.
>
> Closes extranet #12572781
>
> diff --git a/cubicweb_saem_ref/entities/eac.py b/cubicweb_saem_ref/entities/eac.py
> --- a/cubicweb_saem_ref/entities/eac.py
> +++ b/cubicweb_saem_ref/entities/eac.py
> @@ -47,6 +47,20 @@ class AuthorityRecordEACAdapter(eac.Auth
>              return u'EAC_{0}.xml'.format(name)
>          return super(AuthorityRecordEACAdapter, self).file_name
>  
> +    def recordid_element(self, control_elt):
> +        # export ark in <recordId>
> +        self.element('recordId', parent=control_elt, text=self.entity.ark)
> +        record_id = self.entity.record_id
> +        if record_id:
> +            # export original <recordId> to <otherRecordId>
> +            self.element('otherRecordId', parent=control_elt, text=record_id)
> +        for local_type, value in self.entity.other_record_ids:
> +            attrs = {}
> +            if local_type is not None:
> +                attrs['localType'] = local_type
> +            self.element('otherRecordId', parent=control_elt, attributes=attrs,
> +                         text=value)
> +
>      def publication_status_element(self, control_elt):
>          status = {'draft': 'inProcess', 'published': 'approved'}.get(
>              self.entity.cw_adapt_to('IWorkflowable').state, 'inProcess')
> diff --git a/dev-requirements.txt b/dev-requirements.txt
> --- a/dev-requirements.txt
> +++ b/dev-requirements.txt
> @@ -1,7 +1,7 @@
>  pytest
>  webtest
>  http://hg.logilab.org/master/cubes/prov/archive/tip.tar.bz2#egg=cubicweb-prov
> -http://hg.logilab.org/master/cubes/eac/archive/tip.tar.bz2#egg=cubicweb-eac
> +http://hg.logilab.org/review/cubes/eac/archive/4b54485.tar.bz2#egg=cubicweb-eac
>  http://hg.logilab.org/master/cubes/seda/archive/tip.tar.bz2#egg=cubicweb-seda
>  http://hg.logilab.org/master/cubes/relationwidget/archive/tip.tar.bz2#egg=cubicweb-relationwidget
>  http://hg.logilab.org/review/cubes/compound/archive/03180a8d8475.tar.bz2#egg=cubicweb-compound
> diff --git a/test/test_eac.py b/test/test_eac.py
> --- a/test/test_eac.py
> +++ b/test/test_eac.py
> @@ -33,6 +33,19 @@ class EACExportTC(CubicWebTC):
>              self.assertIn('<agent>admin</agent>', eac_xml)
>              self.assertIn('<agent>007</agent>', eac_xml)
>  
> +    def test_export_record_id(self):
> +        with self.admin_access.cnx() as cnx:
> +            record = testutils.authority_record(cnx, u'My record',
> +                                                record_id=u'My RID')
> +            cnx.create_entity('EACOtherRecordId', value=u'Other RID',
> +                              eac_other_record_id_of=record)
> +            cnx.commit()
> +            record = cnx.entity_from_eid(record.eid)
> +            xml = record.cw_adapt_to('EAC-CPF').dump()
> +            self.assertIn('<recordId>{0}</recordId>'.format(record.ark), xml)
> +            self.assertIn('<otherRecordId>My RID</otherRecordId>', xml)
> +            self.assertIn('<otherRecordId>Other RID</otherRecordId>', xml)
> +
>  
>  if __name__ == '__main__':
>      import unittest
>

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list