Skip to content

Commit

Permalink
Merge a7e7421 into 32cf089
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Mar 17, 2021
2 parents 32cf089 + a7e7421 commit cd55022
Show file tree
Hide file tree
Showing 13 changed files with 257 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gem 'uglifier' # compressor for JavaScript assets

# Stanford gems
gem 'assembly-image', '~> 1.7'
gem 'assembly-objectfile', '~> 1.10'
gem 'assembly-objectfile', '~> 1.10', '>= 1.10.2' # webarchive-seed and reading order is supported in 1.10.2 and better
gem 'dor-services-client', '~> 6.27'
gem 'dor-workflow-client'
gem 'druid-tools'
Expand Down
36 changes: 2 additions & 34 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ GEM
assembly-image (1.7.7)
assembly-objectfile (>= 1.6.4)
mini_exiftool (>= 1.6, < 3)
assembly-objectfile (1.10.0)
assembly-objectfile (1.10.2)
activesupport (>= 5.2.0)
deprecation
dry-struct (~> 1.0)
Expand Down Expand Up @@ -115,17 +115,7 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
cocina-models (0.55.0)
activesupport
dry-struct (~> 1.0)
dry-types (~> 1.1)
openapi3_parser
openapi_parser
thor
zeitwerk (~> 2.1)
coderay (1.1.3)
commonmarker (0.21.2)
ruby-enum (~> 0.5)
concurrent-ruby (1.1.8)
config (3.0.0)
deep_merge (~> 1.2, >= 1.2.1)
Expand Down Expand Up @@ -155,13 +145,6 @@ GEM
capistrano-one_time_key
capistrano-shared_configs
docile (1.3.5)
dor-services-client (6.27.0)
activesupport (>= 4.2, < 7)
cocina-models (~> 0.55.0)
deprecation
faraday (>= 0.15, < 2)
moab-versioning (~> 4.0)
zeitwerk (~> 2.1)
dor-workflow-client (3.23.1)
activesupport (>= 3.2.1, < 7)
deprecation (>= 0.99.0)
Expand Down Expand Up @@ -271,11 +254,6 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.4)
moab-versioning (4.4.1)
druid-tools (>= 1.0.0)
json
nokogiri
nokogiri-happymapper
mono_logger (1.1.0)
multi_json (1.15.0)
multipart-post (2.1.1)
Expand All @@ -290,13 +268,7 @@ GEM
racc (~> 1.4)
nokogiri (1.11.2-x86_64-linux)
racc (~> 1.4)
nokogiri-happymapper (0.8.1)
nokogiri (~> 1.5)
okcomputer (1.18.4)
openapi3_parser (0.9.0)
commonmarker (~> 0.17)
psych (~> 3.1)
openapi_parser (0.12.1)
orm_adapter (0.5.0)
parallel (1.20.1)
parser (3.0.0.0)
Expand All @@ -311,7 +283,6 @@ GEM
pry (~> 0.13.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
psych (3.3.1)
public_suffix (4.0.6)
racc (1.5.2)
rack (2.2.3)
Expand Down Expand Up @@ -398,8 +369,6 @@ GEM
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-rspec (1.41.0)
rubocop (>= 0.68.1)
ruby-enum (0.9.0)
i18n
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.4)
sassc (2.0.1)
Expand Down Expand Up @@ -469,7 +438,7 @@ PLATFORMS

DEPENDENCIES
assembly-image (~> 1.7)
assembly-objectfile (~> 1.10)
assembly-objectfile (~> 1.10, >= 1.10.2)
bootstrap (~> 4.3, >= 4.3.1)
capistrano-bundler
capistrano-passenger
Expand All @@ -480,7 +449,6 @@ DEPENDENCIES
devise
devise-remote-user
dlss-capistrano (~> 3.10)
dor-services-client (~> 6.27)
dor-workflow-client
druid-tools
equivalent-xml
Expand Down
6 changes: 4 additions & 2 deletions app/lib/pre_assembly/content_metadata_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ module PreAssembly
class ContentMetadataCreator
# rubocop:disable Metrics/ParameterLists
def initialize(druid_id:, content_md_creation:, object_files:,
content_md_creation_style:, media_manifest:, add_file_attributes:)
content_md_creation_style:, media_manifest:, reading_order:, add_file_attributes:)
@druid_id = druid_id
@content_md_creation = content_md_creation
@object_files = object_files
@content_md_creation_style = content_md_creation_style
@media_manifest = media_manifest
@reading_order = reading_order
@add_file_attributes = add_file_attributes
end
# rubocop:enable Metrics/ParameterLists
Expand All @@ -24,13 +25,14 @@ def create
add_exif: false,
bundle: content_md_creation.to_sym,
style: content_md_creation_style,
reading_order: reading_order,
add_file_attributes: add_file_attributes)
end

