Skip to content

Commit

Permalink
Merge pull request #600 from IU-Libraries-Joint-Development/essi-1932…
Browse files Browse the repository at this point in the history
…_consolidate_fileset_job_calls

[ESSI-1932] consolidate FileSet Inherit, Copy job calls into work actor
  • Loading branch information
aploshay authored Feb 9, 2024
2 parents a4a2c57 + 3a961e6 commit a1dd098
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create(env)

def update(env)
structure = env.attributes.delete(:structure)&.deep_symbolize_keys
super(env) && save_structure(env,structure)
super(env) && save_structure(env,structure) && copy_visibility(env) && inherit_permissions(env)
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
attrs = create_attributes
init_attrs = { dynamic_schema_id: attrs[:dynamic_schema_id] } if attrs[:dynamic_schema_id].present? && klass.new.respond_to?(:dynamic_schema_id)
@object = klass.new(init_attrs)
object.reindex_extent = ::Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
object.reindex_extent = ::Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if defined?(::Hyrax::Adapters::NestingIndexAdapter) && object.respond_to?(:reindex_extent=)
run_callbacks :save do
run_callbacks :create do
klass == ::Collection ? create_collection(attrs) : work_actor.create(environment(attrs))
Expand Down
5 changes: 5 additions & 0 deletions lib/extensions/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def attribute_will_change!(attr)
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithRemoteFilesActor, ESSI::Actors::CreateWithRemoteFilesOrderedMembersStructureActor
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithFilesActor, Hyrax::Actors::CreateWithFilesOrderedMembersActor
Hyrax::Actors::BaseActor.prepend Extensions::Hyrax::Actors::BaseActor::UndoAttributeArrayWrap
Hyrax::Actors::FileSetActor.prepend Extensions::Hyrax::Actors::FileSetActor::CreateContent


# .jp2 conversion settings
Hydra::Derivatives.kdu_compress_path = ESSI.config.dig(:essi, :kdu_compress_path)
Expand Down Expand Up @@ -172,6 +174,9 @@ def attribute_will_change!(attr)
IiifPrint::BlacklightIiifSearch::AnnotationDecorator.include Extensions::IiifPrint::BlacklightIiifSearch::AnnotationDecorator::AnnotationDecoratorCompatibility
IiifPrint::IiifSearchDecorator.include Extensions::IiifPrint::IiifSearchDecorator::SearchDecoratorCompatibility

# Patch iiif_print FileSet job calls
IiifPrint::Data.include Extensions::IiifPrint::Data::InheritPermissionsJobCalls

# support for nested works generating file_set sequences in manifests
IIIFManifest::ManifestBuilder::DeepFileSetEnumerator.prepend Extensions::IIIFManifest::ManifestBuilder::DeepFileSetEnumerator::NestedEach

Expand Down
31 changes: 31 additions & 0 deletions lib/extensions/hyrax/actors/file_set_actor/create_content.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# modified to apply helper jobs to individual FileSet
module Extensions
module Hyrax
module Actors
module FileSetActor
module CreateContent
# Spawns asynchronous IngestJob unless ingesting from URL
# Called from FileSetsController, AttachFilesToWorkJob, IngestLocalFileJob, ImportUrlJob
# @param [Hyrax::UploadedFile, File] file the file uploaded by the user
# @param [Symbol, #to_s] relation
# @return [IngestJob, FalseClass] false on failure, otherwise the queued job
def create_content(file, relation = :original_file, from_url: false)
# If the file set doesn't have a title or label assigned, set a default.
file_set.label ||= label_for(file)
file_set.title = [file_set.label] if file_set.title.blank?
return false unless file_set.save # Need to save to get an id
if from_url
# If ingesting from URL, don't spawn an IngestJob; instead
# reach into the FileActor and run the ingest with the file instance in
# hand. Do this because we don't have the underlying UploadedFile instance
file_actor = build_file_actor(relation)
file_actor.ingest_file(wrapper!(file: file, relation: relation))
else
IngestJob.perform_later(wrapper!(file: file, relation: relation))
end
end
end
end
end
end
end
24 changes: 24 additions & 0 deletions lib/extensions/iiif_print/data/inherit_permissions_job_calls.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# modified from iiif_print
# removes FileSet job calls handled elsewhere
module Extensions
module IiifPrint
module Data
module InheritPermissionsJobCalls
def self.included(base)
base.class_eval do
# Handler for after_create_fileset, to be called by block subscribing to
# and overriding default Hyrax `:after_create_fileset` handler, via
# app integrating iiif_print.
def self.handle_after_create_fileset(file_set, user)
handle_queued_derivative_attachments(file_set)
# Hyrax queues this job by default, and since iiif_print
# overrides the single subscriber Hyrax uses to do so, we
# must call this here:
::FileSetAttachedEventJob.perform_later(file_set, user)
end
end
end
end
end
end
end

0 comments on commit a1dd098

Please sign in to comment.