Skip to content

Commit

Permalink
🧹 Remove ENV['HYKU_IIIF_PRINT'] conditional
Browse files Browse the repository at this point in the history
The knowledge of why we do or don't have `HYKU_IIIF_PRINT` is a bit
odd. I'm not excited to have an `ENV` from Hyku show up here; especially
an `ENV` that only partially removes the full functionality of IIIF
Print.

What I'm wondering is if we should have Hyku decorate the
work_resource.set_child_flag to account for it's implementation foibles
relative to how Hyku is using the HYKU_IIIF_PRINT.

Put another, when we see this variable, my read is HYKU_IIIF_PRINT ==
false means don't do anything IIIF Print related. But that is not what
it means in Hyku, thus we should limit the knowledge/foibles of that ENV
to Hyku only.
  • Loading branch information
jeremyf committed Feb 2, 2024
1 parent 377c96d commit 9dec841
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,31 @@ class IiifPrintContainerDecorator
end
end

if ENV['HYKU_IIIF_PRINT']
namespace 'change_set' do |ops|
ops.register 'update_work' do
steps = Hyrax::Transactions::WorkUpdate::DEFAULT_STEPS.dup
steps.insert(steps.index('work_resource.update_work_members') + 1, 'work_resource.set_child_flag')
Hyrax::Transactions::WorkUpdate.new(steps: steps)
end
namespace 'change_set' do |ops|
ops.register 'update_work' do
steps = Hyrax::Transactions::WorkUpdate::DEFAULT_STEPS.dup
# NOTE: applications that don't want the file splitting of IIIF Print will want to remove
# this step from their transactions.
steps.insert(steps.index('work_resource.update_work_members') + 1, 'work_resource.set_child_flag')
Hyrax::Transactions::WorkUpdate.new(steps: steps)
end
end

if defined?(Bulkrax::Transactions::Container)
namespace 'work_resource' do |ops|
ops.register Bulkrax::Transactions::Container::UPDATE_WITH_BULK_BEHAVIOR do
steps = Bulkrax::Transactions::Container::UPDATE_WITH_BULK_BEHAVIOR_STEPS.dup
steps.insert(steps.index('work_resource.update_work_members') + 1, 'work_resource.set_child_flag')
Hyrax::Transactions::WorkUpdate.new(steps: steps)
end
if defined?(Bulkrax::Transactions::Container)
namespace 'work_resource' do |ops|
ops.register Bulkrax::Transactions::Container::UPDATE_WITH_BULK_BEHAVIOR do
steps = Bulkrax::Transactions::Container::UPDATE_WITH_BULK_BEHAVIOR_STEPS.dup
# NOTE: applications that don't want the file splitting of IIIF Print will want to remove
# this step from their transactions.
steps.insert(steps.index('work_resource.update_work_members') + 1, 'work_resource.set_child_flag')
Hyrax::Transactions::WorkUpdate.new(steps: steps)
end
end
end

namespace 'work_resource' do |ops|
ops.register 'set_child_flag' do
Steps::SetChildFlag.new
end
namespace 'work_resource' do |ops|
ops.register 'set_child_flag' do
Steps::SetChildFlag.new
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/transactions/hyrax/transactions/steps/set_child_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ module Steps
class SetChildFlag
include Dry::Monads[:result]

# @see IiifPrint.model_configuration
def call(resource)
return Failure(:resource_not_persisted) unless resource.persisted?

user = ::User.find_by_user_key(resource.depositor)

Hyrax.custom_queries.find_child_works(resource: resource).each do |child_work|
# not all child works might have the is_child property that we define when we configure
# the a model for iiif_print. see IiifPrint.model_configuration
#
# Put another the existence of the is_child property is optional.
next unless child_work.respond_to?(:is_child)
next if child_work.is_child
child_work.is_child = true
Hyrax.persister.save(resource: child_work)
Expand Down

0 comments on commit 9dec841

Please sign in to comment.