private

attr_reader :druid_id, :content_md_creation, :object_files,
:content_md_creation_style, :media_manifest, :add_file_attributes
:content_md_creation_style, :media_manifest, :reading_order, :add_file_attributes

# Object files that should be included in content metadata.
def content_object_files
Expand Down
16 changes: 14 additions & 2 deletions app/lib/pre_assembly/digital_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def content_md_creation_style
Cocina::Models::Vocab.object => :file,
Cocina::Models::Vocab.book => :simple_book,
Cocina::Models::Vocab.manuscript => :simple_book,
Cocina::Models::Vocab.document => :document,
Cocina::Models::Vocab.map => :map,
Cocina::Models::Vocab.three_dimensional => :'3d'
Cocina::Models::Vocab.three_dimensional => :'3d',
Cocina::Models::Vocab.webarchive_seed => :'webarchive-seed'
}.fetch(object_type, content_structure.to_sym)
end

Expand Down Expand Up @@ -118,11 +120,21 @@ def generate_content_metadata(file_attributes_supplied)
# Invoke the contentMetadata creation method used by the project
# @param [Boolean] file_attributes_supplied - true if publish/preserve/shelve attribs are supplied
def create_content_metadata(file_attributes_supplied)
# Special case: if the content_structure set by the user is a rtl simple book,
# be sure we set this as the style, else use the default and style from the object
if content_structure == 'simple_book_rtl'
reading_order = 'rtl'
content_style = :simple_book
else
reading_order = 'ltr'
content_style = content_md_creation_style
end
ContentMetadataCreator.new(druid_id: druid.id,
content_md_creation: content_md_creation,
object_files: object_files,
content_md_creation_style: content_md_creation_style,
content_md_creation_style: content_style,
media_manifest: media_manifest,
reading_order: reading_order,
add_file_attributes: file_attributes_supplied).create
end

Expand Down
5 changes: 4 additions & 1 deletion app/models/batch_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class BatchContext < ApplicationRecord
'file' => 3,
'media' => 4,
'3d' => 5,
'document' => 6
'document' => 6,
'maps' => 7,
'webarchive_seed' => 8,
'simple_book_rtl' => 9
}

