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 12, 2023
1 parent 770dc5e commit 75d8d4e
Showing 1 changed file with 37 additions and 22 deletions.
59 changes: 37 additions & 22 deletions rero_ils/modules/entities/remote_entities/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,31 +177,46 @@ def _do_entity(self, entity, doc_pid):
new_source, new_source_pid = self._find_other_source(
source, source_pid, mef_data)
if new_source:
self._create_entity(mef_type, mef_data)
authorized_access_point = entity[
"entity"]["authorized_access_point"]
mef_authorized_access_point = mef_data[
new_source]["authorized_access_point"]
self.logger.info(
f'Replace document:{doc_pid} '
f'{self.field} "{authorized_access_point}" - '
f'({mef_type}) {new_source}:{new_source_pid} '
f'"{mef_authorized_access_point}"'
)
entity['entity'] = {
'$ref': (
f'{self._get_base_url(mef_type)}'
f'/{new_source}/{new_source_pid}'
),
'pid': mef_data['pid']
}
changed = True
mef_entity_type = mef_data.get('type')
# verify local and MEF type are the same
if mef_entity_type == doc_entity_type:
self._create_entity(mef_type, mef_data)
authorized_access_point = entity[
"entity"]["authorized_access_point"]
mef_authorized_access_point = mef_data[
new_source]["authorized_access_point"]
self.logger.info(
f'Replace document:{doc_pid} '
f'{self.field} "{authorized_access_point}" - '
f'({mef_type}) {new_source}:{new_source_pid} '
f'"{mef_authorized_access_point}"'
)
entity['entity'] = {
'$ref': (
f'{self._get_base_url(mef_type)}'
f'/{new_source}/{new_source_pid}'
),
'pid': mef_data['pid']
}
changed = True
else:
authorized_access_point = mef_data.get(
source, {}).get('authorized_access_point')
info = (
f'{doc_entity_type} != {mef_entity_type} '
f': {authorized_access_point}'
)
self.rero_only[identifier] = info
self.logger.warning(
f'Type differ:{doc_pid} '
f'{self.field} - ({mef_type}) {identifier} "{info}"'
)
else:
authorized_access_point = mef_data.get(
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 @@ -210,9 +225,9 @@ 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}"'
f' - ({mef_type}) {identifier} "{info}"'
)
return changed

Expand Down

0 comments on commit 75d8d4e

Please sign in to comment.