Skip to content

Commit

Permalink
Merge pull request #250 from RockefellerArchiveCenter/digital-object
Browse files Browse the repository at this point in the history
Update logic for digital object transformation
  • Loading branch information
helrond authored Aug 21, 2024
2 parents 87106d9 + 3b43b99 commit 6a3a2e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions transformer/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,6 @@ class SourcePackageToDigitalObject(odin.Mapping):
def extract_id(self, uri):
return uri.rstrip("/").split("/")[-1]

@odin.map_field(from_field="storage_uri", to_field="title")
def title(self, value):
return self.extract_id(value)

@odin.map_field(from_field="storage_uri", to_field="digital_object_id")
def digital_object_id(self, value):
return self.extract_id(value)
Expand Down
4 changes: 4 additions & 0 deletions transformer/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ def transform_object(self, package):
"""Creates a digital object for each package."""
data = {"storage_uri": package.storage_uri, "use_statement": package.use_statement}
transformed = self.get_transformed_object(data, SourcePackage, SourcePackageToDigitalObject)
transfer_component = self.aspace_client.retrieve(package.archivesspace_transfer)
transformed['title'] = transfer_component['title']
if package.origin == 'digitization':
transformed['publish'] = True
do_uri = self.aspace_client.create(transformed, "digital object").get("uri")
self.update_archival_object(package, do_uri)

Expand Down
1 change: 1 addition & 0 deletions transformer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def test_process_digital_objects(self, as_update_object, as_object, as_create_ob
self.assertEqual(msg, "Digital object created.")
self.assertEqual(len(obj_list), 1)
self.assertEqual(as_create_object.call_count, 1)
self.assertEqual(as_object.call_count, 2)

@patch("transformer.clients.ElectronBond.authorize_oauth")
@patch("transformer.clients.ElectronBond.patch")
Expand Down

0 comments on commit 6a3a2e9

Please sign in to comment.