-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Fedora record removal to DeletePhysicalInstantiations fix #925
Conversation
1e72e96
to
3bcb39e
Compare
3bcb39e
to
c72ab04
Compare
c72ab04
to
e95c5b8
Compare
e95c5b8
to
ddaf04d
Compare
027cfd9
to
7fbff53
Compare
7fbff53
to
54ee1e2
Compare
54ee1e2
to
5574158
Compare
4010868
to
5f46e37
Compare
@members ||= [] | ||
member_id_vals = member_ids.map { |id| id.to_s }.to_set | ||
ids_from_members = @members.map { |m| m.id.to_s }.to_set | ||
# If the member_ids do not match the IDs within the members, then re-set the members to be an accurate reflection of the member IDs. | ||
# This allows us to modify resource.member_ids and have #members accurately reflect the changes. | ||
if member_id_vals != ids_from_members | ||
@members = member_ids.map do |id| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain more about what's happening on these lines and why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WorkBehavior#members
is supposed to be a memoized, but accurate, mapping of member_ids
to objects returned from Hyrax.query_service
. When deleting members, I remove their IDs from the member_ids
array of the parent (we could not use the Hyrax transaction for reasons I can explain if you want).
But then the #members
would be out of sync. So I fixed the cache-busting condition to just detect if the @members
and member_ids
are different, and if so, reset @members
to accurately reflect member_ids
.
lib/fix/delete_asset_resources.rb
Outdated
def destroy_work_and_members(resource:) | ||
result = { resource: resource } | ||
resource.members.each do |member| | ||
resource.members.delete(member) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain the purpose of this line? (28)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to be removing the child from the parent, but if you are thinking it should be deleting from member_ids
instead of members
, I think you are correct.
This delete_asset_resources
is code I added as a consolidation/replacement for other Asset deleting scripts we have that can be run from command line. This one does a recursive delete to get at EssenceTracks which were being left behind, and I was using it a lot in the course of testing so that's why it's included here. Could be a separate PR but hoping to save a little time by combining. It is stand alone and shouldn't affect the script for deleting physical instantiations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, since this is doing a depth-first recursive call to traverse the tree, removing that line really has no effect -- the everything gets deleted, children first. Removing.
Fedora records were not being deleted and were then being retreived by PhysicalInstantiationResource models, effectively getting stuck on the parent Asset. This allows the Fix::DeletePhysicalInstantiaton class to remove PhysicalInstantiations of a give media type from a set of AssetResources identified by an ID list. Usage: ruby lib/fix/delete_physical_instantiations --file aapb_ids.txt --media-type 'Moving Image' Also, * Includes class SampleData class for finding test data sets within an existing repository (e.g. demo).
5f46e37
to
b235a80
Compare
No description provided.