bulkrax 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11a3549082d5c6493135ed66fe5729474b4303bb8dec30ee20a8e00fe66f563d
|
4
|
+
data.tar.gz: '08a021e73dc020a2791d1cf6e7f086a2cebdc5b511ffa2c83db004f31592a6af'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '049aaefb66b149b6e57857f75ded3408a910578cdbbd3c8094a85fedeffc2416124e0369e22cab136e2620cd56c9516f7fcf9bf906897682f09f8b32b2ef9dcc'
|
7
|
+
data.tar.gz: bf1a0ff60588f3b66295f6eb7941c80b4c2cb06cbbc68755145e5ec1688906103a8efd6e7ebb6fab5137460de9f1d3d6b5fe8191beac47cd8241ce0c35b250b2
|
@@ -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
|
-
|
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.
|
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
|
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
|
@@ -75,7 +75,7 @@ module Bulkrax
|
|
75
75
|
def get_field_mapping_hash_for(key)
|
76
76
|
return instance_variable_get("@#{key}_hash") if instance_variable_get("@#{key}_hash").present?
|
77
77
|
|
78
|
-
mapping = importerexporter.field_mapping
|
78
|
+
mapping = importerexporter.field_mapping.is_a?(Hash) ? importerexporter.field_mapping : {}
|
79
79
|
instance_variable_set(
|
80
80
|
"@#{key}_hash",
|
81
81
|
mapping&.with_indifferent_access&.select { |_, h| h.key?(key) }
|
@@ -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
|
@@ -324,7 +328,8 @@ module Bulkrax
|
|
324
328
|
def write_files
|
325
329
|
require 'open-uri'
|
326
330
|
folder_count = 0
|
327
|
-
sorted_entries = sort_entries(importerexporter.entries)
|
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|
|
@@ -356,6 +363,8 @@ module Bulkrax
|
|
356
363
|
f.close
|
357
364
|
end
|
358
365
|
end
|
366
|
+
rescue Ldp::Gone
|
367
|
+
return
|
359
368
|
end
|
360
369
|
|
361
370
|
def export_key_allowed(key)
|
@@ -391,12 +400,12 @@ module Bulkrax
|
|
391
400
|
# always export models in the same order: work, collection, file set
|
392
401
|
entries.sort_by do |entry|
|
393
402
|
case entry.type
|
394
|
-
when 'Bulkrax::CsvEntry'
|
395
|
-
'0'
|
396
403
|
when 'Bulkrax::CsvCollectionEntry'
|
397
404
|
'1'
|
398
405
|
when 'Bulkrax::CsvFileSetEntry'
|
399
406
|
'2'
|
407
|
+
else
|
408
|
+
'0'
|
400
409
|
end
|
401
410
|
end
|
402
411
|
end
|
data/lib/bulkrax/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulkrax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Kaufman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|