bulkrax 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/bulkrax/importers.js.erb +1 -1
- data/app/models/bulkrax/csv_entry.rb +18 -6
- data/app/models/concerns/bulkrax/has_matchers.rb +1 -0
- data/app/models/concerns/bulkrax/importer_exporter_behavior.rb +6 -5
- data/app/parsers/bulkrax/csv_parser.rb +39 -21
- data/lib/bulkrax/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 264fedacd4fc13cbd7450068ff6f16317b9ff33e6f28edf48484652fcdf50c0a
|
4
|
+
data.tar.gz: c91b6d74984569513ae567cc879558fbbc5374b6379ca272c744d5be5972ef45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501a1a4bae256c70c35524e3a41d46f25c4d464c180355b10ae47ea13acc1ee20c22a1763c4908ce3821162b7ebd7c1c3a4b975f27ce32a9014a50d04c1c1f18
|
7
|
+
data.tar.gz: 63fbe35c7bf2496d46434fc1d1b8775e4d1b3c5c43529ed258d030ec6816d8a89ad7c9e90a9dc73e21e699f7efabee1dc6279d59840defce087eeeb7db023483
|
@@ -49,7 +49,7 @@ function prepBulkrax(event) {
|
|
49
49
|
for(var mutation of mutationsList) {
|
50
50
|
if (mutation.type == 'childList') {
|
51
51
|
browseButton = document.getElementById('browse');
|
52
|
-
var exp = /selected_files\[[0-9
|
52
|
+
var exp = /selected_files\[[0-9]*\]\[url\]/
|
53
53
|
for (var node of mutation.addedNodes) {
|
54
54
|
if (node.attributes != undefined) {
|
55
55
|
var name = node.attributes.name.value
|
@@ -3,7 +3,10 @@
|
|
3
3
|
require 'csv'
|
4
4
|
|
5
5
|
module Bulkrax
|
6
|
-
class
|
6
|
+
# TODO: We need to rework this class some to address the Metrics/ClassLength rubocop offense.
|
7
|
+
# We do too much in these entry classes. We need to extract the common logic from the various
|
8
|
+
# entry models into a module that can be shared between them.
|
9
|
+
class CsvEntry < Entry # rubocop:disable Metrics/ClassLength
|
7
10
|
serialize :raw_metadata, JSON
|
8
11
|
|
9
12
|
def self.fields_from_data(data)
|
@@ -40,8 +43,8 @@ module Bulkrax
|
|
40
43
|
|
41
44
|
self.parsed_metadata = {}
|
42
45
|
add_identifier
|
43
|
-
add_visibility
|
44
46
|
add_ingested_metadata
|
47
|
+
add_visibility
|
45
48
|
add_metadata_for_model
|
46
49
|
add_rights_statement
|
47
50
|
add_collections
|
@@ -229,10 +232,19 @@ module Bulkrax
|
|
229
232
|
'Creating Collections using the collection_field_mapping will no longer be supported as of Bulkrax version 3.0.' \
|
230
233
|
' Please configure Bulkrax to use related_parents_field_mapping and related_children_field_mapping instead.'
|
231
234
|
)
|
232
|
-
@possible_collection_ids
|
233
|
-
|
234
|
-
|
235
|
-
|
235
|
+
return @possible_collection_ids if @possible_collection_ids.present?
|
236
|
+
|
237
|
+
collection_field_mapping = self.class.collection_field
|
238
|
+
return [] unless collection_field_mapping.present? && record[collection_field_mapping].present?
|
239
|
+
|
240
|
+
identifiers = []
|
241
|
+
split_titles = record[collection_field_mapping].split(/\s*[;|]\s*/)
|
242
|
+
split_titles.each do |c_title|
|
243
|
+
matching_collection_entries = importerexporter.entries.select { |e| e.raw_metadata['title'] == c_title }
|
244
|
+
raise ::StandardError, 'Only expected to find one matching entry' if matching_collection_entries.count > 1
|
245
|
+
identifiers << matching_collection_entries.first&.identifier
|
246
|
+
end
|
247
|
+
@possible_collection_ids = identifiers.compact.presence || []
|
236
248
|
end
|
237
249
|
|
238
250
|
def collections_created?
|
@@ -22,16 +22,17 @@ module Bulkrax
|
|
22
22
|
|
23
23
|
def increment_counters(index, collection: false, file_set: false)
|
24
24
|
# Only set the totals if they were not set on initialization
|
25
|
+
importer_run = ImporterRun.find(current_run.id) # make sure fresh
|
25
26
|
if collection
|
26
|
-
|
27
|
+
importer_run.total_collection_entries = index + 1 unless parser.collections_total.positive?
|
27
28
|
elsif file_set
|
28
|
-
|
29
|
+
importer_run.total_file_set_entries = index + 1 unless parser.file_sets_total.positive?
|
29
30
|
else
|
30
31
|
# TODO: differentiate between work and collection counts for exporters
|
31
|
-
|
32
|
+
importer_run.total_work_entries = index + 1 unless limit.to_i.positive? || parser.total.positive?
|
32
33
|
end
|
33
|
-
|
34
|
-
|
34
|
+
importer_run.enqueued_records += 1
|
35
|
+
importer_run.save!
|
35
36
|
end
|
36
37
|
|
37
38
|
def keys_without_numbers(keys)
|
@@ -88,31 +88,30 @@ module Bulkrax
|
|
88
88
|
collections.each_with_index do |collection, index|
|
89
89
|
next if collection.blank?
|
90
90
|
break if records.find_index(collection).present? && limit_reached?(limit, records.find_index(collection))
|
91
|
-
ActiveSupport::Deprecation.warn(
|
92
|
-
'Creating Collections using the collection_field_mapping will no longer be supported as of Bulkrax version 3.0.' \
|
93
|
-
' Please configure Bulkrax to use related_parents_field_mapping and related_children_field_mapping instead.'
|
94
|
-
)
|
95
91
|
|
96
92
|
## BEGIN
|
97
93
|
# Add required metadata to collections being imported using the collection_field_mapping, which only have a :title
|
98
94
|
# TODO: Remove once collection_field_mapping is removed
|
99
|
-
metadata =
|
100
|
-
uci = unique_collection_identifier(collection)
|
101
|
-
{
|
102
|
-
title: collection[:title],
|
103
|
-
work_identifier => uci,
|
104
|
-
source_identifier => uci,
|
105
|
-
visibility: 'open',
|
106
|
-
collection_type_gid: ::Hyrax::CollectionType.find_or_create_default_collection_type.gid
|
107
|
-
}
|
108
|
-
end
|
95
|
+
metadata = add_required_collection_metadata(collection)
|
109
96
|
collection_hash = metadata.presence || collection
|
110
97
|
## END
|
111
98
|
|
112
99
|
new_entry = find_or_create_entry(collection_entry_class, collection_hash[source_identifier], 'Bulkrax::Importer', collection_hash)
|
113
100
|
increment_counters(index, collection: true)
|
114
101
|
# TODO: add support for :delete option
|
115
|
-
|
102
|
+
if collection.key?(:from_collection_field_mapping)
|
103
|
+
ActiveSupport::Deprecation.warn(
|
104
|
+
'Creating Collections using the collection_field_mapping will no longer be supported as of Bulkrax version 3.0.' \
|
105
|
+
' Please configure Bulkrax to use related_parents_field_mapping and related_children_field_mapping instead.'
|
106
|
+
)
|
107
|
+
# When importing collections using the deprecated collection_field_mapping, the collection MUST be created
|
108
|
+
# before the work, so we use #perform_now to make sure that happens. The downside is, if a collection fails
|
109
|
+
# to import, it will stop the rest of the collections from importing successfully.
|
110
|
+
# TODO: Remove once collection_field_mapping is removed
|
111
|
+
ImportCollectionJob.perform_now(new_entry.id, current_run.id)
|
112
|
+
else
|
113
|
+
ImportCollectionJob.perform_later(new_entry.id, current_run.id)
|
114
|
+
end
|
116
115
|
end
|
117
116
|
importer.record_status
|
118
117
|
rescue StandardError => e
|
@@ -152,6 +151,25 @@ module Bulkrax
|
|
152
151
|
status_info(e)
|
153
152
|
end
|
154
153
|
|
154
|
+
# Add required metadata to collections being imported using the collection_field_mapping, which only have a :title
|
155
|
+
# TODO: Remove once collection_field_mapping is removed
|
156
|
+
def add_required_collection_metadata(raw_collection_data)
|
157
|
+
return unless raw_collection_data.key?(:from_collection_field_mapping)
|
158
|
+
ActiveSupport::Deprecation.warn(
|
159
|
+
'Creating Collections using the collection_field_mapping will no longer be supported as of Bulkrax version 3.0.' \
|
160
|
+
' Please configure Bulkrax to use related_parents_field_mapping and related_children_field_mapping instead.'
|
161
|
+
)
|
162
|
+
|
163
|
+
uci = unique_collection_identifier(raw_collection_data)
|
164
|
+
{
|
165
|
+
title: raw_collection_data[:title],
|
166
|
+
work_identifier => uci,
|
167
|
+
source_identifier => uci,
|
168
|
+
visibility: 'open',
|
169
|
+
collection_type_gid: ::Hyrax::CollectionType.find_or_create_default_collection_type.gid
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
155
173
|
def write_partial_import_file(file)
|
156
174
|
import_filename = import_file_path.split('/').last
|
157
175
|
partial_import_filename = "#{File.basename(import_filename, '.csv')}_corrected_entries.csv"
|
@@ -188,13 +206,13 @@ module Bulkrax
|
|
188
206
|
|
189
207
|
case importerexporter.export_from
|
190
208
|
when 'all'
|
191
|
-
@work_ids = ActiveFedora::SolrService.query("has_model_ssim:(#{Hyrax.config.curation_concerns.join(' OR ')}) #{extra_filters}", rows: 2_147_483_647).map(&:id)
|
192
|
-
@collection_ids = ActiveFedora::SolrService.query("has_model_ssim:Collection #{extra_filters}", rows: 2_147_483_647).map(&:id)
|
193
|
-
@file_set_ids = ActiveFedora::SolrService.query("has_model_ssim:FileSet #{extra_filters}", rows: 2_147_483_647).map(&:id)
|
209
|
+
@work_ids = ActiveFedora::SolrService.query("has_model_ssim:(#{Hyrax.config.curation_concerns.join(' OR ')}) #{extra_filters}", method: :post, rows: 2_147_483_647).map(&:id)
|
210
|
+
@collection_ids = ActiveFedora::SolrService.query("has_model_ssim:Collection #{extra_filters}", method: :post, rows: 2_147_483_647).map(&:id)
|
211
|
+
@file_set_ids = ActiveFedora::SolrService.query("has_model_ssim:FileSet #{extra_filters}", method: :post, rows: 2_147_483_647).map(&:id)
|
194
212
|
when 'collection'
|
195
|
-
@work_ids = ActiveFedora::SolrService.query("member_of_collection_ids_ssim:#{importerexporter.export_source + extra_filters}", rows: 2_000_000_000).map(&:id)
|
213
|
+
@work_ids = ActiveFedora::SolrService.query("member_of_collection_ids_ssim:#{importerexporter.export_source + extra_filters}", method: :post, rows: 2_000_000_000).map(&:id)
|
196
214
|
when 'worktype'
|
197
|
-
@work_ids = ActiveFedora::SolrService.query("has_model_ssim:#{importerexporter.export_source + extra_filters}", rows: 2_000_000_000).map(&:id)
|
215
|
+
@work_ids = ActiveFedora::SolrService.query("has_model_ssim:#{importerexporter.export_source + extra_filters}", method: :post, rows: 2_000_000_000).map(&:id)
|
198
216
|
when 'importer'
|
199
217
|
set_ids_for_exporting_from_importer
|
200
218
|
end
|
@@ -214,7 +232,7 @@ module Bulkrax
|
|
214
232
|
extra_filters = extra_filters.presence || '*:*'
|
215
233
|
|
216
234
|
{ :@work_ids => ::Hyrax.config.curation_concerns, :@collection_ids => [::Collection], :@file_set_ids => [::FileSet] }.each do |instance_var, models_to_search|
|
217
|
-
instance_variable_set(instance_var, ActiveFedora::SolrService.
|
235
|
+
instance_variable_set(instance_var, ActiveFedora::SolrService.post(
|
218
236
|
extra_filters.to_s,
|
219
237
|
fq: [
|
220
238
|
"#{work_identifier}_sim:(#{complete_entry_identifiers.join(' OR ')})",
|
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: 2.
|
4
|
+
version: 2.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: 2022-
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|