[PATCH 2 of 2 saem_ref V2] [hook] export EAC ARK on AuthorityRecordId

Sylvain Thénault sylvain.thenault at logilab.fr
Fri Feb 24 15:53:20 CET 2017



Le 24/02/2017 à 15:45, Philippe Pepiot a écrit :
> On 02/24/2017 03:37 PM, Philippe Pepiot wrote:
>> @@ -99,7 +104,21 @@ class EACImportService(eac.EACImportServ
>>                  extentity.values['authority'] =
>> set([self._authority.cwuri])
>>              return extentity
>>
>> -        return imap(set_authority_or_naa, extentities)
>> +        def move_record_id(extentities):
>> +            for extentity in extentities:
>> +                if (extentity.etype == 'AuthorityRecord'
>> +                        and 'record_id' in extentity.values):
>> +                    yield ExtEntity(etype='EACOtherRecordId',
>> +                                   
>> extid='EACOtherRecordId-{0}'.format(extentity.extid),
>> +                                    values={
>> +                                        'value':
>> extentity.values.pop('record_id'),
>> +                                        'eac_other_record_id_of':
>> set([extentity.extid]),
>> +                                    })
>> +                yield extentity
>> +
>> +        extentities = imap(set_authority_or_naa, extentities)
>> +        extentities = move_record_id(extentities)
>> +        return extentities
>>
>>
>>  class AllocateArk(Service):
>
>
> Not sure about extid for EACOtherRecordId here, in particular when
> updating an existing record... I'll make more tests.
>
IIRC, extentity.exitid is a random value for AuthorityRecord, so you
should be fine provided that you can't insert more than on other record
id in an import, and it doesn't conflict with ext id of other record id
imported from the file.
As those conditions are probably ok, you're probably fine. Probably :)

-- 
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