Skip to content

Commit

Permalink
Merge pull request #375 from sul-dlss/manifest_cols
Browse files Browse the repository at this point in the history
remove manifest_cols
  • Loading branch information
jmartin-sul committed Sep 28, 2018
2 parents e9c8697 + 4e58d29 commit ed42db9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 38 deletions.
14 changes: 5 additions & 9 deletions app/lib/pre_assembly/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Bundle
:content_exclusion,
:content_md_creation,
:content_structure,
:manifest_cols,
:manifest_rows,
:path_in_bundle,
:progress_log_file,
Expand Down Expand Up @@ -89,8 +88,8 @@ def digital_objects
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 = manifest_cols[:label] ? r[manifest_cols[:label]] : ''
dobj.source_id = r[manifest_cols[:source_id]] if manifest_cols[:source_id]
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
Expand All @@ -102,11 +101,8 @@ def digital_objects
# manifest columns. The column name to use is configured by the
# user invoking the pre-assembly script.
def discover_containers_via_manifest
raise ':manifest_cols must be specified' unless manifest_cols
# TODO: note that manifest_cols is a constant in bundle_context
obj_sym = manifest_cols[:object_container].to_sym
manifest_rows.each_with_index { |r, i| raise "Missing #{obj_sym} in row #{i}: #{r}" unless r[obj_sym] }
manifest_rows.map { |r| path_in_bundle r[obj_sym] }
manifest_rows.each_with_index { |r, i| raise "Missing 'object' in row #{i}: #{r}" unless r[:object] }
manifest_rows.map { |r| path_in_bundle r[:object] }
end

# A method to discover object containers or stageable items.
Expand Down Expand Up @@ -168,7 +164,7 @@ def load_checksums(dobj)

# confirm that the all of the source IDs supplied within a manifest are locally unique
def manifest_sourceids_unique?
all_source_ids = manifest_rows.collect { |r| r[manifest_cols[:source_id]] }
all_source_ids = manifest_rows.collect { |r| r['sourceid'] }
all_source_ids.size == all_source_ids.uniq.size
end

Expand Down
10 changes: 0 additions & 10 deletions app/models/bundle_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ def manifest_rows
@manifest_rows ||= CsvImporter.parse_to_hash(path_in_bundle(manifest))
end

# TODO: make this simpler / remove it (#329)
def manifest_cols
{
label: 'label', # only used by SMPL manifests
source_id: 'sourceid', # only used by SMPL manifests
object_container: 'object', # object referring to filename or foldername
druid: 'druid'
}
end

private

def default_enums
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 @@ -63,7 +63,6 @@
describe '#object_discovery: discovery via manifest and crawl' do
it 'discover_containers_via_manifest() should return expected information' do
vals = %w[123.tif 456.tif 789.tif]
flat_dir_images.manifest_cols[:object_container] = :col_foo
allow(flat_dir_images).to receive(:manifest_rows).and_return(vals.map { |v| { object: v } })
expect(flat_dir_images.discover_containers_via_manifest).to eq(vals.map { |v| flat_dir_images.path_in_bundle v })
end
Expand Down
11 changes: 0 additions & 11 deletions spec/models/bundle_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@
end
end

describe 'manifest_cols' do
it 'sets the column names' do
expect(bc.manifest_cols).to eq(
label: 'label',
source_id: 'sourceid',
object_container: 'object', # object referring to filename or foldername
druid: 'druid'
)
end
end

describe '#verify_output_dir (private method)' do
before { FileUtils.mkdir_p(Settings.job_output_parent_dir) }

Expand Down
10 changes: 3 additions & 7 deletions spec/test_data/exemplar_templates/TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,9 @@ checksums_file: 'checksums.txt' # A provider checksum file (in default md
desc_md_template: 'mods_template.xml' # An optional descriptive metadata XML template to use in conjunction with the manifest. Path can be absolute or relative to the bundle path.

####
# You must indicate the column names of certain fields in the CSV file.
# These should always be lowercase. Note that if your project is using a manifest for object discovery and has objects already registered, you will
# need a column called "druid" in addition to the columns below. The "source_id" and "label" columns must exist in this case but can be blank (since objects are already registered).
manifest_cols:
object_container: 'filename' # Always required, indicates the column name containing the filename (single file per object) or folder name (multiple files per object) relative to the bundle directory.
source_id: 'sourceid' # optional
label: 'label' # optional
# The CSV file is expected with columns (always lowercase):
# - 'druid', required
# - 'object', required

####
# Attributes related to content metadata generation.
Expand Down

0 comments on commit ed42db9

Please sign in to comment.