Skip to content

Commit

Permalink
Adds hotfix for changing physical instantiation media type
Browse files Browse the repository at this point in the history
Also,
* Adds conditionals to only include Bulkrax transaction steps if Bulkrax is enabled.
  * Use work_resource.create_with_bulkrax_behavior Container if enabled.
  * Use change_set.create_work if not enabled.
* Ignores local Sony Ci and Kubeconfig credential files based on default naming
  conventions and locations
  • Loading branch information
bkiahstroud authored and afred committed Sep 3, 2024
1 parent 468e7ec commit d8b478a
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ fits.log
# Drew's demo stuff. Remove this ignore if necessary.
/demo*

# Default locaiton of Sony Ci API credentials
ci.yml

# Default naming convention of kubeconfig files
*kubeconfig.yml

# This file is generated on deployment
public/deployment.html

Expand Down
27 changes: 18 additions & 9 deletions app/services/aapb/batch_ingest/pbcore_xml_item_ingester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,24 @@ def ingest_klass(klass, attrs)
cx = Hyrax::Forms::ResourceForm.for(klass.new).prepopulate!
cx.validate(attrs)

result = Hyrax::Transactions::Container["work_resource.create_with_bulk_behavior"]
.with_step_args(
"work_resource.add_bulkrax_files" => {files: [], user: submitter},

"change_set.set_user_as_depositor" => {user: submitter},
"work_resource.change_depositor" => {user: submitter},
'work_resource.save_acl' => { permissions_params: [attrs.try('visibility') || 'open'].compact }
)
.call(cx)
base_step_args = {
'change_set.set_user_as_depositor' => { user: submitter },
'work_resource.change_depositor' => { user: submitter },
'work_resource.save_acl' => { permissions_params: [attrs.try('visibility') || 'open'].compact }
}

result = if ActiveModel::Type::Boolean.new.cast(ENV.fetch('SETTINGS__BULKRAX__ENABLED', false))
bulkrax_step_arg = { 'work_resource.add_bulkrax_files' => { files: [], user: submitter } }
Hyrax::Transactions::Container["work_resource.create_with_bulk_behavior"]
.with_step_args(
**bulkrax_step_arg.merge(base_step_args)
)
.call(cx)
else
Hyrax::Transactions::Container["change_set.create_work"]
.with_step_args(**base_step_args)
.call(cx)
end

if result.failure?
msg = result.failure[0].to_s
Expand Down
28 changes: 19 additions & 9 deletions app/transactions/ams/steps/add_data_from_pbcore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,25 @@ def parse_pbcore_essense_track
def create_essence_track(attrs)
cx = Hyrax::Forms::ResourceForm.for(EssenceTrackResource.new).prepopulate!
cx.validate(attrs)
Hyrax::Transactions::Container["work_resource.create_with_bulk_behavior"]
.with_step_args(
"work_resource.add_bulkrax_files" => {files: [], user: user},

"change_set.set_user_as_depositor" => {user: user},
"work_resource.change_depositor" => {user: user},
'work_resource.save_acl' => { permissions_params: [attrs.try('visibility') || 'open'].compact }
)
.call(cx)

base_step_args = {
"change_set.set_user_as_depositor" => {user: user},
"work_resource.change_depositor" => {user: user},
'work_resource.save_acl' => { permissions_params: [attrs.try('visibility') || 'open'].compact }
}

result = if ActiveModel::Type::Boolean.new.cast(ENV.fetch('SETTINGS__BULKRAX__ENABLED', false))
bulkrax_step_args = { "work_resource.add_bulkrax_files" => {files: [], user: user} }
Hyrax::Transactions::Container["work_resource.create_with_bulk_behavior"]
.with_step_args(
**bulkrax_step_args.merge(base_step_args)
)
else
Hyrax::Transactions::Container["change_set.create_work"]
.with_step_args(**base_step_args)
end

result.call(cx)
end

def parse_frame_width(frame_size)
Expand Down
53 changes: 53 additions & 0 deletions lib/fix/change_media_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require_relative '../../config/environment'

module Fix
class ChangeMediaType
MEDIA_TYPES = MediaTypeService.new.select_all_options

attr_reader :aapb_ids_filename, :aapb_ids
def initialize
@aapb_ids_filename = "#{File.dirname(File.expand_path(__FILE__))}/data/nebraska_public_media_ids.txt"
end

def aapb_ids
@aapb_ids ||= File.readlines(aapb_ids_filename).map(&:strip)
end

