-
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.
* PluggableDerivativeService will not invoke (plugin for) creation if that plugin's destination name already has an existing derivative file. * DerivativeAttachment model fields, tests implemented, including validation. * WorkDerivatives attach (and consequently commit!) methods log attachment to RDBMS, via NewspaperWorks::DerivativeAttachment. * PluggableDerivativeService refactored to filter vs. logged attachments of pre-existing derivatives, in a more testable way. * `WorkFiles` `.derivatives` method constructs same WorkDerivatives, only once. * WorkFiles delegates construction of derivatives adapter to WorkFile. * Parent/child relationships for WorkFile <>-- WorkDerivatives, with ability to follow .parent reference/relationship from WorkDerivatives object. * IngestFileRelation model, with tests. * WorkFile adapter can be constructed with nil fileset, the use of which is as a mere sentinel value, planned for use by WorkDerivatives. * DerivativeAttachment model permits nil fileset reference, and save methods of WorkDerivatives handle nil fileset with exception. * Make WorkDerivatives logging to DerivativeAttachment happen during assignment, not attachment, and keep the entries in the table in sync with transient values for assigned queue. * WorkDerivatives logs relationship between primary and derivative file path, esp. for cases of no fileset (deferred attachment use case). * Remove strict equivalence check from test for WorkFiles.derivatives * WorkDerivatives.commit_queued! method and integration test. * Install generator injects `:after_create_fileset` override of Hyrax default subscriber into consuming application. This injected subscriber block then calls `NewspaperWorks::Data.handle_after_create_fileset` method, which handles deferred derivative attachment. * On deferred attachment of derivatives, ensure that fileset id is set on DerivativeAttachment table/model during callback, as insurance that the derivative creation plugins will not overwrite.
- Loading branch information
1 parent
c8b8ff0
commit 42c3db7
Showing
17 changed files
with
463 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module NewspaperWorks | ||
class DerivativeAttachment < ApplicationRecord | ||
# We can store nil/optional fileset as interim value before fileset | ||
# construction, but we require at minimum, path, destination_name | ||
validates :path, presence: true | ||
validates :destination_name, presence: true | ||
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,14 @@ | ||
module NewspaperWorks | ||
class IngestFileRelation < ApplicationRecord | ||
validates :file_path, presence: true | ||
validates :derivative_path, presence: true | ||
|
||
# Query by file path for all derivatives, as de-duplicated array of | ||
# derivative paths. | ||
# @param path [String] Path to primary file | ||
# @return [Array<String>] de-duplicated array of derivative paths. | ||
def self.derivatives_for_file(path) | ||
where(file_path: path).pluck(:derivative_path).uniq | ||
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
12 changes: 12 additions & 0 deletions
12
db/migrate/20181214181358_create_newspaper_works_derivative_attachments.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,12 @@ | ||
class CreateNewspaperWorksDerivativeAttachments < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :newspaper_works_derivative_attachments do |t| | ||
t.string :fileset_id | ||
t.string :path | ||
t.string :destination_name | ||
|
||
t.timestamps | ||
end | ||
add_index :newspaper_works_derivative_attachments, :fileset_id | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20190107165909_create_newspaper_works_ingest_file_relations.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,11 @@ | ||
class CreateNewspaperWorksIngestFileRelations < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :newspaper_works_ingest_file_relations do |t| | ||
t.string :file_path | ||
t.string :derivative_path | ||
|
||
t.timestamps | ||
end | ||
add_index :newspaper_works_ingest_file_relations, :file_path | ||
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
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.