Skip to content

Commit

Permalink
entity: better replace identifiedBy
Browse files Browse the repository at this point in the history
Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep committed Sep 6, 2023
1 parent 56e9ca4 commit 348ac09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions rero_ils/modules/entities/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rero_ils/modules/entities/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"'
)
Expand All @@ -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}"'
)
Expand Down

0 comments on commit 348ac09

Please sign in to comment.