def asset_resources
@asset_resources ||= aapb_ids.map do |aapb_id|
puts "Looking up Asset #{aapb_id} ..."
begin
AssetResource.find(aapb_id)
rescue => e
puts "Error looking up Asset #{aapb_id}: #{e.class} -- #{e.message}"
end
end.compact
end

def run!
puts "Running Hotfix #{self.class.name} ..."
asset_resources.each do |asset_resource|
pi = asset_resource.physical_instantiation_resources.detect { |pi| pi.media_type != 'Moving Image' }
if !pi
puts "Nothing to fix for AssetResource #{asset_resource.id}, skipping ..."
next
end

# Change the metadata
pi.media_type = 'Moving Image'

begin
pi.save
puts "PhysicalInstantiationResource #{pi.id} saved with media_type 'Moving Image'"
rescue => e
puts "Error saving PhysicalInstantiationResource #{pi.id}: #{e.class} -- #{e.message}"
end
end
end
end
end


if __FILE__ == $0
Fix::ChangeMediaType.new.run!
end
184 changes: 184 additions & 0 deletions lib/fix/data/nebraska_public_media_ids.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
cpb-aacip-294f75638b3
cpb-aacip-c32e1318cc7
cpb-aacip-f2b99432175
cpb-aacip-24fb6d82fcb
cpb-aacip-b7b8d470a72
cpb-aacip-238cdfc89fb
cpb-aacip-02be757f06a
cpb-aacip-fef056eafe4
cpb-aacip-fb2b1e20cae
cpb-aacip-bb4be95f74e
cpb-aacip-7d3138cbc98
cpb-aacip-612808b0608
cpb-aacip-13074c81579
cpb-aacip-a8c07eb1c16
cpb-aacip-137dcaccab9
cpb-aacip-7a203c3da70
cpb-aacip-27597f5b0ed
cpb-aacip-3b4860945ce
cpb-aacip-0f315b5280b
cpb-aacip-87f657701d4
cpb-aacip-69af623df9c
cpb-aacip-1ca1e4a08d8
cpb-aacip-7b46a69b242
cpb-aacip-33f510ab40d
cpb-aacip-00421efb2b0
cpb-aacip-afe58622be9
cpb-aacip-08675066c04
cpb-aacip-d3f2542d7df
cpb-aacip-4968e4f808d
cpb-aacip-554f6fcb6b2
cpb-aacip-076167f1ca0
cpb-aacip-fd1e44d94e6
cpb-aacip-62e9a7747b6
cpb-aacip-4d8c3199ee8
cpb-aacip-c320a08c526
cpb-aacip-4a90240a09a
cpb-aacip-aa9bfded5c7
cpb-aacip-afa7e93a600
cpb-aacip-cc301924ee9
cpb-aacip-4c3fbb2aaf7
cpb-aacip-50a746fac18
cpb-aacip-f8a9b505e20
cpb-aacip-b9688cf50ed
cpb-aacip-b08aff600aa
cpb-aacip-927ec03e4e4
cpb-aacip-19b34393d8a
cpb-aacip-7cc14165ee9
cpb-aacip-235f7c22567
cpb-aacip-e302b9a5ac0
cpb-aacip-ac6964df90a
cpb-aacip-e0459b39a92
cpb-aacip-f2b8dd63357
cpb-aacip-81597012922
cpb-aacip-5ad8ae9c053
cpb-aacip-fa1c856ac7e
cpb-aacip-e6407f3804c
cpb-aacip-5a3eb7860c7
cpb-aacip-831258383f0
cpb-aacip-df04686ff28
cpb-aacip-d7d55b1745c
cpb-aacip-81995f80c5d
cpb-aacip-03bef5df681
cpb-aacip-b9b88420ee2
cpb-aacip-4bff7b980f6
cpb-aacip-2169696e881
cpb-aacip-63cdf88d538
cpb-aacip-fd3c57d4802
cpb-aacip-2e0188aa873
cpb-aacip-cb8bdaf0513
cpb-aacip-c32c4b4f54a
cpb-aacip-fb2d43f32c7
cpb-aacip-5fc9a5a17eb
cpb-aacip-2dc1049e7a7
cpb-aacip-b30a6e8be3a
cpb-aacip-7652b312a94
cpb-aacip-14baff9861d
cpb-aacip-7258a3f072e
cpb-aacip-3fd03a4a992
cpb-aacip-0ce41f22310
cpb-aacip-ac37704cc9c
cpb-aacip-e2143726821
cpb-aacip-23291e45341
cpb-aacip-78e99f5d48f
cpb-aacip-e3fea70c819
cpb-aacip-d3dd261a113
cpb-aacip-e22ca58aa7a
cpb-aacip-c055582d672
cpb-aacip-43c913ae953
cpb-aacip-b4506a9329c
cpb-aacip-b9fc73214a9
cpb-aacip-c3c7a1cb288
cpb-aacip-7d0865d1edd
cpb-aacip-ad2b0d9eb34
cpb-aacip-39c0714877f
cpb-aacip-6dc11d896e1
cpb-aacip-4903c325751
cpb-aacip-32a2f2d3bab
cpb-aacip-1b82bc253ae
cpb-aacip-51decbb01f0
cpb-aacip-30e983081f2
cpb-aacip-4dca4885f1f
cpb-aacip-01042c99044
cpb-aacip-cfd64c5e00e
cpb-aacip-ff36a94f53f
cpb-aacip-60b57c1e2fd
cpb-aacip-8a8d8a7e538
cpb-aacip-19c828e679f
cpb-aacip-6ad5aa76df7
cpb-aacip-1199b291859
cpb-aacip-1aa95eb993b
cpb-aacip-ca91fb5a460
cpb-aacip-587d0b59034
cpb-aacip-36863145ceb
cpb-aacip-d39c402f6ce
cpb-aacip-af2c6141754
cpb-aacip-95e39785494
cpb-aacip-bac022e4b04
cpb-aacip-ff36471c048
cpb-aacip-8e07558b829
cpb-aacip-3828675b84c
cpb-aacip-d3c8f80b52c
cpb-aacip-c6fd2fd44cc
cpb-aacip-61ab5395f2c
cpb-aacip-06cc34335d0
cpb-aacip-6dfae4fbe22
cpb-aacip-76697efd567
cpb-aacip-f552aafccf6
cpb-aacip-861e985a21a
cpb-aacip-6ecd8a3257e
cpb-aacip-acad2369ea8
cpb-aacip-0f193a2292a
cpb-aacip-3cb234d049e
cpb-aacip-4f42e38eb80
cpb-aacip-6cef7787164
cpb-aacip-376a7e7dca4
cpb-aacip-7afafa04f81
cpb-aacip-7f9196d5375
cpb-aacip-ae45802f2d9
cpb-aacip-208b7e67cf8
cpb-aacip-78bda899de8
cpb-aacip-e647587264e
cpb-aacip-9fa78df5409
cpb-aacip-08d22ec00aa
cpb-aacip-3af06cd3ee8
cpb-aacip-98ffbb0b81b
cpb-aacip-0c988783bfc
cpb-aacip-9979eceacb2
cpb-aacip-8b876080369
cpb-aacip-9725a780ef6
cpb-aacip-f856b0f0713
cpb-aacip-47720e19ac4
cpb-aacip-003a721989d
cpb-aacip-a2bd7e73631
cpb-aacip-d0cadad274d
cpb-aacip-027545a40c9
cpb-aacip-cd8a9c5f19c
cpb-aacip-df677b6d1de
cpb-aacip-033e86e4555
cpb-aacip-fe4c325c262
cpb-aacip-cb33354c038
cpb-aacip-7a928d4b385
cpb-aacip-cc4f2c2ad47
cpb-aacip-67f4b006aed
cpb-aacip-e9a491d8a91
cpb-aacip-6cd320707ec
cpb-aacip-6ce061d3f88
cpb-aacip-0ca84291b09
cpb-aacip-2cf96b857f7
cpb-aacip-8156b991b6a
cpb-aacip-3f7518bba67
cpb-aacip-cefcf4fbf38
cpb-aacip-30a15ad3cfa
cpb-aacip-450dfe2a949
cpb-aacip-242bd7c076e
cpb-aacip-e40b39c823a
cpb-aacip-6bb32940393
cpb-aacip-5a959dc4fb1
cpb-aacip-f874cf4c4d9
cpb-aacip-4404c0eaf3d
cpb-aacip-28ec850180b
cpb-aacip-c32c68ea5f8
cpb-aacip-94dbb10a51c
cpb-aacip-1bfeadcc053
cpb-aacip-c741bf6082d
File renamed without changes.

0 comments on commit d8b478a

Please sign in to comment.