bulkrax 4.3.0 → 5.0.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/exporters.js +12 -0
- data/app/controllers/bulkrax/entries_controller.rb +5 -0
- data/app/controllers/bulkrax/exporters_controller.rb +5 -0
- data/app/controllers/bulkrax/importers_controller.rb +9 -1
- data/app/factories/bulkrax/object_factory.rb +87 -11
- data/app/jobs/bulkrax/create_relationships_job.rb +1 -1
- data/app/jobs/bulkrax/import_file_set_job.rb +1 -0
- data/app/jobs/bulkrax/import_work_job.rb +23 -13
- data/app/matchers/bulkrax/application_matcher.rb +5 -3
- data/app/models/bulkrax/csv_entry.rb +20 -8
- data/app/models/bulkrax/entry.rb +2 -1
- data/app/models/bulkrax/importer.rb +20 -15
- data/app/models/bulkrax/oai_entry.rb +42 -9
- data/app/models/bulkrax/rdf_entry.rb +1 -1
- data/app/models/bulkrax/xml_entry.rb +54 -12
- data/app/models/concerns/bulkrax/file_factory.rb +9 -3
- data/app/models/concerns/bulkrax/file_set_entry_behavior.rb +8 -1
- data/app/models/concerns/bulkrax/import_behavior.rb +27 -19
- data/app/parsers/bulkrax/application_parser.rb +90 -13
- data/app/parsers/bulkrax/csv_parser.rb +13 -6
- data/app/parsers/bulkrax/oai_dc_parser.rb +2 -2
- data/app/parsers/bulkrax/xml_parser.rb +6 -0
- data/app/services/bulkrax/remove_relationships_for_importer.rb +107 -0
- data/app/views/bulkrax/exporters/_form.html.erb +3 -3
- data/app/views/bulkrax/shared/_file_set_entries_tab.html.erb +3 -3
- data/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb +9 -5
- data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +18 -7
- data/db/migrate/20211203195233_rename_children_counters_to_relationships.rb +1 -1
- data/db/migrate/20211220195027_add_file_set_counters_to_importer_runs.rb +1 -1
- data/db/migrate/20220118001339_add_import_attempts_to_entries.rb +1 -1
- data/db/migrate/20220119213325_add_work_counters_to_importer_runs.rb +1 -1
- data/db/migrate/20220301001839_create_bulkrax_pending_relationships.rb +1 -1
- data/db/migrate/20220303212810_add_order_to_bulkrax_pending_relationships.rb +1 -1
- data/db/migrate/20220412233954_add_include_thumbnails_to_bulkrax_exporters.rb +1 -1
- data/db/migrate/20220413180915_add_generated_metadata_to_bulkrax_exporters.rb +1 -1
- data/db/migrate/20220609001128_rename_bulkrax_importer_run_to_importer_run.rb +1 -1
- data/lib/bulkrax/version.rb +1 -1
- data/lib/bulkrax.rb +85 -11
- data/lib/generators/bulkrax/install_generator.rb +20 -0
- data/lib/generators/bulkrax/templates/config/initializers/bulkrax.rb +13 -1
- data/lib/tasks/reset.rake +65 -0
- metadata +6 -4
@@ -29,7 +29,7 @@
|
|
29
29
|
|
30
30
|
<%= form.input :export_source_importer,
|
31
31
|
label: t('bulkrax.exporter.labels.importer'),
|
32
|
-
|
32
|
+
required: true,
|
33
33
|
prompt: 'Select from the list',
|
34
34
|
label_html: { class: 'importer export-source-option hidden' },
|
35
35
|
input_html: { class: 'importer export-source-option hidden' },
|
@@ -38,7 +38,7 @@
|
|
38
38
|
<%= form.input :export_source_collection,
|
39
39
|
prompt: 'Start typing ...',
|
40
40
|
label: t('bulkrax.exporter.labels.collection'),
|
41
|
-
|
41
|
+
required: true,
|
42
42
|
placeholder: @collection&.title&.first,
|
43
43
|
label_html: { class: 'collection export-source-option hidden' },
|
44
44
|
input_html: {
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
<%= form.input :export_source_worktype,
|
54
54
|
label: t('bulkrax.exporter.labels.worktype'),
|
55
|
-
|
55
|
+
required: true,
|
56
56
|
prompt: 'Select from the list',
|
57
57
|
label_html: { class: 'worktype export-source-option hidden' },
|
58
58
|
input_html: { class: 'worktype export-source-option hidden' },
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<% entries.each do |e| %>
|
15
15
|
<% entry_path = item.class.to_s.include?('Importer') ? bulkrax.importer_entry_path(item.id, e.id) : bulkrax.exporter_entry_path(item.id, e.id) %>
|
16
16
|
<tr>
|
17
|
-
<td><%= link_to e.identifier,
|
17
|
+
<td><%= link_to e.identifier, entry_path %></td>
|
18
18
|
<td><%= e.id %></td>
|
19
19
|
<% if e.status == "Complete" %>
|
20
20
|
<td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
|
@@ -24,12 +24,12 @@
|
|
24
24
|
<td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
|
25
25
|
<% end %>
|
26
26
|
<% if e.last_error.present? %>
|
27
|
-
<td><%= link_to e.last_error.dig("error_class"),
|
27
|
+
<td><%= link_to e.last_error.dig("error_class"), entry_path %></td>
|
28
28
|
<% else %>
|
29
29
|
<td></td>
|
30
30
|
<% end %>
|
31
31
|
<td><%= e.status_at %></td>
|
32
|
-
<td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'),
|
32
|
+
<td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), entry_path %></td>
|
33
33
|
</tr>
|
34
34
|
<% end %>
|
35
35
|
</tbody>
|
@@ -1,6 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% if current_ability.can_import_works? %>
|
2
|
+
<%= menu.nav_link(bulkrax.importers_path) do %>
|
3
|
+
<span class="fa fa-cloud-upload" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.importers') %></span>
|
4
|
+
<% end %>
|
5
|
+
<% end %>
|
6
|
+
<% if current_ability.can_export_works? %>
|
7
|
+
<%= menu.nav_link(bulkrax.exporters_path) do %>
|
8
|
+
<span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
|
9
|
+
<% end %>
|
3
10
|
<% end %>
|
4
|
-
<%= menu.nav_link(bulkrax.exporters_path) do %>
|
5
|
-
<span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
|
6
|
-
<% end %>
|
@@ -1,19 +1,30 @@
|
|
1
|
-
<li class="h5"><%= t('hyrax.admin.sidebar.repository_objects') %></li>
|
1
|
+
<li class="h5 nav-item"><%= t('hyrax.admin.sidebar.repository_objects') %></li>
|
2
2
|
|
3
3
|
<%= menu.nav_link(hyrax.my_collections_path,
|
4
|
+
class: "nav-link",
|
5
|
+
onclick: "dontChangeAccordion(event);",
|
4
6
|
also_active_for: hyrax.dashboard_collections_path) do %>
|
5
7
|
<span class="fa fa-folder-open" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.collections') %></span>
|
6
8
|
<% end %>
|
7
9
|
|
8
10
|
<%= menu.nav_link(hyrax.my_works_path,
|
11
|
+
class: "nav-link",
|
12
|
+
onclick: "dontChangeAccordion(event);",
|
9
13
|
also_active_for: hyrax.dashboard_works_path) do %>
|
10
14
|
<span class="fa fa-file" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.works') %></span>
|
11
15
|
<% end %>
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
<%
|
16
|
-
|
17
|
-
<%= menu.nav_link(bulkrax.
|
18
|
-
|
17
|
+
<% if ::Hyrax::DashboardController&.respond_to?(:sidebar_partials) %>
|
18
|
+
<%= render 'hyrax/dashboard/sidebar/menu_partials', menu: menu, section: :repository_content %>
|
19
|
+
<% else %>
|
20
|
+
<% if current_ability.can_import_works? %>
|
21
|
+
<%= menu.nav_link(bulkrax.importers_path) do %>
|
22
|
+
<span class="fa fa-cloud-upload" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.importers') %></span>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<% if current_ability.can_export_works? %>
|
26
|
+
<%= menu.nav_link(bulkrax.exporters_path) do %>
|
27
|
+
<span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
19
30
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class RenameChildrenCountersToRelationships < ActiveRecord::Migration[5.
|
1
|
+
class RenameChildrenCountersToRelationships < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
rename_column :bulkrax_importer_runs, :processed_children, :processed_relationships unless column_exists?(:bulkrax_importer_runs, :processed_relationships)
|
4
4
|
rename_column :bulkrax_importer_runs, :failed_children, :failed_relationships unless column_exists?(:bulkrax_importer_runs, :failed_relationships)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddFileSetCountersToImporterRuns < ActiveRecord::Migration[5.
|
1
|
+
class AddFileSetCountersToImporterRuns < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
add_column :bulkrax_importer_runs, :processed_file_sets, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :processed_file_sets)
|
4
4
|
add_column :bulkrax_importer_runs, :failed_file_sets, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :failed_file_sets)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddImportAttemptsToEntries < ActiveRecord::Migration[5.
|
1
|
+
class AddImportAttemptsToEntries < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
add_column :bulkrax_entries, :import_attempts, :integer, default: 0 unless column_exists?(:bulkrax_entries, :import_attempts)
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddWorkCountersToImporterRuns < ActiveRecord::Migration[5.
|
1
|
+
class AddWorkCountersToImporterRuns < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
add_column :bulkrax_importer_runs, :processed_works, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :processed_works)
|
4
4
|
add_column :bulkrax_importer_runs, :failed_works, :integer, default: 0 unless column_exists?(:bulkrax_importer_runs, :failed_works)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddOrderToBulkraxPendingRelationships < ActiveRecord::Migration[5.
|
1
|
+
class AddOrderToBulkraxPendingRelationships < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
add_column :bulkrax_pending_relationships, :order, :integer, default: 0 unless column_exists?(:bulkrax_pending_relationships, :order)
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddIncludeThumbnailsToBulkraxExporters < ActiveRecord::Migration[5.
|
1
|
+
class AddIncludeThumbnailsToBulkraxExporters < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
add_column :bulkrax_exporters, :include_thumbnails, :boolean, default: false unless column_exists?(:bulkrax_exporters, :include_thumbnails)
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddGeneratedMetadataToBulkraxExporters < ActiveRecord::Migration[5.
|
1
|
+
class AddGeneratedMetadataToBulkraxExporters < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
add_column :bulkrax_exporters, :generated_metadata, :boolean, default: false unless column_exists?(:bulkrax_exporters, :generated_metadata)
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class RenameBulkraxImporterRunToImporterRun < ActiveRecord::Migration[5.
|
1
|
+
class RenameBulkraxImporterRunToImporterRun < ActiveRecord::Migration[5.1]
|
2
2
|
def up
|
3
3
|
if column_exists?(:bulkrax_pending_relationships, :bulkrax_importer_run_id)
|
4
4
|
remove_foreign_key :bulkrax_pending_relationships, :bulkrax_importer_runs
|
data/lib/bulkrax/version.rb
CHANGED
data/lib/bulkrax.rb
CHANGED
@@ -1,25 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bulkrax/version"
|
3
4
|
require "bulkrax/engine"
|
4
5
|
require 'active_support/all'
|
5
6
|
|
7
|
+
# rubocop:disable Metrics/ModuleLength
|
6
8
|
module Bulkrax
|
7
9
|
class << self
|
8
|
-
|
9
|
-
|
10
|
+
# @todo Move from module attribute methods to a configuration class. With module attributes,
|
11
|
+
# when we make a change we are polluting the global space. This means that our tests that
|
12
|
+
# modify these config values are modifying global state. Which is not desirous, as it can
|
13
|
+
# introduce unexpected flakey tests.
|
14
|
+
mattr_accessor :api_definition,
|
10
15
|
:default_field_mapping,
|
16
|
+
:default_work_type,
|
17
|
+
:export_path,
|
18
|
+
:field_mappings,
|
11
19
|
:fill_in_blank_source_identifiers,
|
12
20
|
:generated_metadata_mapping,
|
21
|
+
:import_path,
|
22
|
+
:multi_value_element_join_on,
|
23
|
+
:multi_value_element_split_on,
|
24
|
+
:object_factory,
|
25
|
+
:parsers,
|
26
|
+
:qa_controlled_properties,
|
13
27
|
:related_children_field_mapping,
|
14
28
|
:related_parents_field_mapping,
|
15
|
-
:reserved_properties,
|
16
|
-
:qa_controlled_properties,
|
17
|
-
:field_mappings,
|
18
|
-
:import_path,
|
19
|
-
:export_path,
|
20
29
|
:removed_image_path,
|
21
|
-
:
|
22
|
-
:
|
30
|
+
:reserved_properties,
|
31
|
+
:server_name
|
23
32
|
|
24
33
|
self.parsers = [
|
25
34
|
{ name: "OAI - Dublin Core", class_name: "Bulkrax::OaiDcParser", partial: "oai_fields" },
|
@@ -29,8 +38,8 @@ module Bulkrax
|
|
29
38
|
{ name: "XML", class_name: "Bulkrax::XmlParser", partial: "xml_fields" }
|
30
39
|
]
|
31
40
|
|
32
|
-
self.import_path = 'tmp/imports'
|
33
|
-
self.export_path = 'tmp/exports'
|
41
|
+
self.import_path = Bulkrax.import_path || 'tmp/imports'
|
42
|
+
self.export_path = Bulkrax.export_path || 'tmp/exports'
|
34
43
|
self.removed_image_path = Bulkrax::Engine.root.join('spec', 'fixtures', 'removed.png').to_s
|
35
44
|
self.server_name = 'bulkrax@example.com'
|
36
45
|
|
@@ -137,8 +146,73 @@ module Bulkrax
|
|
137
146
|
)
|
138
147
|
end
|
139
148
|
|
149
|
+
DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | '
|
150
|
+
# Specify the delimiter for joining an attribute's multi-value array into a string.
|
151
|
+
#
|
152
|
+
# @note the specific delimeter should likely be present in the multi_value_element_split_on
|
153
|
+
# expression.
|
154
|
+
def self.multi_value_element_join_on
|
155
|
+
@multi_value_element_join_on ||= DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
|
156
|
+
end
|
157
|
+
|
158
|
+
DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON = /\s*[:;|]\s*/.freeze
|
159
|
+
# @return [RegexClass] the regular express to use to "split" an attribute's values. If set to
|
160
|
+
# `true` use the DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON.
|
161
|
+
#
|
162
|
+
# @note The "true" value is to preserve backwards compatibility.
|
163
|
+
# @see DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
|
164
|
+
def self.multi_value_element_split_on
|
165
|
+
if @multi_value_element_join_on.is_a?(TrueClass)
|
166
|
+
DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
|
167
|
+
else
|
168
|
+
@multi_value_element_split_on ||= DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
140
172
|
# this function maps the vars from your app into your engine
|
141
173
|
def self.setup
|
142
174
|
yield self
|
143
175
|
end
|
176
|
+
|
177
|
+
# Responsible for stripping hidden characters from the given string.
|
178
|
+
#
|
179
|
+
# @param value [#to_s]
|
180
|
+
# @return [String] with hidden characters removed
|
181
|
+
#
|
182
|
+
# @see https://github.com/samvera-labs/bulkrax/issues/688
|
183
|
+
def self.normalize_string(value)
|
184
|
+
# Removing [Byte Order Mark (BOM)](https://en.wikipedia.org/wiki/Byte_order_mark)
|
185
|
+
value.to_s.delete("\xEF\xBB\xBF")
|
186
|
+
end
|
187
|
+
|
188
|
+
# This class confirms to the Active::Support.serialze interface. It's job is to ensure that we
|
189
|
+
# don't have keys with the tricksy Byte Order Mark character.
|
190
|
+
#
|
191
|
+
# @see https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html#method-i-serialize
|
192
|
+
class NormalizedJson
|
193
|
+
def self.normalize_keys(hash)
|
194
|
+
return hash unless hash.respond_to?(:each_pair)
|
195
|
+
returning_value = {}
|
196
|
+
hash.each_pair do |key, value|
|
197
|
+
returning_value[Bulkrax.normalize_string(key)] = value
|
198
|
+
end
|
199
|
+
returning_value
|
200
|
+
end
|
201
|
+
|
202
|
+
# When we write the serialized data to the database, we "dump" the value into that database
|
203
|
+
# column.
|
204
|
+
def self.dump(value)
|
205
|
+
JSON.dump(normalize_keys(value))
|
206
|
+
end
|
207
|
+
|
208
|
+
# When we load the serialized data from the database, we pass the database's value into "load"
|
209
|
+
# function.
|
210
|
+
#
|
211
|
+
# rubocop:disable Security/JSONLoad
|
212
|
+
def self.load(string)
|
213
|
+
normalize_keys(JSON.load(string))
|
214
|
+
end
|
215
|
+
# rubocop:enable Security/JSONLoad
|
216
|
+
end
|
144
217
|
end
|
218
|
+
# rubocop:disable Metrics/ModuleLength
|
@@ -55,6 +55,26 @@ class Bulkrax::InstallGenerator < Rails::Generators::Base
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def add_ability
|
59
|
+
file = 'app/models/ability.rb'
|
60
|
+
file_text = File.read(file)
|
61
|
+
import_line = 'def can_import_works?'
|
62
|
+
export_line = 'def can_export_works?'
|
63
|
+
unless file_text.include?(import_line)
|
64
|
+
insert_into_file file, before: /^end/ do
|
65
|
+
" def can_import_works?\n can_create_any_work?\n end"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# rubocop:disable Style/GuardClause
|
70
|
+
unless file_text.include?(export_line)
|
71
|
+
insert_into_file file, before: /^end/ do
|
72
|
+
" def can_export_works?\n can_create_any_work?\n end"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
# rubocop:enable Style/GuardClause
|
76
|
+
end
|
77
|
+
|
58
78
|
def add_css
|
59
79
|
['css', 'scss', 'sass'].map do |ext|
|
60
80
|
file = "app/assets/stylesheets/application.#{ext}"
|
@@ -10,6 +10,9 @@ Bulkrax.setup do |config|
|
|
10
10
|
# Default is the first returned by Hyrax.config.curation_concerns
|
11
11
|
# config.default_work_type = MyWork
|
12
12
|
|
13
|
+
# Factory Class to use when generating and saving objects
|
14
|
+
config.object_factory = Bulkrax::ObjectFactory
|
15
|
+
|
13
16
|
# Path to store pending imports
|
14
17
|
# config.import_path = 'tmp/imports'
|
15
18
|
|
@@ -67,7 +70,16 @@ Bulkrax.setup do |config|
|
|
67
70
|
# is controlled by the active terms in config/authorities/rights_statements.yml
|
68
71
|
# Defaults: 'rights_statement' and 'license'
|
69
72
|
# config.qa_controlled_properties += ['my_field']
|
73
|
+
|
74
|
+
# Specify the delimiter regular expression for splitting an attribute's values into a multi-value array.
|
75
|
+
# config.multi_value_element_split_on = //\s*[:;|]\s*/.freeze
|
76
|
+
|
77
|
+
# Specify the delimiter for joining an attribute's multi-value array into a string. Note: the
|
78
|
+
# specific delimeter should likely be present in the multi_value_element_split_on expression.
|
79
|
+
# config.multi_value_element_join_on = ' | '
|
70
80
|
end
|
71
81
|
|
72
82
|
# Sidebar for hyrax 3+ support
|
73
|
-
|
83
|
+
if Object.const_defined?(:Hyrax) && ::Hyrax::DashboardController&.respond_to?(:sidebar_partials)
|
84
|
+
Hyrax::DashboardController.sidebar_partials[:repository_content] << "hyrax/dashboard/sidebar/bulkrax_sidebar_additions"
|
85
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :hyrax do
|
4
|
+
namespace :reset do
|
5
|
+
desc "Delete Bulkrax importers in addition to the reset below"
|
6
|
+
task importers_et_all: :works_and_collections do
|
7
|
+
# sometimes re-running an existing importer causes issues
|
8
|
+
# and you may need to create new ones or delete the existing ones
|
9
|
+
Bulkrax::Importer.delete_all
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Reset fedora / solr and corresponding database tables w/o clearing other active record tables like users'
|
13
|
+
task works_and_collections: [:environment] do
|
14
|
+
confirm('You are about to delete all works and collections, this is not reversable!')
|
15
|
+
require 'active_fedora/cleaner'
|
16
|
+
ActiveFedora::Cleaner.clean!
|
17
|
+
Hyrax::PermissionTemplateAccess.delete_all
|
18
|
+
Hyrax::PermissionTemplate.delete_all
|
19
|
+
Bulkrax::PendingRelationship.delete_all
|
20
|
+
Bulkrax::Entry.delete_all
|
21
|
+
Bulkrax::ImporterRun.delete_all
|
22
|
+
Bulkrax::Status.delete_all
|
23
|
+
# Remove sipity methods, everything but sipity roles
|
24
|
+
Sipity::Workflow.delete_all
|
25
|
+
Sipity::EntitySpecificResponsibility.delete_all
|
26
|
+
Sipity::Comment.delete_all
|
27
|
+
Sipity::Entity.delete_all
|
28
|
+
Sipity::WorkflowRole.delete_all
|
29
|
+
Sipity::WorkflowResponsibility.delete_all
|
30
|
+
Sipity::Agent.delete_all
|
31
|
+
Mailboxer::Receipt.destroy_all
|
32
|
+
Mailboxer::Notification.delete_all
|
33
|
+
Mailboxer::Conversation::OptOut.delete_all
|
34
|
+
Mailboxer::Conversation.delete_all
|
35
|
+
AccountElevator.switch!('single.tenant.default')
|
36
|
+
# we need to wait till Fedora is done with its cleanup
|
37
|
+
# otherwise creating the admin set will fail
|
38
|
+
while AdminSet.exists?(AdminSet::DEFAULT_ID)
|
39
|
+
puts 'waiting for delete to finish before reinitializing Fedora'
|
40
|
+
sleep 20
|
41
|
+
end
|
42
|
+
|
43
|
+
Hyrax::CollectionType.find_or_create_default_collection_type
|
44
|
+
Hyrax::CollectionType.find_or_create_admin_set_type
|
45
|
+
AdminSet.find_or_create_default_admin_set_id
|
46
|
+
|
47
|
+
collection_types = Hyrax::CollectionType.all
|
48
|
+
collection_types.each do |c|
|
49
|
+
next unless c.title.match?(/^translation missing/)
|
50
|
+
oldtitle = c.title
|
51
|
+
c.title = I18n.t(c.title.gsub("translation missing: en.", ''))
|
52
|
+
c.save
|
53
|
+
puts "#{oldtitle} changed to #{c.title}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def confirm(action)
|
58
|
+
return if ENV['RESET_CONFIRMED'].present?
|
59
|
+
confirm_token = rand(36**6).to_s(36)
|
60
|
+
STDOUT.puts "#{action} Enter '#{confirm_token}' to confirm:"
|
61
|
+
input = STDIN.gets.chomp
|
62
|
+
raise "Aborting. You entered #{input}" unless input == confirm_token
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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:
|
4
|
+
version: 5.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:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -106,14 +106,14 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 3.
|
109
|
+
version: 3.2.4
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 3.
|
116
|
+
version: 3.2.4
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: loofah
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -328,6 +328,7 @@ files:
|
|
328
328
|
- app/parsers/bulkrax/oai_dc_parser.rb
|
329
329
|
- app/parsers/bulkrax/oai_qualified_dc_parser.rb
|
330
330
|
- app/parsers/bulkrax/xml_parser.rb
|
331
|
+
- app/services/bulkrax/remove_relationships_for_importer.rb
|
331
332
|
- app/views/bulkrax/entries/_parsed_metadata.html.erb
|
332
333
|
- app/views/bulkrax/entries/_raw_metadata.html.erb
|
333
334
|
- app/views/bulkrax/entries/show.html.erb
|
@@ -404,6 +405,7 @@ files:
|
|
404
405
|
- lib/generators/bulkrax/templates/config/bulkrax_api.yml
|
405
406
|
- lib/generators/bulkrax/templates/config/initializers/bulkrax.rb
|
406
407
|
- lib/tasks/bulkrax_tasks.rake
|
408
|
+
- lib/tasks/reset.rake
|
407
409
|
homepage: https://github.com/samvera-labs/bulkrax
|
408
410
|
licenses:
|
409
411
|
- Apache-2.0
|