-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #600 from IU-Libraries-Joint-Development/essi-1932…
…_consolidate_fileset_job_calls [ESSI-1932] consolidate FileSet Inherit, Copy job calls into work actor
- Loading branch information
Showing
5 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/extensions/hyrax/actors/file_set_actor/create_content.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
lib/extensions/iiif_print/data/inherit_permissions_job_calls.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |