From 348ac09806bfe3fbaea05e017fa376fcd32488fd Mon Sep 17 00:00:00 2001 From: Peter Weber Date: Tue, 5 Sep 2023 08:01:37 +0200 Subject: [PATCH] entity: better replace identifiedBy Co-Authored-by: Peter Weber --- rero_ils/modules/entities/api.py | 13 ++++++++----- rero_ils/modules/entities/replace.py | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rero_ils/modules/entities/api.py b/rero_ils/modules/entities/api.py index 48f9f37185..cdd5557f40 100644 --- a/rero_ils/modules/entities/api.py +++ b/rero_ils/modules/entities/api.py @@ -112,11 +112,14 @@ def get_record_by_ref(cls, ref): pid=ref_pid )): raise Exception('NO DATA') - # Try to get the contribution from DB maybe it was not indexed. - if entity := Entity.get_record_by_pid(data['pid']): - entity = entity.replace(data) - else: - entity = cls.create(data) + # Try to get the contribution from DB. + entity = Entity.get_record_by_pid(data['pid']) + if entity: + # TODO: find a way to safely update the old entity + raise Exception( + f'OLD DATA: MEF({data["pid"]}) DB({entity.pid})' + ) + entity = cls.create(data) online = True nested.commit() # TODO: reindex in the document indexing diff --git a/rero_ils/modules/entities/replace.py b/rero_ils/modules/entities/replace.py index 9567db57f5..200bd370d0 100644 --- a/rero_ils/modules/entities/replace.py +++ b/rero_ils/modules/entities/replace.py @@ -202,7 +202,7 @@ def _do_entity(self, entity, doc_pid): source, {}).get('authorized_access_point') info = f'{doc_entity_type}: {authorized_access_point}' self.rero_only[identifier] = info - self.logger.warning( + self.logger.info( f'No other source found for document:{doc_pid} ' f'{self.field} - ({mef_type}) {identifier} "{info}"' ) @@ -211,7 +211,7 @@ def _do_entity(self, entity, doc_pid): 'entity']['authorized_access_point'] info = f'{doc_entity_type}: {authorized_access_point}' self.not_found[identifier] = info - self.logger.warning( + self.logger.info( f'No MEF found for document:{doc_pid} ' f'{self.parent} - ({mef_type}) {identifier} "{info}"' )