Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingest aliases #1703

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions peachjam/adapters/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from languages_plus.models import Language

from peachjam.models import (
AlternativeName,
Author,
CoreDocument,
DocumentNature,
Expand Down Expand Up @@ -344,6 +345,8 @@ def update_document(self, url):
)
logger.info(f"Added {len(taxonomies)} taxonomies to {created_doc}")

# fetch associated aliases
self.fetch_and_create_aliases(document, created_doc)
self.set_parent(document, created_doc)
self.fetch_relationships(document, created_doc)
self.download_and_save_document_images(document, created_doc)
Expand Down Expand Up @@ -539,3 +542,14 @@ def delete_document(self, expression_frbr_uri):
document.delete()
else:
raise e

def fetch_and_create_aliases(self, document, created_document):
aliases = document.get("aliases", [])
if aliases:
# delete all existing alternative names/aliases for doc
AlternativeName.objects.filter(document=created_document).delete()

for alias in aliases:
AlternativeName.objects.create(document=created_document, title=alias)

logger.info(f"Fetching of aliases for {created_document} is complete!")
Loading