bulkrax 4.2.1 → 4.4.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/bulkrax/exporters.js +12 -0
  3. data/app/assets/javascripts/bulkrax/importers.js.erb +27 -1
  4. data/app/controllers/bulkrax/exporters_controller.rb +3 -1
  5. data/app/controllers/bulkrax/importers_controller.rb +1 -1
  6. data/app/factories/bulkrax/object_factory.rb +35 -8
  7. data/app/jobs/bulkrax/create_relationships_job.rb +1 -1
  8. data/app/jobs/bulkrax/import_work_job.rb +12 -10
  9. data/app/matchers/bulkrax/application_matcher.rb +1 -1
  10. data/app/models/bulkrax/csv_entry.rb +14 -10
  11. data/app/models/bulkrax/importer.rb +20 -15
  12. data/app/models/bulkrax/oai_entry.rb +1 -2
  13. data/app/models/concerns/bulkrax/file_set_entry_behavior.rb +8 -1
  14. data/app/models/concerns/bulkrax/import_behavior.rb +10 -9
  15. data/app/parsers/bulkrax/application_parser.rb +87 -14
  16. data/app/parsers/bulkrax/bagit_parser.rb +2 -1
  17. data/app/parsers/bulkrax/csv_parser.rb +11 -10
  18. data/app/parsers/bulkrax/oai_dc_parser.rb +2 -2
  19. data/app/services/bulkrax/remove_relationships_for_importer.rb +107 -0
  20. data/app/views/bulkrax/exporters/_form.html.erb +3 -3
  21. data/app/views/bulkrax/exporters/show.html.erb +17 -41
  22. data/app/views/bulkrax/importers/edit.html.erb +1 -1
  23. data/app/views/bulkrax/importers/new.html.erb +1 -1
  24. data/app/views/bulkrax/importers/show.html.erb +3 -114
  25. data/app/views/bulkrax/shared/_collection_entries_tab.html.erb +39 -0
  26. data/app/views/bulkrax/shared/_file_set_entries_tab.html.erb +39 -0
  27. data/app/views/bulkrax/shared/_work_entries_tab.html.erb +39 -0
  28. data/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb +7 -5
  29. data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +23 -15
  30. data/db/migrate/20211203195233_rename_children_counters_to_relationships.rb +1 -1
  31. data/db/migrate/20211220195027_add_file_set_counters_to_importer_runs.rb +1 -1
  32. data/db/migrate/20220118001339_add_import_attempts_to_entries.rb +1 -1
  33. data/db/migrate/20220119213325_add_work_counters_to_importer_runs.rb +1 -1
  34. data/db/migrate/20220301001839_create_bulkrax_pending_relationships.rb +1 -1
  35. data/db/migrate/20220303212810_add_order_to_bulkrax_pending_relationships.rb +1 -1
  36. data/db/migrate/20220412233954_add_include_thumbnails_to_bulkrax_exporters.rb +1 -1
  37. data/db/migrate/20220413180915_add_generated_metadata_to_bulkrax_exporters.rb +1 -1
  38. data/db/migrate/20220609001128_rename_bulkrax_importer_run_to_importer_run.rb +1 -1
  39. data/lib/bulkrax/version.rb +1 -1
  40. data/lib/bulkrax.rb +38 -11
  41. data/lib/generators/bulkrax/templates/config/initializers/bulkrax.rb +10 -0
  42. data/lib/tasks/bulkrax_tasks.rake +10 -11
  43. data/lib/tasks/reset.rake +65 -0
  44. metadata +7 -2
@@ -80,120 +80,9 @@
80
80
  </ul>
81
81
  <!-- Tab panes -->
82
82
  <div class="tab-content outline">
