From 1bc07b79fb67e6e76d28bfe0e737c92521313847 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Thu, 25 Jan 2024 10:30:44 +0000 Subject: [PATCH] Merge Aggregation into Record --- app/records/schemas/details.py | 24 +---------------------- app/sources/rosetta/api.py | 35 +++++++--------------------------- 2 files changed, 8 insertions(+), 51 deletions(-) diff --git a/app/records/schemas/details.py b/app/records/schemas/details.py index 1e797e0..ffc3a7c 100644 --- a/app/records/schemas/details.py +++ b/app/records/schemas/details.py @@ -23,28 +23,6 @@ class Record(Details): title: str | None = None summary_title: str | None = None description: str | None = None - date: str | None = None - is_digitised: bool | None = None - held_by: dict = {} - legal_status: str | None = None - closure_status: str | None = None - access_condition: str | None = None - notes: list[str] = [] - languages: list[str] = [] - related_materials: list[dict] = [] - hierarchy: list[dict] = [] - - def __init__(self, id: str): - super().__init__(id) - - -class Aggregation(Details): - type: str = "aggregation" - ref: str | None = None - iaid: str | None = None - title: str | None = None - summary_title: str | None = None - description: str | None = None physical_description: str | None = None administrative_background: str | None = None arrangement: str | None = None @@ -53,11 +31,11 @@ class Aggregation(Details): held_by: dict = {} creators: list[dict] = [] acquisition: list[dict] = [] - unpublished_finding_aids: str | None = None legal_status: str | None = None closure_status: str | None = None access_condition: str | None = None notes: list[str] = [] + unpublished_finding_aids: str | None = None languages: list[str] = [] related_materials: list[dict] = [] hierarchy: list[dict] = [] diff --git a/app/sources/rosetta/api.py b/app/sources/rosetta/api.py index 94defba..8f79617 100644 --- a/app/sources/rosetta/api.py +++ b/app/sources/rosetta/api.py @@ -1,6 +1,5 @@ from app.lib.api import GetAPI from app.records.schemas import ( - Aggregation, Record, RecordArchive, RecordCreator, @@ -152,7 +151,10 @@ def get_result(self, id: str) -> dict: def parse_results(self, raw_results, source_url): parsed_data = RosettaResponseParser(raw_results) - if parsed_data.type() == "record": + if ( + parsed_data.type() == "record" + or parsed_data.type() == "aggregation" + ): record = Record(parsed_data.id()) record.ref = parsed_data.identifier() record.iaid = parsed_data.iaid() @@ -160,29 +162,6 @@ def parse_results(self, raw_results, source_url): record.title = parsed_data.title() record.summary_title = parsed_data.summary_title() record.description = parsed_data.description() - record.date = parsed_data.date_range() - record.is_digitised = parsed_data.is_digitised() - record.held_by = parsed_data.held_by() - record.legal_status = parsed_data.legal_status() - record.closure_status = parsed_data.closure_status() - record.access_condition = parsed_data.access_condition() - record.notes = parsed_data.notes() - record.languages = parsed_data.languages() - record.related_materials = parsed_data.related_materials() - record.hierarchy = ( - parsed_data.hierarchies()[0] - if len(parsed_data.hierarchies()) - else [] - ) - record.source_url = source_url - return record.toJSON() - if parsed_data.type() == "aggregation": - record = Aggregation(parsed_data.id()) - record.ref = parsed_data.identifier() - record.iaid = parsed_data.iaid() - record.title = parsed_data.title() - record.summary_title = parsed_data.summary_title() - record.description = parsed_data.description() record.physical_description = parsed_data.physical_description() record.administrative_background = ( parsed_data.administrative_background() @@ -193,13 +172,13 @@ def parse_results(self, raw_results, source_url): record.held_by = parsed_data.held_by() record.creators = parsed_data.creators() record.acquisition = parsed_data.acquisition() - record.unpublished_finding_aids = ( - parsed_data.unpublished_finding_aids() - ) record.legal_status = parsed_data.legal_status() record.closure_status = parsed_data.closure_status() record.access_condition = parsed_data.access_condition() record.notes = parsed_data.notes() + record.unpublished_finding_aids = ( + parsed_data.unpublished_finding_aids() + ) record.languages = parsed_data.languages() record.related_materials = parsed_data.related_materials() record.hierarchy = (