bulkrax 9.2.0 → 9.3.0
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 +4 -4
- data/app/assets/javascripts/bulkrax/importers.js.erb +4 -2
- data/app/factories/bulkrax/valkyrie_object_factory.rb +24 -8
- data/app/jobs/bulkrax/create_relationships_job.rb +4 -1
- data/app/jobs/bulkrax/delete_and_import_job.rb +12 -4
- data/app/jobs/bulkrax/delete_file_set_job.rb +9 -0
- data/app/models/bulkrax/csv_entry.rb +6 -1
- data/app/models/bulkrax/entry.rb +9 -3
- data/app/models/bulkrax/exporter.rb +7 -2
- data/app/models/bulkrax/importer.rb +7 -2
- data/app/models/bulkrax/oai_entry.rb +5 -1
- data/app/models/bulkrax/rdf_entry.rb +5 -1
- data/app/models/bulkrax/status.rb +6 -1
- data/app/models/bulkrax/xml_entry.rb +5 -1
- data/app/models/concerns/bulkrax/export_behavior.rb +2 -2
- data/app/views/bulkrax/importers/_file_uploader.html.erb +1 -1
- data/lib/bulkrax/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b2230355bb1411a1ef0d5a17c70a957f87c88c0b1a5254fda5646eb89a07bc1
|
4
|
+
data.tar.gz: b8211fe255a2a094854b9a0174b3b2154de093c53f838befdc2c8f8246d7731b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555612ee946fcf1b48a353f93e20fafbe3c04052f28c99e129f3af7a216022416d4fcc3a51dca25943d5c10b2a86355871e1a788b5ab3046093cdf808efa7644
|
7
|
+
data.tar.gz: 3fae6e18a3bd810446dc7fb0dc2486e283ad74f28bad18c75426cc5589386b1fa32e05210eb1367fead50acf0649b7de64dd52a9c208b2450002fb10ece33e0d
|
@@ -15,9 +15,11 @@ function prepBulkrax(event) {
|
|
15
15
|
// Initialize the uploader only if hyraxUploader is defined
|
16
16
|
if (typeof $.fn.hyraxUploader === 'function') {
|
17
17
|
// Initialize the uploader
|
18
|
-
$('.fileupload-bulkrax')
|
18
|
+
var uploader = $('.fileupload-bulkrax');
|
19
|
+
var maxFileSize = uploader.data('max-file-size');
|
20
|
+
uploader.hyraxUploader({
|
19
21
|
maxNumberOfFiles: 1,
|
20
|
-
maxFileSize:
|
22
|
+
maxFileSize: maxFileSize
|
21
23
|
});
|
22
24
|
|
23
25
|
// Function to toggle 'required' attribute based on uploaded files
|
@@ -236,7 +236,8 @@ module Bulkrax
|
|
236
236
|
# @input [Fileset or FileMetadata]
|
237
237
|
# @return [FileMetadata] the original file
|
238
238
|
def self.original_file(fileset:)
|
239
|
-
fileset.
|
239
|
+
return fileset if fileset.is_a?(Hyrax::FileMetadata)
|
240
|
+
fileset.try(:original_file)
|
240
241
|
end
|
241
242
|
|
242
243
|
##
|
@@ -293,6 +294,10 @@ module Bulkrax
|
|
293
294
|
def delete(user)
|
294
295
|
obj = find
|
295
296
|
raise ObjectFactoryInterface::ObjectNotFoundError, "Object not found to delete" unless obj
|
297
|
+
# delete the file sets when we delete a work
|
298
|
+
# This has to be done before the work is deleted or we can't find them
|
299
|
+
# via the custom query
|
300
|
+
destroy_existing_files(object: obj)
|
296
301
|
|
297
302
|
Hyrax.persister.delete(resource: obj)
|
298
303
|
Hyrax.index_adapter.delete(resource: obj)
|
@@ -330,9 +335,19 @@ module Bulkrax
|
|
330
335
|
nil
|
331
336
|
end
|
332
337
|
|
338
|
+
# @note We perform the transaction against the *parent* here, because the FileSets are generated and updated in relationship with their parent, not in isolation
|
333
339
|
def create_file_set(attrs)
|
334
|
-
|
335
|
-
|
340
|
+
attrs = HashWithIndifferentAccess.new(attrs)
|
341
|
+
parent_object = find_record(attributes[related_parents_parsed_mapping].first, importer_run_id).last
|
342
|
+
perform_transaction_for(object: parent_object, attrs: {}) do
|
343
|
+
fs_attrs = attrs.merge(attributes).symbolize_keys
|
344
|
+
uploaded_files, = prep_fileset_content(attrs)
|
345
|
+
transactions['change_set.update_work']
|
346
|
+
.with_step_args(
|
347
|
+
'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: [fs_attrs] },
|
348
|
+
'work_resource.save_acl' => { permissions_params: [attrs.try('visibility') || 'open'].compact }
|
349
|
+
)
|
350
|
+
end
|
336
351
|
end
|
337
352
|
|
338
353
|
def create_work(attrs)
|
@@ -547,8 +562,9 @@ module Bulkrax
|
|
547
562
|
end
|
548
563
|
|
549
564
|
# @Override Destroy existing files with Hyrax::Transactions
|
550
|
-
def destroy_existing_files
|
565
|
+
def destroy_existing_files(object: @object)
|
551
566
|
existing_files = Hyrax.custom_queries.find_child_file_sets(resource: object)
|
567
|
+
return if existing_files.empty?
|
552
568
|
|
553
569
|
existing_files.each do |fs|
|
554
570
|
transactions["file_set.destroy"]
|
@@ -558,10 +574,10 @@ module Bulkrax
|
|
558
574
|
.value!
|
559
575
|
end
|
560
576
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
577
|
+
object.member_ids = object.member_ids.reject { |m| existing_files.detect { |f| f.id == m } }
|
578
|
+
object.rendering_ids = []
|
579
|
+
object.representative_id = nil
|
580
|
+
object.thumbnail_id = nil
|
565
581
|
end
|
566
582
|
|
567
583
|
def transform_attributes(update: false)
|
@@ -136,6 +136,7 @@ module Bulkrax
|
|
136
136
|
# When the parent is a collection, we save the relationship on each child.
|
137
137
|
# The parent does not need to be saved, as the relationship is stored on the child.
|
138
138
|
# but we do reindex the parent after all the children are added.
|
139
|
+
# rubocop:disable Layout/RescueEnsureAlignment
|
139
140
|
def process_parent_as_collection(parent_record:, parent_identifier:)
|
140
141
|
ActiveRecord::Base.uncached do
|
141
142
|
Bulkrax::PendingRelationship.where(parent_id: parent_identifier, importer_run_id: @importer_run_id)
|
@@ -151,7 +152,6 @@ module Bulkrax
|
|
151
152
|
@errors << e
|
152
153
|
end
|
153
154
|
end
|
154
|
-
|
155
155
|
# if collection members were added, we reindex the collection
|
156
156
|
# The collection members have already saved the relationships
|
157
157
|
# To index the parent, we want to make sure we have the latest version of the parent,
|
@@ -161,6 +161,7 @@ module Bulkrax
|
|
161
161
|
Bulkrax.object_factory.update_index(resources: [reloaded_parent])
|
162
162
|
Bulkrax.object_factory.publish(event: 'object.membership.updated', object: reloaded_parent, user: @user)
|
163
163
|
end
|
164
|
+
# rubocop:enable Layout/RescueEnsureAlignment
|
164
165
|
|
165
166
|
# When the parent is a work, we save the relationship on the parent.
|
166
167
|
# We prefer to save all of the member relationships and then save the parent once. Concurrent
|
@@ -168,6 +169,7 @@ module Bulkrax
|
|
168
169
|
# record while we are adding the children to it.
|
169
170
|
# However the locking appears to not be working so as a workaround we will save each member as we go,
|
170
171
|
# but only index the parent once at the end.
|
172
|
+
# rubocop:disable Layout/RescueEnsureAlignment
|
171
173
|
def process_parent_as_work(parent_record:, parent_identifier:)
|
172
174
|
conditionally_acquire_lock_for(parent_record.id.to_s) do
|
173
175
|
ActiveRecord::Base.uncached do
|
@@ -193,6 +195,7 @@ module Bulkrax
|
|
193
195
|
end
|
194
196
|
end
|
195
197
|
end
|
198
|
+
# rubocop:enable Layout/RescueEnsureAlignment
|
196
199
|
|
197
200
|
# NOTE: the child changes are saved in the object factory.
|
198
201
|
def add_to_collection(relationship:, parent_record:, ability:)
|
@@ -5,10 +5,13 @@ module Bulkrax
|
|
5
5
|
queue_as :import
|
6
6
|
|
7
7
|
def perform(entry, importer_run)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
self.class::
|
8
|
+
# Delete the object if it exists, then reimport it.
|
9
|
+
# If the object doesn't exist, just reimport it.
|
10
|
+
begin
|
11
|
+
status = self.class::DELETE_CLASS.perform_now(entry, importer_run)
|
12
|
+
reimport(entry, importer_run) if status.status_message == "Deleted"
|
13
|
+
rescue Bulkrax::ObjectFactoryInterface::ObjectNotFoundError
|
14
|
+
reimport(entry, importer_run)
|
12
15
|
end
|
13
16
|
|
14
17
|
rescue => e
|
@@ -16,5 +19,10 @@ module Bulkrax
|
|
16
19
|
# this causes caught exception to be reraised
|
17
20
|
raise
|
18
21
|
end
|
22
|
+
|
23
|
+
def reimport(entry, importer_run)
|
24
|
+
entry = Bulkrax::Entry.find(entry.id) # maximum reload
|
25
|
+
self.class::IMPORT_CLASS.perform_now(entry.id, importer_run.id)
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
@@ -3,7 +3,16 @@
|
|
3
3
|
module Bulkrax
|
4
4
|
class DeleteFileSetJob < DeleteJob
|
5
5
|
def perform(entry, importer_run)
|
6
|
+
# Ensure the entry has metadata built for delete if it
|
7
|
+
# doesn't already so it can be found for deletion.
|
8
|
+
if entry.respond_to?(:build_metadata_for_delete) &&
|
9
|
+
entry.parsed_metadata.nil? &&
|
10
|
+
entry.raw_metadata.present?
|
11
|
+
entry.build_metadata_for_delete
|
12
|
+
entry.save!
|
13
|
+
end
|
6
14
|
file_set = entry.factory.find
|
15
|
+
|
7
16
|
if file_set
|
8
17
|
parent = file_set.parent
|
9
18
|
if parent&.respond_to?(:ordered_members)
|
@@ -22,7 +22,12 @@ module Bulkrax
|
|
22
22
|
super(message)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
|
+
if Rails.version < '7.1'
|
27
|
+
serialize :raw_metadata, Bulkrax::NormalizedJson
|
28
|
+
else
|
29
|
+
serialize :raw_metadata, coder: Bulkrax::NormalizedJson
|
30
|
+
end
|
26
31
|
|
27
32
|
def self.fields_from_data(data)
|
28
33
|
data.headers.flatten.compact.uniq
|
data/app/models/bulkrax/entry.rb
CHANGED
@@ -18,9 +18,15 @@ module Bulkrax
|
|
18
18
|
alias importer importerexporter
|
19
19
|
alias exporter importerexporter
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
if Rails.version < '7.1'
|
22
|
+
serialize :parsed_metadata, Bulkrax::NormalizedJson
|
23
|
+
# Do not serialize raw_metadata as so we can support xml or other formats
|
24
|
+
serialize :collection_ids, Array
|
25
|
+
else
|
26
|
+
serialize :parsed_metadata, coder: Bulkrax::NormalizedJson
|
27
|
+
# Do not serialize raw_metadata as so we can support xml or other formats
|
28
|
+
serialize :collection_ids, coder: YAML, type: Array
|
29
|
+
end
|
24
30
|
|
25
31
|
paginates_per 5
|
26
32
|
|
@@ -4,8 +4,13 @@ module Bulkrax
|
|
4
4
|
include Bulkrax::ImporterExporterBehavior
|
5
5
|
include Bulkrax::StatusInfo
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
if Rails.version < '7.1'
|
8
|
+
serialize :parser_fields, JSON
|
9
|
+
serialize :field_mapping, JSON
|
10
|
+
else
|
11
|
+
serialize :parser_fields, coder: JSON
|
12
|
+
serialize :field_mapping, coder: JSON
|
13
|
+
end
|
9
14
|
|
10
15
|
belongs_to :user
|
11
16
|
has_many :exporter_runs, dependent: :destroy
|
@@ -5,8 +5,13 @@ module Bulkrax
|
|
5
5
|
include Bulkrax::ImporterExporterBehavior
|
6
6
|
include Bulkrax::StatusInfo
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
if Rails.version < '7.1'
|
9
|
+
serialize :parser_fields, JSON
|
10
|
+
serialize :field_mapping, JSON
|
11
|
+
else
|
12
|
+
serialize :parser_fields, coder: JSON
|
13
|
+
serialize :field_mapping, coder: JSON
|
14
|
+
end
|
10
15
|
|
11
16
|
belongs_to :user
|
12
17
|
has_many :importer_runs, dependent: :destroy
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
module Bulkrax
|
4
4
|
class OaiEntry < Entry
|
5
|
-
|
5
|
+
if Rails.version < '7.1'
|
6
|
+
serialize :raw_metadata, Bulkrax::NormalizedJson
|
7
|
+
else
|
8
|
+
serialize :raw_metadata, coder: Bulkrax::NormalizedJson
|
9
|
+
end
|
6
10
|
|
7
11
|
delegate :record, to: :raw_record
|
8
12
|
|
@@ -3,7 +3,11 @@
|
|
3
3
|
unless ENV.fetch('BULKRAX_NO_RDF', 'false').to_s == 'true'
|
4
4
|
module Bulkrax
|
5
5
|
class RdfEntry < Entry
|
6
|
-
|
6
|
+
if Rails.version < '7.1'
|
7
|
+
serialize :raw_metadata, Bulkrax::NormalizedJson
|
8
|
+
else
|
9
|
+
serialize :raw_metadata, coder: Bulkrax::NormalizedJson
|
10
|
+
end
|
7
11
|
|
8
12
|
def self.read_data(path)
|
9
13
|
RDF::Reader.open(path)
|
@@ -4,7 +4,12 @@ module Bulkrax
|
|
4
4
|
class Status < ApplicationRecord
|
5
5
|
belongs_to :statusable, polymorphic: true, denormalize: { fields: %i[status_message error_class], if: :latest? }
|
6
6
|
belongs_to :runnable, polymorphic: true
|
7
|
-
|
7
|
+
|
8
|
+
if Rails.version < '7.1'
|
9
|
+
serialize :error_backtrace, Array
|
10
|
+
else
|
11
|
+
serialize :error_backtrace, coder: YAML, type: Array
|
12
|
+
end
|
8
13
|
|
9
14
|
scope :for_importers, -> { where(statusable_type: 'Bulkrax::Importer') }
|
10
15
|
scope :for_exporters, -> { where(statusable_type: 'Bulkrax::Exporter') }
|
@@ -3,7 +3,11 @@
|
|
3
3
|
module Bulkrax
|
4
4
|
# Generic XML Entry
|
5
5
|
class XmlEntry < Entry
|
6
|
-
|
6
|
+
if Rails.version < '7.1'
|
7
|
+
serialize :raw_metadata, Bulkrax::NormalizedJson
|
8
|
+
else
|
9
|
+
serialize :raw_metadata, coder: Bulkrax::NormalizedJson
|
10
|
+
end
|
7
11
|
|
8
12
|
def self.fields_from_data(data); end
|
9
13
|
|
@@ -27,10 +27,10 @@ module Bulkrax
|
|
27
27
|
# Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters
|
28
28
|
def filename(file_set)
|
29
29
|
# return if there are no files on the fileset
|
30
|
-
|
30
|
+
file = Bulkrax.object_factory.original_file(fileset: file_set)
|
31
|
+
return '' if file.blank?
|
31
32
|
|
32
33
|
fn = Bulkrax.object_factory.filename_for(fileset: file_set)
|
33
|
-
file = Bulkrax.object_factory.original_file(fileset: file_set)
|
34
34
|
ext = file_extension(file: file, filename: fn)
|
35
35
|
|
36
36
|
# Prepend the file_set id to ensure a unique filename
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="fileupload-bulkrax">
|
1
|
+
<div class="fileupload-bulkrax" data-max-file-size="<%= (defined?(Hyrax) && Hyrax.config.uploader[:maxFileSize]) || 524288000 %>">
|
2
2
|
<noscript><input type="hidden" name="redirect" value="<%= main_app.root_path %>" /></noscript>
|
3
3
|
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
|
4
4
|
<div class="fileupload-buttonbar">
|
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: 9.
|
4
|
+
version: 9.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Kaufman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.1.6
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 8.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 5.1.6
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 8.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bagit
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -527,7 +527,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
527
527
|
- !ruby/object:Gem::Version
|
528
528
|
version: '0'
|
529
529
|
requirements: []
|
530
|
-
rubygems_version: 3.
|
530
|
+
rubygems_version: 3.4.10
|
531
531
|
signing_key:
|
532
532
|
specification_version: 4
|
533
533
|
summary: Import and export tool for Hyrax and Hyku
|