83
- <div role="tabpanel" class="tab-pane active bulkrax-nav-tab-table-left-align" id="work-entries">
84
- <table class='table table-striped'>
85
- <thead>
86
- <tr>
87
- <th>Identifier</th>
88
- <th>Entry ID</th>
89
- <th>Status</th>
90
- <th>Errors</th>
91
- <th>Status Set At</th>
92
- <th>Actions</th>
93
- </tr>
94
- </thead>
95
- <tbody>
96
- <% @work_entries.each do |e| %>
97
- <tr>
98
- <td><%= link_to e.identifier, bulkrax.importer_entry_path(@importer.id, e.id) %></td>
99
- <td><%= e.id %></td>
100
- <% if e.status == "Complete" %>
101
- <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
102
- <% elsif e.status == "Pending" %>
103
- <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
104
- <% else %>
105
- <td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
106
- <% end %>
107
- <% if e.last_error.present? %>
108
- <td><%= link_to e.last_error.dig("error_class"), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
109
- <% else %>
110
- <td></td>
111
- <% end %>
112
- <td><%= e.status_at %></td>
113
- <td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
114
- </tr>
115
- <% end %>
116
- </tbody>
117
- </table>
118
- <%= page_entries_info(@work_entries) %><br />
119
- <%= paginate(@work_entries, theme: 'blacklight', param_name: :work_entries_page, params: { anchor: 'work-entries'}) %>
120
- </div>
121
- <div role="tabpanel" class="tab-pane bulkrax-nav-tab-table-left-align" id="collection-entries">
122
- <table class='table table-striped'>
123
- <thead>
124
- <tr>
125
- <th>Identifier</th>
126
- <th>Entry ID</th>
127
- <th>Status</th>
128
- <th>Errors</th>
129
- <th>Status Set At</th>
130
- <th>Actions</th>
131
- </tr>
132
- </thead>
133
- <tbody>
134
- <% @collection_entries.each do |e| %>
135
- <tr>
136
- <td><%= link_to e.identifier, bulkrax.importer_entry_path(@importer.id, e.id) %></td>
137
- <td><%= e.id %></td>
138
- <% if e.status == "Complete" %>
139
- <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
140
- <% elsif e.status == "Pending" %>
141
- <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
142
- <% else %>
143
- <td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
144
- <% end %>
145
- <% if e.last_error.present? %>
146
- <td><%= link_to e.last_error.dig("error_class"), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
147
- <% else %>
148
- <td></td>
149
- <% end %>
150
- <td><%= e.status_at %></td>
151
- <td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
152
- </tr>
153
- <% end %>
154
- </tbody>
155
- </table>
156
- <%= page_entries_info(@collection_entries) %><br />
157
- <%= paginate(@collection_entries, theme: 'blacklight', param_name: :collections_entries_page, params: {anchor: 'collection-entries'}) %>
158
- </div>
159
- <div role="tabpanel" class="tab-pane bulkrax-nav-tab-table-left-align" id="file-set-entries">
160
- <table class='table table-striped'>
161
- <thead>
162
- <tr>
163
- <th>Identifier</th>
164
- <th>Entry ID</th>
165
- <th>Status</th>
166
- <th>Errors</th>
167
- <th>Status Set At</th>
168
- <th>Actions</th>
169
- </tr>
170
- </thead>
171
- <tbody>
172
- <% @file_set_entries.each do |e| %>
173
- <tr>
174
- <td><%= link_to e.identifier, bulkrax.importer_entry_path(@importer.id, e.id) %></td>
175
- <td><%= e.id %></td>
176
- <% if e.status == "Complete" %>
177
- <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
178
- <% elsif e.status == "Pending" %>
179
- <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
180
- <% else %>
181
- <td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
182
- <% end %>
183
- <% if e.last_error.present? %>
184
- <td><%= link_to e.last_error.dig("error_class"), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
185
- <% else %>
186
- <td></td>
187
- <% end %>
188
- <td><%= e.status_at %></td>
189
- <td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
190
- </tr>
191
- <% end %>
192
- </tbody>
193
- </table>
194
- <%= page_entries_info(@file_set_entries) %><br />
195
- <%= paginate(@file_set_entries, theme: 'blacklight', param_name: :file_set_entries_page, params: {anchor: 'file-set-entries'}) %>
196
- </div>
83
+ <%= render partial: 'bulkrax/shared/work_entries_tab', locals: { item: @importer, entries: @work_entries } %>
84
+ <%= render partial: 'bulkrax/shared/collection_entries_tab', locals: { item: @importer, entries: @collection_entries } %>
85
+ <%= render partial: 'bulkrax/shared/file_set_entries_tab', locals: { item: @importer, entries: @file_set_entries } %>
197
86
  </div>
198
87
  </div>
199
88
 
