Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors transaction step for saving admin data (#889)
* Refactors transaction step for saving admin data By default, multi-valued input fields display an additional set of input fields that are blank. These get submitted by the form and are usually discarded, but because we are treating Sony Ci ID field special, it was erroneously saving additional blank values for Sony Ci ID, which was resulting in multiple players of the same media dislaying on AAPB when the record was published. Multiple Sony Ci IDs are allowed in cases of mult-part Assets. They are stored as a serialized JSON array in the AdminData.sonyci_id field, which is related to Asset reords via a global ID field on AdminData.gid. And the global ID fields was used instead of a normal foreign key because the AssetResource used to be just Asset, and stored in Fedora, not the database, and a global ID was the closest thing to a foreign key across 2 persistence layers that we could think of :) Fixes #882. * Handles non-multiple, non-blank (default) case Co-authored-by: Kiah Stroud <[email protected]> * Add debug log for when nothing gets written Co-authored-by: Kiah Stroud <[email protected]> * Enumerates over SERIALIZED_FIELDS explicitly rather than duck typing * Another refactor/simplification Uses AdminData.attributes_for_updates as a filter to the change set fields. Filters out blank sony ci ids so they don't get serialized. Adds validation routine to AdminData for guarding against fields that cannot be deleted once set: bulkrax_importer_id and batch_ingest_batch_id. These IDs are foreign keys and if they accidentally get unset, we loase relational integrity, so need to make sure they are not accidentally getting unset via ingest, or updating Assets via UI, or anywhere else. * adds missing code that was supposed to be part of the last commit 🤦, please squash when merging and remove this msg. * Do not persist data in CreateAapbAdminData#set_admin_data_attributes --------- Co-authored-by: Kiah Stroud <[email protected]>
- Loading branch information