diff --git a/merger/mergers.py b/merger/mergers.py index c3059996..3847d157 100644 --- a/merger/mergers.py +++ b/merger/mergers.py @@ -1,5 +1,7 @@ from requests.exceptions import ConnectionError +from pisces import settings + from .helpers import (ArchivesSpaceHelper, MissingArchivalObjectError, add_group, closest_creators, closest_parent_value, combine_references, handle_cartographer_reference, @@ -202,7 +204,7 @@ def get_archivesspace_data(self, object, object_type): if not object.get("extents"): extent_data = self.parse_instances(object["instances"]) if object_type == "archival_object_collection" and not extent_data: - extent_data = closest_parent_value(object, "extents") + extent_data = settings.INHERIT_EXTENT and [{'value': None, "type": None}] or closest_parent_value(object, "extents") data["extents"] = extent_data if object_type == "archival_object_collection": data["linked_agents"] = closest_creators(object) diff --git a/pisces/config.py.deploy b/pisces/config.py.deploy index 1b8e4539..43b360d9 100644 --- a/pisces/config.py.deploy +++ b/pisces/config.py.deploy @@ -41,3 +41,4 @@ TERM_SCHEMA = "${TERM_SCHEMA}" NOTIFY_EMAIL = ${NOTIFY_EMAIL} NOTIFY_TEAMS = ${NOTIFY_TEAMS} TEAMS_URL = "${TEAMS_URL}" +INHERIT_EXTENT = ${INHERIT_EXTENT} diff --git a/pisces/config.py.example b/pisces/config.py.example index fcf26c78..b7062e68 100644 --- a/pisces/config.py.example +++ b/pisces/config.py.example @@ -41,3 +41,4 @@ TERM_SCHEMA = "term.json" # Filename for schema against which transformed terms NOTIFY_EMAIL = True # deliver error messages via email (boolean) NOTIFY_TEAMS = False # deliver error message via Microsoft Teams (boolean) TEAMS_URL = "https://teams-url.com" # URL for Incoming Webhook Connector in Microsoft Teams Channel +INHERIT_EXTENT = True # Configure whether extents are inherited down a collection hierarchy (boolean) diff --git a/pisces/settings.py b/pisces/settings.py index 8d35b292..c97aa0a2 100644 --- a/pisces/settings.py +++ b/pisces/settings.py @@ -207,3 +207,5 @@ MANIFEST_BASEURL = config.MANIFEST_BASEURL DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' +# Data attribute inheritance configuration +INHERIT_EXTENT = config.INHERIT_EXTENT diff --git a/transformer/resources/rac.py b/transformer/resources/rac.py index 9750cf02..1e29f804 100644 --- a/transformer/resources/rac.py +++ b/transformer/resources/rac.py @@ -67,8 +67,8 @@ class Date(odin.Resource): class Extent(odin.Resource): """Records the size of an aggregation of archival records.""" - value = odin.StringField() - type = odin.StringField() + value = odin.StringField(null=True) + type = odin.StringField(null=True) class FileObject(odin.Resource): @@ -147,7 +147,7 @@ class Object(BaseResource): category = odin.StringField(default="collection") dates = odin.ArrayOf(Date) languages = odin.ArrayOf(Language) - extents = odin.ArrayOf(Extent) + extents = odin.ArrayOf(Extent, null=True) notes = odin.ArrayOf(Note) people = odin.ArrayOf(AgentReference) organizations = odin.ArrayOf(AgentReference) diff --git a/transformer/resources/source.py b/transformer/resources/source.py index d59c1f50..ee5a5c3f 100644 --- a/transformer/resources/source.py +++ b/transformer/resources/source.py @@ -73,10 +73,10 @@ class SourceDigitalObject(odin.Resource): class SourceExtent(odin.Resource): """Records the size of an aggregation of archival records.""" - number = odin.StringField() + number = odin.StringField(null=True) container_summary = odin.StringField(null=True) portion = odin.StringField(choices=(('whole', 'Whole'), ('part', 'Part'))), - extent_type = odin.StringField() + extent_type = odin.StringField(null=True) class SourceExternalId(odin.Resource): @@ -224,7 +224,7 @@ class Meta: ) dates = odin.ArrayOf(SourceDate) - extents = odin.ArrayOf(SourceExtent) + extents = odin.ArrayOf(SourceExtent, null=True) external_ids = odin.ArrayOf(SourceExternalId) group = odin.DictAs(SourceGroup) jsonmodel_type = odin.StringField(choices=COMPONENT_TYPES)