@@ -0,0 +1,39 @@
1
+ <div role="tabpanel" class="tab-pane bulkrax-nav-tab-table-left-align" id="collection-entries">
2
+ <table class='table table-striped'>
3
+ <thead>
4
+ <tr>
5
+ <th>Identifier</th>
6
+ <th>Entry ID</th>
7
+ <th>Status</th>
8
+ <th>Errors</th>
9
+ <th>Status Set At</th>
10
+ <th>Actions</th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% entries.each do |e| %>
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
+ <tr>
17
+ <td><%= link_to e.identifier, entry_path %></td>
18
+ <td><%= e.id %></td>
19
+ <% if e.status == "Complete" %>
20
+ <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
21
+ <% elsif e.status == "Pending" %>
22
+ <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
23
+ <% else %>
24
+ <td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
25
+ <% end %>
26
+ <% if e.last_error.present? %>
27
+ <td><%= link_to e.last_error.dig("error_class"), entry_path %></td>
28
+ <% else %>
29
+ <td></td>
30
+ <% end %>
31
+ <td><%= e.status_at %></td>
32
+ <td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), entry_path %></td>
33
+ </tr>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+ <%= page_entries_info(entries) %><br />
38
+ <%= paginate(entries, theme: 'blacklight', param_name: :collections_entries_page, params: { anchor: 'collection-entries' }) %>
39
+ </div>
@@ -0,0 +1,39 @@
1
+ <div role="tabpanel" class="tab-pane bulkrax-nav-tab-table-left-align" id="file-set-entries">
2
+ <table class='table table-striped'>
3
+ <thead>
4
+ <tr>
5
+ <th>Identifier</th>
6
+ <th>Entry ID</th>
7
+ <th>Status</th>
8
+ <th>Errors</th>
9
+ <th>Status Set At</th>
10
+ <th>Actions</th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% entries.each do |e| %>
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
+ <tr>
17
+ <td><%= link_to e.identifier, entry_path %></td>
18
+ <td><%= e.id %></td>
19
+ <% if e.status == "Complete" %>
20
+ <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
21
+ <% elsif e.status == "Pending" %>
22
+ <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
23
+ <% else %>
24
+ <td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
25
+ <% end %>
26
+ <% if e.last_error.present? %>
27
+ <td><%= link_to e.last_error.dig("error_class"), entry_path %></td>
28
+ <% else %>
29
+ <td></td>
30
+ <% end %>
31
+ <td><%= e.status_at %></td>
32
+ <td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), entry_path %></td>
33
+ </tr>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+ <%= page_entries_info(entries) %><br />
38
+ <%= paginate(entries, theme: 'blacklight', param_name: :file_set_entries_page, params: { anchor: 'file-set-entries' }) %>
39
+ </div>
@@ -0,0 +1,39 @@
1
+ <div role="tabpanel" class="tab-pane active bulkrax-nav-tab-table-left-align" id="work-entries">
2
+ <table class='table table-striped'>
3
+ <thead>
4
+ <tr>
5
+ <th>Identifier</th>
6
+ <th>Entry ID</th>
7
+ <th>Status</th>
8
+ <th>Errors</th>
9
+ <th>Status Set At</th>
10
+ <th>Actions</th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% entries.each do |e| %>
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
+ <tr>
17
+ <td><%= link_to e.identifier, entry_path %></td>
18
+ <td><%= e.id %></td>
19
+ <% if e.status == "Complete" %>
20
+ <td><span class="glyphicon glyphicon-ok" style="color: green;"></span> <%= e.status %></td>
21
+ <% elsif e.status == "Pending" %>
22
+ <td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
23
+ <% else %>
24
+ <td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
25
+ <% end %>
26
+ <% if e.last_error.present? %>
27
+ <td><%= link_to e.last_error.dig("error_class"), entry_path %></td>
28
+ <% else %>
29
+ <td></td>
30
+ <% end %>
31
+ <td><%= e.status_at %></td>
32
+ <td><%= link_to raw('<span class="glyphicon glyphicon-info-sign"></span>'), entry_path %></td>
33
+ </tr>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+ <%= page_entries_info(entries) %><br />
38
+ <%= paginate(entries, theme: 'blacklight', param_name: :work_entries_page, params: { anchor: 'work-entries' }) %>
39
+ </div>
@@ -1,6 +1,8 @@
1
- <%= menu.nav_link(bulkrax.importers_path) do %>
2
- <span class="fa fa-cloud-upload" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.importers') %></span>
1
+ <% if ENV.fetch('HYKU_BULKRAX_ENABLED', 'true') == 'true' %>
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
+ <%= menu.nav_link(bulkrax.exporters_path) do %>
6
+ <span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
7
+ <% end %>
3
8
  <% 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,27 @@
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
- <%= menu.nav_link(hyrax.my_collections_path,
4
- also_active_for: hyrax.dashboard_collections_path) do %>
5
- <span class="fa fa-folder-open" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.collections') %></span>
6
- <% end %>
3
+ <%= menu.nav_link(hyrax.my_collections_path,
4
+ class: "nav-link",
5
+ onclick: "dontChangeAccordion(event);",
6
+ also_active_for: hyrax.dashboard_collections_path) do %>
7
+ <span class="fa fa-folder-open" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.collections') %></span>
8
+ <% end %>
7
9
 
