Skip to content

Commit

Permalink
Merge fce576d into 6c581d5
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 5, 2019
2 parents 6c581d5 + fce576d commit f82e1ed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 32 deletions.
23 changes: 10 additions & 13 deletions app/lib/pre_assembly/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,16 @@ def object_filenames_unique?(dobj)
# @return [Array<DigitalObject>]
def digital_objects
@digital_objects ||= discover_containers_via_manifest.each_with_index.map do |c, i|
params = {
container: c,
stageable_items: discover_items_via_crawl(c)
}
params[:object_files] = discover_object_files(params[:stageable_items])
DigitalObject.new(self, params).tap do |dobj|
r = manifest_rows[i]
# Get label and source_id from column names declared in YAML config.
dobj.label = r['label'] || ''
dobj.source_id = r['sourceid']
# Also store a hash of all values from the manifest row, using column names as keys.
dobj.manifest_row = r
end
stageable_items = discover_items_via_crawl(c)
row = manifest_rows[i]

DigitalObject.new(self,
container: c,
stageable_items: stageable_items,
object_files: discover_object_files(stageable_items),
label: row.fetch('label', ''),
source_id: row['sourceid'],
pid: row[:druid])
end
end

Expand Down
31 changes: 13 additions & 18 deletions app/lib/pre_assembly/digital_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module PreAssembly
class DigitalObject
include PreAssembly::Logging

attr_reader :bundle, :stageable_items, :object_files
attr_reader :bundle, :stageable_items, :object_files,
:label, :pid, :source_id

delegate :bundle_dir,
:content_md_creation,
Expand All @@ -13,28 +14,29 @@ class DigitalObject
to: :bundle

attr_accessor :container,
:label,
:manifest_row,
:pre_assem_finished,
:source_id
:pre_assem_finished

attr_writer :dor_object

# @param [PreAssembly::Bundle] bundle
# @param [String] container the identifier (non-namespaced)
# @param [Array<String>] stageable_items items to stage
# @param [Array<ObjectFile>] object_files path to files that are part of the object
def initialize(bundle, container: nil, stageable_items: nil, object_files: nil)
# @param [String] label The label for this object
# @param [String] pid The identifier for the item
# @param [String] source_id The source identifier
# rubocop:disable Metrics/ParameterLists
def initialize(bundle, container: nil, stageable_items: nil, object_files: nil,
label: nil, pid: nil, source_id: nil)
@bundle = bundle
@container = container
@stageable_items = stageable_items
@object_files = object_files
setup
end

def setup
self.label = 'Unknown' # used for registration when no label is provided in the manifest
@label = label
@pid = pid
@source_id = source_id
end
# rubocop:enable Metrics/ParameterLists

def stager(source, destination)
if staging_style_symlink
Expand Down Expand Up @@ -89,13 +91,6 @@ def druid
@druid ||= DruidTools::Druid.new(pid)
end

def pid
@pid ||= begin
raise 'manifest_row is required' unless manifest_row
manifest_row[:druid]
end
end

def query_dor_by_barcode(barcode)
Dor::SearchService.query_by_id barcode: barcode
end
Expand Down
1 change: 0 additions & 1 deletion spec/lib/pre_assembly/bundle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
expect(dobj.label).to be_a(String)
expect(dobj.label).not_to eq('Unknown') # hardcoded in class
expect(dobj.source_id).to be_a(String)
expect(dobj.manifest_row).to be_a(Hash)
end
end
end
Expand Down

0 comments on commit f82e1ed

Please sign in to comment.