Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
Merge Aggregation into Record
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 25, 2024
1 parent ccbe41e commit 1bc07b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 51 deletions.
24 changes: 1 addition & 23 deletions app/records/schemas/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] = []
Expand Down
35 changes: 7 additions & 28 deletions app/sources/rosetta/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from app.lib.api import GetAPI
from app.records.schemas import (
Aggregation,
Record,
RecordArchive,
RecordCreator,
Expand Down Expand Up @@ -152,37 +151,17 @@ 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()
record.former_ref = parsed_data.former_identifier()
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()
Expand All @@ -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 = (
Expand Down

0 comments on commit 1bc07b7

Please sign in to comment.