8
- <%= menu.nav_link(hyrax.my_works_path,
9
- also_active_for: hyrax.dashboard_works_path) do %>
10
- <span class="fa fa-file" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.works') %></span>
11
- <% end %>
10
+ <%= menu.nav_link(hyrax.my_works_path,
11
+ class: "nav-link",
12
+ onclick: "dontChangeAccordion(event);",
13
+ also_active_for: hyrax.dashboard_works_path) do %>
14
+ <span class="fa fa-file" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('hyrax.admin.sidebar.works') %></span>
15
+ <% end %>
12
16
 
13
- <%= menu.nav_link(bulkrax.importers_path) do %>
14
- <span class="fa fa-cloud-upload" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.importers') %></span>
15
- <% end %>
17
+ <% if ::Hyrax::DashboardController&.respond_to?(:sidebar_partials) %>
18
+ <%= render 'hyrax/dashboard/sidebar/menu_partials', menu: menu, section: :repository_content %>
19
+ <% else %>
20
+ <%= menu.nav_link(bulkrax.importers_path) do %>
21
+ <span class="fa fa-cloud-upload" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.importers') %></span>
22
+ <% end %>
16
23
 
17
- <%= menu.nav_link(bulkrax.exporters_path) do %>
18
- <span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
19
- <% end %>
24
+ <%= menu.nav_link(bulkrax.exporters_path) do %>
25
+ <span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
26
+ <% end %>
27
+ <% end %>
@@ -1,4 +1,4 @@
1
- class RenameChildrenCountersToRelationships < ActiveRecord::Migration[5.2]
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.2]
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.2]
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.2]
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 CreateBulkraxPendingRelationships < ActiveRecord::Migration[5.2]
1
+ class CreateBulkraxPendingRelationships < ActiveRecord::Migration[5.1]
2
2
  def change
3
3
  unless table_exists?(:bulkrax_pending_relationships)
4
4
  create_table :bulkrax_pending_relationships do |t|
@@ -1,4 +1,4 @@
1
- class AddOrderToBulkraxPendingRelationships < ActiveRecord::Migration[5.2]
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.2]
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.2]
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.2]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulkrax
4
- VERSION = '4.2.1'
4
+ VERSION = '4.4.0'
5
5
  end
data/lib/bulkrax.rb CHANGED
@@ -1,25 +1,29 @@
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
 
6
7
  module Bulkrax
7
8
  class << self
8
- mattr_accessor :parsers,
9
- :default_work_type,
9
+ mattr_accessor :api_definition,
10
10
  :default_field_mapping,
11
+ :default_work_type,
12
+ :export_path,
13
+ :field_mappings,
11
14
  :fill_in_blank_source_identifiers,
12
15
  :generated_metadata_mapping,
16
+ :import_path,
17
+ :multi_value_element_join_on,
18
+ :multi_value_element_split_on,
19
+ :object_factory,
20
+ :parsers,
21
+ :qa_controlled_properties,
13
22
  :related_children_field_mapping,
14
23
  :related_parents_field_mapping,
15
- :reserved_properties,
16
- :qa_controlled_properties,
17
- :field_mappings,
18
- :import_path,
19
- :export_path,
20
24
  :removed_image_path,
21
- :server_name,
22
- :api_definition
25
+ :reserved_properties,
26
+ :server_name
23
27
 
24
28
  self.parsers = [
25
29
  { name: "OAI - Dublin Core", class_name: "Bulkrax::OaiDcParser", partial: "oai_fields" },
@@ -29,8 +33,8 @@ module Bulkrax
29
33
  { name: "XML", class_name: "Bulkrax::XmlParser", partial: "xml_fields" }
30
34
  ]
31
35
 