enum content_metadata_creation: {
Expand Down
7 changes: 5 additions & 2 deletions app/views/batch_contexts/_new_bc_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
<%= form.input :content_structure, collection:
[
['Simple Image', 'simple_image'],
['Simple Book', 'simple_book'],
['Image', 'simple_image'],
['Book (ltr)', 'simple_book'],
['Book (rtl)', 'simple_book_rtl'],
['Document', 'document'],
['File', 'file'],
['Media', 'media'],
['3D', '3d'],
['Map', 'maps'],
['Webarchive seed', 'webarchive_seed']
]
%>
Expand Down
2 changes: 1 addition & 1 deletion spec/features/dark_file_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:bare_druid) { 'tx666tx9999' }
let(:object_staging_dir) { Rails.root.join(Settings.assembly_staging_dir, 'tx', '666', 'tx', '9999', bare_druid) }
let(:cocina_model_dark_access) { instance_double(Cocina::Models::Access, access: 'dark') }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.media, access: cocina_model_dark_access) }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.object, access: cocina_model_dark_access) }
let(:dsc_object_version) { instance_double(Dor::Services::Client::ObjectVersion, openable?: true) }
let(:dsc_object) { instance_double(Dor::Services::Client::Object, version: dsc_object_version, find: item) }
let(:exp_content_md) do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:bare_druid) { 'pr666rr9999' }
let(:object_staging_dir) { Rails.root.join(Settings.assembly_staging_dir, 'pr', '666', 'rr', '9999', bare_druid) }
let(:cocina_model_world_access) { instance_double(Cocina::Models::Access, access: 'world') }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.media, access: cocina_model_world_access) }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.document, access: cocina_model_world_access) }
let(:dsc_object_version) { instance_double(Dor::Services::Client::ObjectVersion, openable?: true) }
let(:dsc_object) { instance_double(Dor::Services::Client::Object, version: dsc_object_version, find: item) }
let(:exp_content_md) do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:bare_druid) { 'pr666rr9999' }
let(:object_staging_dir) { Rails.root.join(Settings.assembly_staging_dir, 'pr', '666', 'rr', '9999', bare_druid) }
let(:cocina_model_world_access) { instance_double(Cocina::Models::Access, access: 'world') }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.media, access: cocina_model_world_access) }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.image, access: cocina_model_world_access) }
let(:dsc_object_version) { instance_double(Dor::Services::Client::ObjectVersion, openable?: true) }
let(:dsc_object) { instance_double(Dor::Services::Client::Object, version: dsc_object_version, find: item) }
let(:exp_content_md) do
Expand Down Expand Up @@ -47,7 +47,7 @@

fill_in 'Project name', with: project_name
select 'Pre Assembly Run', from: 'Job type'
select 'Simple Image', from: 'Content structure'
select 'Image', from: 'Content structure'
fill_in 'Bundle dir', with: bundle_dir

click_button 'Submit'
Expand Down
4 changes: 2 additions & 2 deletions spec/features/public_tif_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:bare_druid) { 'tf111tf2222' }
let(:object_staging_dir) { Rails.root.join(Settings.assembly_staging_dir, 'tf', '111', 'tf', '2222', bare_druid) }
let(:cocina_model_world_access) { instance_double(Cocina::Models::Access, access: 'world') }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.media, access: cocina_model_world_access) }
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.image, access: cocina_model_world_access) }
let(:dsc_object_version) { instance_double(Dor::Services::Client::ObjectVersion, openable?: true) }
let(:dsc_object) { instance_double(Dor::Services::Client::Object, version: dsc_object_version, find: item) }
let(:exp_content_md) do
Expand Down Expand Up @@ -49,7 +49,7 @@

fill_in 'Project name', with: project_name
select 'Pre Assembly Run', from: 'Job type'
select 'Simple Image', from: 'Content structure'
select 'Image', from: 'Content structure'
fill_in 'Bundle dir', with: bundle_dir
choose 'Preserve=Yes, Shelve=Yes, Publish=Yes'

Expand Down
6 changes: 4 additions & 2 deletions spec/lib/pre_assembly/content_metadata_creator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
object_files: object_files,
content_md_creation_style: content_md_creation_style,
media_manifest: media_manifest,
reading_order: reading_order,
add_file_attributes: add_file_attributes)
end

let(:druid_id) { 'foo' }
let(:content_md_creation) { 'bar' }
let(:content_md_creation_style) { 'baz' }
let(:add_file_attributes) { false }
let(:reading_order) { 'ltr' }
let(:media_manifest) { 'quix' }

describe '#content_object_files' do
Expand Down Expand Up @@ -55,7 +57,7 @@
creator.create
expect(Assembly::ContentMetadata).to have_received(:create_content_metadata)
.with(druid: druid_id, objects: object_files, add_exif: false,
bundle: :bar, style: content_md_creation_style, add_file_attributes: false)
bundle: :bar, style: content_md_creation_style, reading_order: reading_order, add_file_attributes: false)
end
end

Expand All @@ -66,7 +68,7 @@
creator.create
expect(Assembly::ContentMetadata).to have_received(:create_content_metadata)
.with(druid: druid_id, objects: object_files, add_exif: false,
bundle: :bar, style: content_md_creation_style, add_file_attributes: true)
bundle: :bar, style: content_md_creation_style, reading_order: reading_order, add_file_attributes: true)
end
end
end
Expand Down

0 comments on commit cd55022

Please sign in to comment.