bulkrax 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/jobs/bulkrax/delete_collection_job.rb +5 -0
- data/app/jobs/bulkrax/delete_file_set_job.rb +5 -0
- data/app/jobs/bulkrax/delete_job.rb +20 -0
- data/app/jobs/bulkrax/delete_work_job.rb +1 -16
- data/app/models/bulkrax/csv_entry.rb +24 -29
- data/app/models/concerns/bulkrax/export_behavior.rb +1 -1
- data/app/parsers/bulkrax/csv_parser.rb +4 -2
- data/app/views/bulkrax/importers/show.html.erb +1 -1
- data/lib/bulkrax/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b7cfb404f1878429bbac77aad6d1167e97377fe28b54e2042cee7f6ca04e67
|
4
|
+
data.tar.gz: c3789c193dc1610c99117e5e2c450ed477a7390995916c4b6b419900f5cf539b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a669e9b566770ad21e3a6242d24779f5c73847b2b97d4f7334f06209ac7de3634e7667550ba35ce6930f9ceaffda8efccb29cf3277b40f29d808ddbd9623a1b8
|
7
|
+
data.tar.gz: 794e6de65d4ebb5665ab73fdac3eba2d4157ff1b07f3da6cc63a6323b2127dc40021d69ea193da2a356e276f08dde8ccc51dc1d8c563e5ba3e8ecb592e4b4c88
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bulkrax
|
4
|
+
class DeleteJob < ApplicationJob
|
5
|
+
queue_as :import
|
6
|
+
|
7
|
+
# rubocop:disable Rails/SkipsModelValidations
|
8
|
+
def perform(entry, importer_run)
|
9
|
+
obj = entry.factory.find
|
10
|
+
obj&.delete
|
11
|
+
ImporterRun.find(importer_run.id).increment!(:deleted_records)
|
12
|
+
ImporterRun.find(importer_run.id).decrement!(:enqueued_records)
|
13
|
+
entry.save!
|
14
|
+
entry.importer.current_run = ImporterRun.find(importer_run.id)
|
15
|
+
entry.importer.record_status
|
16
|
+
entry.status_info("Deleted", ImporterRun.find(importer_run.id))
|
17
|
+
end
|
18
|
+
# rubocop:enable Rails/SkipsModelValidations
|
19
|
+
end
|
20
|
+
end
|
@@ -1,20 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Bulkrax
|
4
|
-
class DeleteWorkJob <
|
5
|
-
queue_as :import
|
6
|
-
|
7
|
-
# rubocop:disable Rails/SkipsModelValidations
|
8
|
-
def perform(entry, importer_run)
|
9
|
-
work = entry.factory.find
|
10
|
-
work&.delete
|
11
|
-
ImporterRun.find(importer_run.id).increment!(:deleted_records)
|
12
|
-
ImporterRun.find(importer_run.id).decrement!(:enqueued_records)
|
13
|
-
entry.save!
|
14
|
-
entry.importer.current_run = ImporterRun.find(importer_run.id)
|
15
|
-
entry.importer.record_status
|
16
|
-
entry.status_info("Deleted", ImporterRun.find(importer_run.id))
|
17
|
-
end
|
18
|
-
# rubocop:enable Rails/SkipsModelValidations
|
19
|
-
end
|
4
|
+
class DeleteWorkJob < DeleteJob; end
|
20
5
|
end
|
@@ -93,17 +93,31 @@ module Bulkrax
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def build_export_metadata
|
96
|
-
# make_round_trippable
|
97
96
|
self.parsed_metadata = {}
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
|
98
|
+
build_system_metadata
|
99
|
+
build_files_metadata unless hyrax_record.is_a?(Collection)
|
101
100
|
build_relationship_metadata
|
102
101
|
build_mapping_metadata
|
103
|
-
|
102
|
+
|
104
103
|
self.parsed_metadata
|
105
104
|
end
|
106
105
|
|
106
|
+
# Metadata required by Bulkrax for round-tripping
|
107
|
+
def build_system_metadata
|
108
|
+
self.parsed_metadata['id'] = hyrax_record.id
|
109
|
+
self.parsed_metadata[source_identifier] = hyrax_record.send(work_identifier)
|
110
|
+
self.parsed_metadata[key_for_export('model')] = hyrax_record.has_model.first
|
111
|
+
end
|
112
|
+
|
113
|
+
def build_files_metadata
|
114
|
+
file_mapping = key_for_export('file')
|
115
|
+
file_sets = hyrax_record.file_set? ? Array.wrap(hyrax_record) : hyrax_record.file_sets
|
116
|
+
filenames = file_sets.map { |fs| filename(fs).to_s if filename(fs).present? }.compact
|
117
|
+
|
118
|
+
handle_join_on_export(file_mapping, filenames, mapping['file']&.[]('join')&.present?)
|
119
|
+
end
|
120
|
+
|
107
121
|
def build_relationship_metadata
|
108
122
|
# Includes all relationship methods for all exportable record types (works, Collections, FileSets)
|
109
123
|
relationship_methods = {
|
@@ -127,12 +141,10 @@ module Bulkrax
|
|
127
141
|
|
128
142
|
def build_mapping_metadata
|
129
143
|
mapping.each do |key, value|
|
130
|
-
|
131
|
-
next if
|
132
|
-
# relationships handled by #build_relationship_metadata
|
133
|
-
next if [related_parents_parsed_mapping, related_children_parsed_mapping].include?(key)
|
134
|
-
next if key == 'file' # handled by #build_files
|
144
|
+
# these keys are handled by other methods
|
145
|
+
next if ['model', 'file', related_parents_parsed_mapping, related_children_parsed_mapping].include?(key)
|
135
146
|
next if value['excluded']
|
147
|
+
next if Bulkrax.reserved_properties.include?(key) && !field_supported?(key)
|
136
148
|
|
137
149
|
object_key = key if value.key?('object')
|
138
150
|
next unless hyrax_record.respond_to?(key.to_s) || object_key.present?
|
@@ -205,14 +217,6 @@ module Bulkrax
|
|
205
217
|
end
|
206
218
|
end
|
207
219
|
|
208
|
-
def build_files
|
209
|
-
file_mapping = mapping['file']&.[]('from')&.first || 'file'
|
210
|
-
file_sets = hyrax_record.file_set? ? Array.wrap(hyrax_record) : hyrax_record.file_sets
|
211
|
-
|
212
|
-
filenames = file_sets.map { |fs| filename(fs).to_s if filename(fs).present? }.compact
|
213
|
-
handle_join_on_export(file_mapping, filenames, mapping['file']&.[]('join')&.present?)
|
214
|
-
end
|
215
|
-
|
216
220
|
def handle_join_on_export(key, values, join)
|
217
221
|
if join
|
218
222
|
parsed_metadata[key] = values.join(' | ') # TODO: make split char dynamic
|
@@ -224,16 +228,6 @@ module Bulkrax
|
|
224
228
|
end
|
225
229
|
end
|
226
230
|
|
227
|
-
# In order for the existing exported hyrax_record, to be updated by a re-import
|
228
|
-
# we need a unique value in system_identifier
|
229
|
-
# add the existing hyrax_record id to system_identifier
|
230
|
-
def make_round_trippable
|
231
|
-
values = hyrax_record.send(work_identifier.to_s).to_a
|
232
|
-
values << hyrax_record.id
|
233
|
-
hyrax_record.send("#{work_identifier}=", values)
|
234
|
-
hyrax_record.save
|
235
|
-
end
|
236
|
-
|
237
231
|
def record
|
238
232
|
@record ||= raw_metadata
|
239
233
|
end
|
@@ -263,7 +257,8 @@ module Bulkrax
|
|
263
257
|
end
|
264
258
|
|
265
259
|
def collections_created?
|
266
|
-
|
260
|
+
# TODO: look into if this method is still needed after new relationships code
|
261
|
+
true
|
267
262
|
end
|
268
263
|
|
269
264
|
def find_collection_ids
|
@@ -11,12 +11,15 @@ module Bulkrax
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def records(_opts = {})
|
14
|
+
return @records if @records.present?
|
15
|
+
|
14
16
|
file_for_import = only_updates ? parser_fields['partial_import_file_path'] : import_file_path
|
15
17
|
# data for entry does not need source_identifier for csv, because csvs are read sequentially and mapped after raw data is read.
|
16
18
|
csv_data = entry_class.read_data(file_for_import)
|
17
19
|
importer.parser_fields['total'] = csv_data.count
|
18
20
|
importer.save
|
19
|
-
|
21
|
+
|
22
|
+
@records = csv_data.map { |record_data| entry_class.data_for_entry(record_data, nil, self) }
|
20
23
|
end
|
21
24
|
|
22
25
|
def build_records
|
@@ -145,7 +148,6 @@ module Bulkrax
|
|
145
148
|
'Bulkrax::Importer',
|
146
149
|
current_record.to_h)
|
147
150
|
if current_record[:delete].present?
|
148
|
-
# TODO: create a "Delete" job for file_sets and collections
|
149
151
|
"Bulkrax::Delete#{type.camelize}Job".constantize.send(perform_method, new_entry, current_run)
|
150
152
|
else
|
151
153
|
"Bulkrax::Import#{type.camelize}Job".constantize.send(perform_method, new_entry.id, current_run.id)
|
@@ -178,7 +178,7 @@
|
|
178
178
|
<% elsif e.status == "Pending" %>
|
179
179
|
<td><span class="glyphicon glyphicon-option-horizontal" style="color: blue;"></span> <%= e.status %></td>
|
180
180
|
<% else %>
|
181
|
-
<td><span class="glyphicon glyphicon-remove" style="color: red
|
181
|
+
<td><span class="glyphicon glyphicon-remove" style="color: <%= e.status == 'Deleted' ? 'green' : 'red' %>;"></span> <%= e.status %></td>
|
182
182
|
<% end %>
|
183
183
|
<% if e.last_error.present? %>
|
184
184
|
<td><%= link_to e.last_error.dig("error_class"), bulkrax.importer_entry_path(@importer.id, e.id) %></td>
|
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: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Kaufman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -260,6 +260,9 @@ files:
|
|
260
260
|
- app/helpers/bulkrax/validation_helper.rb
|
261
261
|
- app/jobs/bulkrax/application_job.rb
|
262
262
|
- app/jobs/bulkrax/create_relationships_job.rb
|
263
|
+
- app/jobs/bulkrax/delete_collection_job.rb
|
264
|
+
- app/jobs/bulkrax/delete_file_set_job.rb
|
265
|
+
- app/jobs/bulkrax/delete_job.rb
|
263
266
|
- app/jobs/bulkrax/delete_work_job.rb
|
264
267
|
- app/jobs/bulkrax/download_cloud_file_job.rb
|
265
268
|
- app/jobs/bulkrax/export_work_job.rb
|
@@ -384,7 +387,7 @@ homepage: https://github.com/samvera-labs/bulkrax
|
|
384
387
|
licenses:
|
385
388
|
- Apache-2.0
|
386
389
|
metadata: {}
|
387
|
-
post_install_message:
|
390
|
+
post_install_message:
|
388
391
|
rdoc_options: []
|
389
392
|
require_paths:
|
390
393
|
- lib
|
@@ -399,8 +402,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
402
|
- !ruby/object:Gem::Version
|
400
403
|
version: '0'
|
401
404
|
requirements: []
|
402
|
-
rubygems_version: 3.
|
403
|
-
signing_key:
|
405
|
+
rubygems_version: 3.1.4
|
406
|
+
signing_key:
|
404
407
|
specification_version: 4
|
405
408
|
summary: Import and export tool for Hyrax and Hyku
|
406
409
|
test_files: []
|