32
- self.import_path = 'tmp/imports'
33
- self.export_path = 'tmp/exports'
36
+ self.import_path = Bulkrax.import_path || 'tmp/imports'
37
+ self.export_path = Bulkrax.export_path || 'tmp/exports'
34
38
  self.removed_image_path = Bulkrax::Engine.root.join('spec', 'fixtures', 'removed.png').to_s
35
39
  self.server_name = 'bulkrax@example.com'
36
40
 
@@ -137,6 +141,29 @@ module Bulkrax
137
141
  )
138
142
  end
139
143
 
144
+ DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | '
145
+ # Specify the delimiter for joining an attribute's multi-value array into a string.
146
+ #
147
+ # @note the specific delimeter should likely be present in the multi_value_element_split_on
148
+ # expression.
149
+ def self.multi_value_element_join_on
150
+ @multi_value_element_join_on ||= DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
151
+ end
152
+
153
+ DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON = /\s*[:;|]\s*/.freeze
154
+ # @return [RegexClass] the regular express to use to "split" an attribute's values. If set to
155
+ # `true` use the DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON.
156
+ #
157
+ # @note The "true" value is to preserve backwards compatibility.
158
+ # @see DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
159
+ def self.multi_value_element_split_on
160
+ if @multi_value_element_join_on.is_a?(TrueClass)
161
+ DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
162
+ else
163
+ @multi_value_element_split_on ||= DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
164
+ end
165
+ end
166
+
140
167
  # this function maps the vars from your app into your engine
141
168
  def self.setup
142
169
  yield self
@@ -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,6 +70,13 @@ 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
@@ -3,28 +3,27 @@
3
3
  namespace :bulkrax do
4
4
  desc "Remove old exported zips and create new ones with the new file structure"
5
5
  task rerun_all_exporters: :environment do
6
+ # delete the existing folders and zip files
7
+ Dir["tmp/exports/**"].each { |file| FileUtils.rm_rf(file) }
8
+
6
9
  if defined?(::Hyku)
7
10
  Account.find_each do |account|
8
- puts "=============== updating #{account.name} ============"
9
11
  next if account.name == "search"
10
12
  switch!(account)
13
+ puts "=============== updating #{account.name} ============"
11
14
 
12
- rerun_exporters_and_delete_zips
15
+ make_new_exports
13
16
 
14
17
  puts "=============== finished updating #{account.name} ============"
15
18
  end
16
19
  else
17
- rerun_exporters_and_delete_zips
20
+ make_new_exports
18
21
  end
19
22
  end
20
23
 
21
- def rerun_exporters_and_delete_zips
22
- begin
23
- Bulkrax::Exporter.all.each { |e| Bulkrax::ExporterJob.perform_later(e.id) }
24
- rescue => e
25
- puts "(#{e.message})"
26
- end
27
-
28
- Dir["tmp/exports/**.zip"].each { |zip_path| FileUtils.rm_rf(zip_path) }
24
+ def make_new_exports
25
+ Bulkrax::Exporter.all.each { |e| Bulkrax::ExporterJob.perform_later(e.id) }
26
+ rescue => e
27
+ puts "(#{e.message})"
29
28
  end
30
29
  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.2.1
4
+ version: 4.4.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: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2022-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -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
@@ -351,6 +352,9 @@ files:
351
352
  - app/views/bulkrax/importers/upload_corrected_entries.html.erb
352
353
  - app/views/bulkrax/shared/_bulkrax_errors.html.erb
353
354
  - app/views/bulkrax/shared/_bulkrax_field_mapping.html.erb
355
+ - app/views/bulkrax/shared/_collection_entries_tab.html.erb
356
+ - app/views/bulkrax/shared/_file_set_entries_tab.html.erb
357
+ - app/views/bulkrax/shared/_work_entries_tab.html.erb
354
358
  - app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb
355
359
  - app/views/hyrax/dashboard/sidebar/_repository_content.html.erb
356
360
  - app/views/layouts/bulkrax/application.html.erb
@@ -401,6 +405,7 @@ files:
401
405
  - lib/generators/bulkrax/templates/config/bulkrax_api.yml
402
406
  - lib/generators/bulkrax/templates/config/initializers/bulkrax.rb
403
407
  - lib/tasks/bulkrax_tasks.rake
408
+ - lib/tasks/reset.rake
404
409
  homepage: https://github.com/samvera-labs/bulkrax
405
410
  licenses:
406
411
  - Apache-2.0