Skip to content

Commit

Permalink
🧹 correct camel case to constant notation for easier referencing
Browse files Browse the repository at this point in the history
Co-Authored-By: LaRita Robinson <[email protected]>
  • Loading branch information
Shana Moore and laritakr committed Jan 24, 2024
1 parent 02db077 commit e8da6ae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
8 changes: 4 additions & 4 deletions app/factories/bulkrax/valkyrie_object_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def create
result = transaction
.with_step_args(
# "work_resource.add_to_parent" => {parent_id: @related_parents_parsed_mapping, user: @user},
"work_resource.#{Bulkrax::Container::AddBulkraxFiles}" => { files: get_s3_files(remote_files: attributes["remote_files"]), user: @user },
"work_resource.#{Bulkrax::Container::ADD_BULKRAX_FILES}" => { files: get_s3_files(remote_files: attributes["remote_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 }
Expand Down Expand Up @@ -83,7 +83,7 @@ def update

result = update_transaction
.with_step_args(
"work_resource.#{Bulkrax::Container::AddBulkraxFiles}" => { files: get_s3_files(remote_files: attributes["remote_files"]), user: @user }
"work_resource.#{Bulkrax::Container::ADD_BULKRAX_FILES}" => { files: get_s3_files(remote_files: attributes["remote_files"]), user: @user }

# TODO: uncomment when we upgrade Hyrax 4.x
# 'work_resource.save_acl' => { permissions_params: [attrs.try('visibility') || 'open'].compact }
Expand Down Expand Up @@ -165,12 +165,12 @@ def destroy_existing_files
private

def transaction
Hyrax::Transactions::Container["work_resource.#{Bulkrax::Container::CreateWithBulkBehavior}"]
Hyrax::Transactions::Container["work_resource.#{Bulkrax::Container::CREATE_WITH_BULK_BEHAVIOR}"]
end

# Customize Hyrax::Transactions::WorkUpdate transaction with bulkrax
def update_transaction
Hyrax::Transactions::Container["work_resource.#{Bulkrax::Container::UpdateWithBulkBehavior}"]
Hyrax::Transactions::Container["work_resource.#{Bulkrax::Container::UPDATE_WITH_BULK_BEHAVIOR}"]
end

# Query child FileSet in the resource/object
Expand Down
36 changes: 20 additions & 16 deletions app/transactions/bulkrax/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,39 @@
module Bulkrax
class Container
extend Dry::Container::Mixin

CreateWithBulkBehavior = 'create_with_bulk_behavior'.freeze
UpdateWithBulkBehavior = 'update_with_bulk_behavior'.freeze
AddBulkraxFiles = 'add_bulkrax_files'.freeze

namespace "work_resource" do |ops|
ops.register CreateWithBulkBehavior do
steps = Hyrax::Transactions::WorkCreate::DEFAULT_STEPS.dup
steps[steps.index("work_resource.add_file_sets")] = "work_resource.#{Bulkrax::Container::AddBulkraxFiles}"
ADD_BULKRAX_FILES = 'add_bulkrax_files'
CREATE_WITH_BULK_BEHAVIOR = 'create_with_bulk_behavior'
CREATE_WITH_BULK_BEHAVIOR_STEPS = begin
steps = Hyrax::Transactions::WorkCreate::DEFAULT_STEPS.dup
steps[steps.index("work_resource.add_file_sets")] = "work_resource.#{Bulkrax::Container::ADD_BULKRAX_FILES}"
steps
end.freeze
UPDATE_WITH_BULK_BEHAVIOR = 'update_with_bulk_behavior'
UPDATE_WITH_BULK_BEHAVIOR_STEPS = begin
steps = Hyrax::Transactions::WorkUpdate::DEFAULT_STEPS.dup
steps[steps.index("work_resource.add_file_sets")] = "work_resource.#{Bulkrax::Container::ADD_BULKRAX_FILES}"
steps
end.freeze

Hyrax::Transactions::WorkCreate.new(steps: steps)
namespace "work_resource" do |ops|
ops.register CREATE_WITH_BULK_BEHAVIOR do
Hyrax::Transactions::WorkCreate.new(steps: CREATE_WITH_BULK_BEHAVIOR_STEPS)
end

ops.register UpdateWithBulkBehavior do
steps = Hyrax::Transactions::WorkUpdate::DEFAULT_STEPS.dup
steps[steps.index("work_resource.add_file_sets")] = "work_resource.#{Bulkrax::Container::AddBulkraxFiles}"

Hyrax::Transactions::WorkUpdate.new(steps: steps)
ops.register UPDATE_WITH_BULK_BEHAVIOR do
Hyrax::Transactions::WorkUpdate.new(steps: UPDATE_WITH_BULK_BEHAVIOR_STEPS)
end

# TODO: uninitialized constant Bulkrax::Container::InlineUploadHandler
# ops.register "add_file_sets" do
# Hyrax::Transactions::Steps::AddFileSets.new(handler: InlineUploadHandler)
# end

ops.register AddBulkraxFiles do
ops.register ADD_BULKRAX_FILES do
Bulkrax::Steps::AddFiles.new
end
end
end
end
Hyrax::Transactions::Container.merge(Bulkrax::Container)
Hyrax::Transactions::Container.merge(Bulkrax::Container)

0 comments on commit e8da6ae

Please sign in to comment.