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

Philippe Pepiot philippe.pepiot at logilab.fr
Fri Feb 24 18:12:24 CET 2017


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1487956061 -3600
#      Fri Feb 24 18:07:41 2017 +0100
# Node ID ce9beb8c142f92166caea258be1f6db583b9d147
# Parent  6f995252d31dca54ae720cf4c0a13d5356215d85
# Available At https://hg.logilab.org/review/cubes/saem_ref
#              hg pull https://hg.logilab.org/review/cubes/saem_ref -r ce9beb8c142f
# Tested at: https://jenkins.logilab.org/job/cubicweb-saem_ref/106/
[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,19 @@ class AuthorityRecordEACAdapter(eac.Auth
             return u'EAC_{0}.xml'.format(name)
         return super(AuthorityRecordEACAdapter, self).file_name
 
+    @property
+    def record_id(self):
+        # set ark in <recordId>
+        return self.entity.ark
+
+    @property
+    def other_record_ids(self):
+        # prepend <otherRecordId> with imported record_id
+        record_ids = super(AuthorityRecordEACAdapter, self).other_record_ids
+        if self.entity.record_id:
+            record_ids.insert(0, (None, self.entity.record_id))
+        return record_ids
+
     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/8eea971.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



More information about the saem-devel mailing list