diff --git a/app/lib/pre_assembly/bundle.rb b/app/lib/pre_assembly/bundle.rb index 20d24446..140b2249 100644 --- a/app/lib/pre_assembly/bundle.rb +++ b/app/lib/pre_assembly/bundle.rb @@ -15,7 +15,6 @@ class Bundle :content_exclusion, :content_md_creation, :content_structure, - :manifest_cols, :manifest_rows, :path_in_bundle, :progress_log_file, @@ -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 @@ -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. @@ -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 diff --git a/app/models/bundle_context.rb b/app/models/bundle_context.rb index b3a4dd58..833137fe 100644 --- a/app/models/bundle_context.rb +++ b/app/models/bundle_context.rb @@ -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 diff --git a/spec/lib/pre_assembly/bundle_spec.rb b/spec/lib/pre_assembly/bundle_spec.rb index ae1d58f2..fce26a25 100644 --- a/spec/lib/pre_assembly/bundle_spec.rb +++ b/spec/lib/pre_assembly/bundle_spec.rb @@ -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 diff --git a/spec/models/bundle_context_spec.rb b/spec/models/bundle_context_spec.rb index 93238c98..4b5647ad 100644 --- a/spec/models/bundle_context_spec.rb +++ b/spec/models/bundle_context_spec.rb @@ -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) } diff --git a/spec/test_data/exemplar_templates/TEMPLATE.yaml b/spec/test_data/exemplar_templates/TEMPLATE.yaml index 07df714a..9fd37123 100644 --- a/spec/test_data/exemplar_templates/TEMPLATE.yaml +++ b/spec/test_data/exemplar_templates/TEMPLATE.yaml @@ -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.