bulkrax 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e466ce0a1d1fe4b2c3baa9a6a5356b0138b5e7c1f2e1b88a7d17b852257f6b46
4
- data.tar.gz: 52b585cd22870e2b4d586b3848cd48f8106f39a54341bc2aeba91a05079b9f0e
3
+ metadata.gz: 61886547fff51b48446b9dfaf420f14deea3fc86e9c5d8b44c1886087ee8086a
4
+ data.tar.gz: d19557cd24341cbd6001e835fff081dca349eeeab818b6b8bcf4c4cb91e5b692
5
5
  SHA512:
6
- metadata.gz: cbb4169d6956f98f3b27ac143f0f16f6ac1adb86fa66a7819fad73f28d45ba5a8578b306de8d4319112a2bf1e4b4edb4aeb3b149abfa0bd840b4eb19a1aa4172
7
- data.tar.gz: b06a77c964f82d2fa17b8cde3cff5413ceb0e9ab21eb9b7e0c299d6b42a3217308fc497474151f6b51022b7d2a48b2b2af4262a7d97941038aa6505b32e053d4
6
+ metadata.gz: d14c4c440b00f6fe0e689e506b77775b6bbfdf5e6a9c64c5310ccd84947a6f71880c52518575839534bb90be89cc7a198c9fd4d51831f6814f18380391abc8e2
7
+ data.tar.gz: 2c743fa2532fc672437240492faa2b6660194afff19c0ee27e6c6a9a8a402f7ae55ee0ecec84dad2ce474ecf86579218f47df578773e01d8409922f013cd9123
@@ -12,7 +12,8 @@ module Bulkrax
12
12
  def perform(entry_id, importer_run_id)
13
13
  @importer_run_id = importer_run_id
14
14
  entry = Entry.find(entry_id)
15
- parent_identifier = entry.raw_metadata[entry.related_parents_raw_mapping]&.strip
15
+ # e.g. "parents" or "parents_1"
16
+ parent_identifier = (entry.raw_metadata[entry.related_parents_raw_mapping] || entry.raw_metadata["#{entry.related_parents_raw_mapping}_1"])&.strip
16
17
 
17
18
  validate_parent!(parent_identifier)
18
19
 
@@ -57,7 +58,7 @@ module Bulkrax
57
58
  end
58
59
 
59
60
  def check_parent_exists!(parent_identifier)
60
- raise MissingParentError, %(Unable to find a record with the identifier "#{parent_identifier}") if parent_record.blank?
61
+ raise MissingParentError, %(Unable to find a record with the identifier "#{parent_identifier}") if parent_record.nil?
61
62
  end
62
63
 
63
64
  def check_parent_is_a_work!(parent_identifier)
@@ -66,8 +67,7 @@ module Bulkrax
66
67
  end
67
68
 
68
69
  def find_parent_record(parent_identifier)
69
- @parent_record ||= find_record(parent_identifier, importer_run_id)
70
- @parent_record = parent_record.last if parent_record.is_a? Array
70
+ _, @parent_record = find_record(parent_identifier, importer_run_id)
71
71
  end
72
72
  end
73
73
  end
@@ -264,6 +264,8 @@ module Bulkrax
264
264
 
265
265
  Dir["#{exporter_export_path}/**"].each do |folder|
266
266
  zip_path = "#{exporter_export_zip_path.split('/').last}_#{folder.split('/').last}.zip"
267
+ FileUtils.rm_rf("#{exporter_export_zip_path}/#{zip_path}")
268
+
267
269
  Zip::File.open(File.join("#{exporter_export_zip_path}/#{zip_path}"), create: true) do |zip_file|
268
270
  Dir["#{folder}/**/**"].each do |file|
269
271
  zip_file.add(file.sub("#{folder}/", ''), file)
@@ -283,6 +283,10 @@ module Bulkrax
283
283
  CsvFileSetEntry
284
284
  end
285
285
 
286
+ def valid_entry_types
287
+ ['Bulkrax::CsvCollectionEntry', 'Bulkrax::CsvFileSetEntry', 'Bulkrax::CsvEntry']
288
+ end
289
+
286
290
  # TODO: figure out why using the version of this method that's in the bagit parser
287
291
  # breaks specs for the "if importer?" line
288
292
  def total
@@ -325,6 +329,7 @@ module Bulkrax
325
329
  require 'open-uri'
326
330
  folder_count = 0
327
331
  sorted_entries = sort_entries(importerexporter.entries.uniq(&:identifier))
332
+ .select { |e| valid_entry_types.include?(e.type) }
328
333
 
329
334
  sorted_entries[0..limit || total].in_groups_of(records_split_count, false) do |group|
330
335
  folder_count += 1
@@ -342,6 +347,8 @@ module Bulkrax
342
347
 
343
348
  def store_files(identifier, folder_count)
344
349
  record = ActiveFedora::Base.find(identifier)
350
+ return unless record
351
+
345
352
  file_sets = record.file_set? ? Array.wrap(record) : record.file_sets
346
353
  file_sets << record.thumbnail if exporter.include_thumbnails && record.thumbnail.present? && record.work?
347
354
  file_sets.each do |fs|
@@ -391,12 +398,12 @@ module Bulkrax
391
398
  # always export models in the same order: work, collection, file set
392
399
  entries.sort_by do |entry|
393
400
  case entry.type
394
- when 'Bulkrax::CsvEntry'
395
- '0'
396
401
  when 'Bulkrax::CsvCollectionEntry'
397
402
  '1'
398
403
  when 'Bulkrax::CsvFileSetEntry'
399
404
  '2'
405
+ else
406
+ '0'
400
407
  end
401
408
  end
402
409
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulkrax
4
- VERSION = '4.1.1'
4
+ VERSION = '4.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulkrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman