bulkrax 8.3.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/bulkrax/import_export.scss +5 -0
  3. data/app/controllers/concerns/bulkrax/datatables_behavior.rb +1 -1
  4. data/app/factories/bulkrax/object_factory.rb +4 -1
  5. data/app/factories/bulkrax/object_factory_interface.rb +2 -2
  6. data/app/factories/bulkrax/valkyrie_object_factory.rb +4 -2
  7. data/app/jobs/bulkrax/export_work_job.rb +1 -1
  8. data/app/models/bulkrax/status.rb +1 -1
  9. data/app/models/concerns/bulkrax/export_behavior.rb +8 -4
  10. data/app/parsers/bulkrax/csv_parser.rb +5 -2
  11. data/app/parsers/bulkrax/parser_export_record_set.rb +1 -1
  12. data/app/views/bulkrax/entries/show.html.erb +2 -2
  13. data/app/views/bulkrax/exporters/_form.html.erb +1 -1
  14. data/app/views/bulkrax/exporters/edit.html.erb +2 -2
  15. data/app/views/bulkrax/exporters/index.html.erb +2 -2
  16. data/app/views/bulkrax/exporters/new.html.erb +2 -2
  17. data/app/views/bulkrax/exporters/show.html.erb +2 -2
  18. data/app/views/bulkrax/importers/_form.html.erb +1 -1
  19. data/app/views/bulkrax/importers/edit.html.erb +3 -3
  20. data/app/views/bulkrax/importers/index.html.erb +2 -2
  21. data/app/views/bulkrax/importers/new.html.erb +2 -2
  22. data/app/views/bulkrax/importers/show.html.erb +2 -2
  23. data/app/views/bulkrax/importers/upload_corrected_entries.html.erb +2 -2
  24. data/db/migrate/20240806161142_add_file_name_to_uploaded_files.rb +1 -1
  25. data/db/migrate/20241203010707_entry_error_denormalization.rb +7 -0
  26. data/db/migrate/20241205212513_faster_first_entry.rb +7 -0
  27. data/lib/bulkrax/version.rb +1 -1
  28. data/lib/bulkrax.rb +1 -1
  29. data/lib/tasks/bulkrax_tasks.rake +1 -1
  30. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a409c17f35bc09ef0a8c63d06a064d01fbff68a0e4c0b91c9bfaed45d6e8169
4
- data.tar.gz: 7fad94124795ff133b83d05030c550f2a52f808ac017fdd3a436c17ce039cd01
3
+ metadata.gz: 2d5a97916d5e7efb9a589f19f850af0c4c2bae1d0197032cdc449fa32ed9470e
4
+ data.tar.gz: 32e1ed599b25b75b238acff7bd8f24fcc8fe9ea71d09e8d10fa88383c41c79ba
5
5
  SHA512:
6
- metadata.gz: 65280762e81baa620e73d965d5e7c58ec4ccb40d303c00cf634e7f9b3b3850e541cc9964900ce7b9aec9f6be1a7fe81dd9781db5b74209a9f8661f5f8a96f595
7
- data.tar.gz: e91e65f6de8edc1640dd9b6e75c246fff4fd0812a3f87f6b4600dd9c95afc095be6076c9a80c5bca50ccc73c3831fc0a30c1160b46f18c483a6d68277bf762a8
6
+ metadata.gz: 23c692b80ac68dc92d67a95635496656e8d2e1e411ac788338d71d55494d34204ea49702f4e14addb623ee9f818e16156e65ecffe1da993d85662a53ad86a44f
7
+ data.tar.gz: 5583e8ae05b357a28fec59474badf3a26d68bf2b27ed2b37db94ea532b65957a949371a2924694ba8f5e1c9e5dd7bbd8158c8bd9d0e7a023edfd4105b88b2fc3
@@ -1,3 +1,8 @@
1
+ .bulkrax-card-footer {
2
+ min-height: 60px;
3
+
4
+ }
5
+
1
6
  div.importer_parser_fields_file_style span.radio {
2
7
  display: inline;
3
8
  margin-right: 20px;
@@ -132,7 +132,7 @@ module Bulkrax
132
132
  status_message: status_message_for(e),
133
133
  type: e.type,
134
134
  updated_at: e.updated_at,
135
- errors: e.latest_status&.error_class&.present? ? view_context.link_to(e.latest_status.error_class, view_context.item_entry_path(item, e), title: e.latest_status.error_message) : "",
135
+ errors: e.status_message == 'Failed' ? view_context.link_to(e.error_class, view_context.item_entry_path(item, e)) : "",
136
136
  actions: entry_util_links(e, item)
137
137
  }
138
138
  end
@@ -165,7 +165,10 @@ module Bulkrax
165
165
  end
166
166
 
167
167
  def delete(_user)
168
- find&.delete(eradicate: true)
168
+ obj = find
169
+ return false unless obj
170
+
171
+ obj.delete(eradicate: true)
169
172
  end
170
173
 
171
174
  private
@@ -319,9 +319,9 @@ module Bulkrax
319
319
  #
320
320
  # @return [Object] when we've found the object by the entry's :id or by it's
321
321
  # source_identifier
322
- # @return [FalseClass] when we cannot find the object.
322
+ # @return [NilClass] when we cannot find the object.
323
323
  def find
324
- find_by_id || search_by_identifier || false
324
+ find_by_id || search_by_identifier || nil
325
325
  end
326
326
 
327
327
  ##
@@ -81,7 +81,8 @@ module Bulkrax
81
81
  return false unless field_supported?(field: field, model: model)
82
82
 
83
83
  if model.respond_to?(:schema)
84
- dry_type = model.schema.key(field.to_sym)
84
+ schema = model.new.singleton_class.schema || model.schema
85
+ dry_type = schema.key(field.to_sym)
85
86
  return true if dry_type.respond_to?(:primitive) && dry_type.primitive == Array
86
87
 
87
88
  false
@@ -193,7 +194,8 @@ module Bulkrax
193
194
  @schema_properties_map ||= {}
194
195
 
195
196
  klass_key = klass.name
196
- @schema_properties_map[klass_key] = klass.schema.map { |k| k.name.to_s } unless @schema_properties_map.key?(klass_key)
197
+ schema = klass.new.singleton_class.schema || klass.schema
198
+ @schema_properties_map[klass_key] = schema.map { |k| k.name.to_s } unless @schema_properties_map.key?(klass_key)
197
199
 
198
200
  @schema_properties_map[klass_key]
199
201
  end
@@ -26,7 +26,7 @@ module Bulkrax
26
26
  end
27
27
  # rubocop:enable Rails/SkipsModelValidations
28
28
  end
29
- return entry if exporter_run.enqueued_records.positive?
29
+ return entry if exporter_run.reload.enqueued_records.positive?
30
30
 
31
31
  if exporter_run.failed_records.positive?
32
32
  exporter_run.exporter.set_status_info('Complete (with failures)')
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Bulkrax
4
4
  class Status < ApplicationRecord
5
- belongs_to :statusable, polymorphic: true, denormalize: { fields: %i[status_message], if: :latest? }
5
+ belongs_to :statusable, polymorphic: true, denormalize: { fields: %i[status_message error_class], if: :latest? }
6
6
  belongs_to :runnable, polymorphic: true
7
7
  serialize :error_backtrace, Array
8
8
 
@@ -26,11 +26,15 @@ module Bulkrax
26
26
 
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
- # NOTE: Will this work with Valkyrie?
30
29
  return if file_set.original_file.blank?
31
- fn = file_set.original_file.file_name.first
32
- mime = ::Marcel::MimeType.for(file_set.original_file.mime_type)
33
- ext_mime = ::Marcel::MimeType.for(file_set.original_file.file_name)
30
+ if file_set.original_file.respond_to?(:original_filename) # valkyrie
31
+ fn = file_set.original_file.original_filename
32
+ mime = ::Marcel::MimeType.for(file_set.original_file.file.io)
33
+ else # original non valkyrie version
34
+ fn = file_set.original_file.file_name.first
35
+ mime = ::Marcel::MimeType.for(declared_type: file_set.original_file.mime_type)
36
+ end
37
+ ext_mime = ::Marcel::MimeType.for(name: fn)
34
38
  if fn.include?(file_set.id) || importerexporter.metadata_only?
35
39
  filename = "#{fn}.#{mime.to_sym}"
36
40
  filename = fn if mime.to_s == ext_mime.to_s
@@ -244,7 +244,10 @@ module Bulkrax
244
244
  record = Bulkrax.object_factory.find(identifier)
245
245
  return unless record
246
246
 
247
- file_sets = record.file_set? ? Array.wrap(record) : record.file_sets
247
+ file_sets = Array.wrap(record) if record.file_set?
248
+ if file_sets.nil? # for valkyrie
249
+ file_sets = record.respond_to?(:file_sets) ? record.file_sets : record.members&.select(&:file_set?)
250
+ end
248
251
  file_sets << record.thumbnail if exporter.include_thumbnails && record.thumbnail.present? && record.work?
249
252
  file_sets.each do |fs|
250
253
  path = File.join(exporter_export_path, folder_count, 'files')
@@ -252,7 +255,7 @@ module Bulkrax
252
255
  file = filename(fs)
253
256
  next if file.blank? || fs.original_file.blank?
254
257
 
255
- io = open(fs.original_file.uri)
258
+ io = fs.original_file.respond_to?(:uri) ? open(fs.original_file.uri) : fs.original_file.file.io
256
259
  File.open(File.join(path, file), 'wb') do |f|
257
260
  f.write(io.read)
258
261
  f.close
@@ -173,7 +173,7 @@ module Bulkrax
173
173
  # @see https://github.com/samvera/hyrax/blob/64c0bbf0dc0d3e1b49f040b50ea70d177cc9d8f6/app/indexers/hyrax/work_indexer.rb#L15-L18
174
174
  def file_sets
175
175
  @file_sets ||= ParserExportRecordSet.in_batches(candidate_file_set_ids) do |batch_of_ids|
176
- fsq = "has_model_ssim:#{Bulkrax.file_model_internal_resource} AND id:(\"" + batch_of_ids.join('" OR "') + "\")"
176
+ fsq = "has_model_ssim:\"#{Bulkrax.file_model_internal_resource.demodulize}\" AND id:(\"" + batch_of_ids.join('" OR "') + "\")"
177
177
  fsq += extra_filters if extra_filters.present?
178
178
  Bulkrax.object_factory.query(
179
179
  fsq,
@@ -1,6 +1,6 @@
1
1
  <p id="notice"><%= notice %></p>
2
- <div class="panel panel-default">
3
- <div class="panel-body">
2
+ <div class="panel card panel-default">
3
+ <div class="panel-body card-body">
4
4
  <p class='bulkrax-p-align'>
5
5
  <strong><%= t('bulkrax.importer.labels.identifier') %>:</strong>
6
6
  <%= @entry.identifier %>
@@ -1,4 +1,4 @@
1
- <div class="panel-body">
1
+ <div class="panel-body card-body">
2
2
  <% if exporter.errors.any? %>
3
3
  <div id="error_explanation">
4
4
  <h2><%= pluralize(exporter.errors.count, "error") %> prohibited this exporter from being saved:</h2>
@@ -4,10 +4,10 @@
4
4
 
5
5
  <div class="row">
6
6
  <div class="col-md-12">
7
- <div class="panel panel-default tabs exporter-form">
7
+ <div class="panel card panel-default exporter-form">
8
8
  <%= simple_form_for @exporter do |form| %>
9
9
  <%= render 'form', exporter: @exporter, form: form %>
10
- <div class="panel-footer">
10
+ <div class="panel-footer card-footer bulkrax-card-footer">
11
11
  <div class='pull-right'>
12
12
  <%= form.button :submit, value: 'Update Exporter', class: 'btn btn-primary' %>
13
13
  |
@@ -11,8 +11,8 @@
11
11
  <meta name="turbolinks-cache-control" content="no-cache">
12
12
  <% end %>
13
13
 
14
- <div class="panel panel-default">
15
- <div class="panel-body">
14
+ <div class="panel card panel-default">
15
+ <div class="panel-body card-body">
16
16
  <div class="table-responsive">
17
17
  <table id='exporters-table' class="table table-striped">
18
18
  <thead>
@@ -4,10 +4,10 @@
4
4
 
5
5
  <div class="row">
6
6
  <div class="col-md-12">
7
- <div class="panel panel-default tabs exporter-form">
7
+ <div class="panel card panel-default exporter-form">
8
8
  <%= simple_form_for @exporter do |form| %>
9
9
  <%= render 'form', exporter: @exporter, form: form %>
10
- <div class="panel-footer">
10
+ <div class="panel-footer card-footer bulkrax-card-footer">
11
11
  <div class='pull-right'>
12
12
  <%= form.button :submit, value: 'Create and Export', class: 'btn btn-primary' %>
13
13
  |
@@ -4,8 +4,8 @@
4
4
  <h1><span class='fa fa-cloud-download' aria-hidden='true'></span> Exporter: <%= @exporter.name %></h1>
5
5
  </div>
6
6
 
7
- <div class='panel panel-default'>
8
- <div class='panel-body'>
7
+ <div class='panel card panel-default'>
8
+ <div class='panel-body card-body'>
9
9
 
10
10
  <% if File.exist?(@exporter.exporter_export_zip_path) %>
11
11
  <%= simple_form_for @exporter, method: :get, url: exporter_download_path(@exporter), html: { class: 'form-inline bulkrax-p-align' } do |form| %>
@@ -1,4 +1,4 @@
1
- <div class="panel-body">
1
+ <div class="panel-body card-body">
2
2
  <% if importer.errors.any? %>
3
3
  <div id="error_explanation">
4
4
  <h2><%= pluralize(importer.errors.count, "error") %> prohibited this importer from being saved:</h2>
@@ -4,11 +4,11 @@
4
4
 
5
5
  <div class="row">
6
6
  <div class="col-md-12">
7
- <div class="panel panel-default tabs importer-form">
7
+ <div class="panel card panel-default importer-form">
8
8
 
9
9
  <%= simple_form_for @importer, html: { multipart: true } do |form| %>
10
10
  <%= render 'form', importer: @importer, form: form %>
11
- <div class="panel-footer">
11
+ <div class="panel-footer card-footer bulkrax-card-footer">
12
12
  <div class='pull-right'>
13
13
  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#bulkraxModal">
14
14
  Update Importer
@@ -21,4 +21,4 @@
21
21
  <% end %>
22
22
  </div>
23
23
  </div>
24
- </div>
24
+ </div>
@@ -11,8 +11,8 @@
11
11
  <meta name="turbolinks-cache-control" content="no-cache">
12
12
  <% end %>
13
13
 
14
- <div class="panel panel-default">
15
- <div class="panel-body">
14
+ <div class="panel card panel-default">
15
+ <div class="panel-body card-body">
16
16
  <div class="table-responsive">
17
17
  <table id='importers-table' class="table table-striped">
18
18
  <thead>
@@ -4,10 +4,10 @@
4
4
 
5
5
  <div class="row">
6
6
  <div class="col-md-12">
7
- <div class="panel panel-default tabs importer-form">
7
+ <div class="panel card panel-default importer-form">
8
8
  <%= simple_form_for @importer, html: { multipart: true } do |form| %>
9
9
  <%= render 'form', importer: @importer, form: form %>
10
- <div class="panel-footer">
10
+ <div class="panel-footer card-footer bulkrax-card-footer">
11
11
  <div class='pull-right'>
12
12
  <% if ENV['SHOW_CREATE_AND_VALIDATE'] == 'true' %>
13
13
  <%= form.button :submit, value: 'Create and Validate', class: 'btn btn-primary' %>
@@ -8,8 +8,8 @@
8
8
  <% end %>
9
9
  </div>
10
10
  </div>
11
- <div class="panel panel-default bulkrax-align-text">
12
- <div class="panel-body">
11
+ <div class="panel card panel-default bulkrax-align-text">
12
+ <div class="panel-body card-body">
13
13
  <p class="bulkrax-p-align">
14
14
  <strong><%= t('bulkrax.importer.labels.name') %>:</strong>
15
15
  <%= @importer.name %>
@@ -2,8 +2,8 @@
2
2
  <h1><span class='fa fa-cloud-upload' aria-hidden='true'></span> Upload Corrected Entries: <%= @importer.name %></h1>
3
3
  </div>
4
4
 
5
- <div class='panel panel-default'>
6
- <div class='panel-body'>
5
+ <div class='panel card panel-default'>
6
+ <div class='panel-body card-body'>
7
7
  <p>
8
8
  Upload <b>only</b> the corrected entries for the <b><%= @importer.name %></b> importer. To export failed entries for correction,
9
9
  <%= link_to importer_export_errors_path(@importer.id) do %>
@@ -1,5 +1,5 @@
1
1
  class AddFileNameToUploadedFiles < ActiveRecord::Migration[5.2]
2
2
  def change
3
- add_column :uploaded_files, :filename, :string unless column_exists?(:uploaded_files, :filename)
3
+ add_column :uploaded_files, :filename, :string if table_exists?(:uploaded_files) && !column_exists?(:uploaded_files, :filename)
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ class EntryErrorDenormalization < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :bulkrax_entries, :error_class, :string unless column_exists?(:bulkrax_entries, :error_class)
4
+ add_column :bulkrax_importers, :error_class, :string unless column_exists?(:bulkrax_importers, :error_class)
5
+ add_column :bulkrax_exporters, :error_class, :string unless column_exists?(:bulkrax_exporters, :error_class)
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ class FasterFirstEntry < ActiveRecord::Migration[5.2]
3
+ def change
4
+ add_index :bulkrax_entries, [:importerexporter_id, :importerexporter_type, :id], name: 'index_bulkrax_entries_on_importerexporter_id_type_and_id' unless index_exists?(:bulkrax_entries, [:importerexporter_id, :importerexporter_type, :id],
5
+ name: 'index_bulkrax_entries_on_importerexporter_id_type_and_id')
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulkrax
4
- VERSION = '8.3.0'
4
+ VERSION = '9.0.0'
5
5
  end
data/lib/bulkrax.rb CHANGED
@@ -92,7 +92,7 @@ module Bulkrax
92
92
  end
93
93
 
94
94
  def collection_model_class
95
- @collection_model_class ||= Collection
95
+ @collection_model_class ||= Collection if defined?(::Hyrax)
96
96
  end
97
97
 
98
98
  attr_writer :collection_model_class
@@ -9,7 +9,7 @@ namespace :bulkrax do
9
9
  progress_mark: ' ',
10
10
  remainder_mark: "\u{FF65}")
11
11
  Bulkrax::Status.latest_by_statusable.includes(:statusable).find_each do |status|
12
- status.statusable.update(status_message: status.status_message)
12
+ status.statusable.update(status_message: status.status_message, error_class: status.error_class)
13
13
  @progress.increment
14
14
  end
15
15
  end
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: 8.3.0
4
+ version: 9.0.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: 2024-12-02 00:00:00.000000000 Z
11
+ date: 2024-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.6
33
+ version: 0.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.6
40
+ version: 0.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coderay
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -487,6 +487,8 @@ files:
487
487
  - db/migrate/20240823173525_add_error_tracking_to_pending_relationships.rb
488
488
  - db/migrate/20240916182737_add_last_imported_at_to_bulkrax_importers.rb
489
489
  - db/migrate/20240916182823_add_next_import_at_to_bulkrax_importers.rb
490
+ - db/migrate/20241203010707_entry_error_denormalization.rb
491
+ - db/migrate/20241205212513_faster_first_entry.rb
490
492
  - lib/bulkrax.rb
491
493
  - lib/bulkrax/engine.rb
492
494
  - lib/bulkrax/entry_spec_helper.rb
@@ -519,7 +521,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
519
521
  - !ruby/object:Gem::Version
520
522
  version: '0'
521
523
  requirements: []
522
- rubygems_version: 3.4.20
524
+ rubygems_version: 3.4.19
523
525
  signing_key:
524
526
  specification_version: 4
525
527
  summary: Import and export tool for Hyrax and Hyku