diff --git a/app/transactions/hyrax/transactions/iiif_print_container_decorator.rb b/app/transactions/hyrax/transactions/iiif_print_container_decorator.rb index 18a9999a..09ff253e 100644 --- a/app/transactions/hyrax/transactions/iiif_print_container_decorator.rb +++ b/app/transactions/hyrax/transactions/iiif_print_container_decorator.rb @@ -31,15 +31,19 @@ class IiifPrintContainerDecorator 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::Container) + if defined?(Bulkrax::Transactions::Container) namespace 'work_resource' do |ops| - ops.register Bulkrax::Container::UPDATE_WITH_BULK_BEHAVIOR do - steps = Bulkrax::Container::UPDATE_WITH_BULK_BEHAVIOR_STEPS.dup + 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 diff --git a/app/transactions/hyrax/transactions/steps/set_child_flag.rb b/app/transactions/hyrax/transactions/steps/set_child_flag.rb index c4851e52..89d85272 100644 --- a/app/transactions/hyrax/transactions/steps/set_child_flag.rb +++ b/app/transactions/hyrax/transactions/steps/set_child_flag.rb @@ -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)