-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a status field to `PreIngestFile`s that defaults to 'preingest'. The `AttachFilesToWorkJob` class is preprended with logic that updates the status to 'attached'. The logic requires that `deduplication_key` is present in the CSV so that field is added to the default mapper and validator. There is a helper which outputs a success icon (a green checkmark) if the `PreIngestFile` has an 'attached' status. This is used for the `PreIngestWork` if all the statuses for the `PreIngestFile` are 'attached'.
- Loading branch information
Showing
19 changed files
with
174 additions
and
273 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module AttachFilesToWorkJobPrepends | ||
# @param [ActiveFedora::Base] work - the work object | ||
# @param [Array<Hyrax::UploadedFile>] uploaded_files - an array of files to attach | ||
def perform(work, uploaded_files, **work_attributes) | ||
super | ||
if work.deduplication_key | ||
uploaded_files.each do |uploaded_file| | ||
# Remove existing PreIngestFile for this FileSet | ||
pre_ingest_work = Zizia::PreIngestWork.find_by(deduplication_key: work.deduplication_key) | ||
pre_ingest_file = pre_ingest_work.pre_ingest_files.where('status != "attached"') | ||
.find_by(filename: File.basename(uploaded_file.file.path)) | ||
pre_ingest_file.status = 'attached' | ||
pre_ingest_file.save | ||
end | ||
end | ||
end | ||
end |
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 @@ | ||
AttachFilesToWorkJob.prepend(AttachFilesToWorkJobPrepends) |
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,5 @@ | ||
class AddStatusToPreIngestFile < ActiveRecord::Migration[5.1] | ||
def change | ||
add_column :zizia_pre_ingest_files, :status, :string, default: 'preingest' | ||
end | ||
end |
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
Oops, something went wrong.