bulkrax 3.0.0.beta8 → 3.1.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/jobs/bulkrax/create_relationships_job.rb +10 -12
- data/app/jobs/bulkrax/export_work_job.rb +1 -0
- data/app/models/bulkrax/csv_entry.rb +1 -0
- data/app/models/bulkrax/exporter.rb +2 -1
- data/app/models/bulkrax/importer.rb +1 -1
- data/app/models/concerns/bulkrax/import_behavior.rb +62 -1
- data/app/parsers/bulkrax/csv_parser.rb +1 -1
- data/lib/bulkrax/version.rb +1 -1
- data/lib/bulkrax.rb +7 -4
- data/lib/generators/bulkrax/templates/config/initializers/bulkrax.rb +6 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23cd36b2c3dc13769f7d20da3c0d53f2d5c2cabef15d5beeeccee75aed6d679a
|
4
|
+
data.tar.gz: 868f0ec5c54862943e126af0ecf63d49771bc9a4ac88e566074205d7077e063c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f9c359a539054dba54000ca30bd1209bb862254c75463c2598807e8fd91e7e562e3bd6203f5f347ffe17da22f58d7915c1090109e88aabccac774c0281b1ee
|
7
|
+
data.tar.gz: 11c0083e67c4add719f04c01d20fac3216f6e994407dfdc48ae5f6d82696241a2b81ef6156279568b92e4bd56d3598085e83bac3718d04892a4fc96bbefd1028
|
@@ -82,18 +82,18 @@ module Bulkrax
|
|
82
82
|
# Work-Collection membership is added to the child as member_of_collection_ids
|
83
83
|
# This is adding the reverse relationship, from the child to the parent
|
84
84
|
def collection_parent_work_child
|
85
|
-
child_records[:works].
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
child_work_ids = child_records[:works].map(&:id)
|
86
|
+
parent_record.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
|
87
|
+
|
88
|
+
parent_record.add_member_objects(child_work_ids)
|
89
|
+
ImporterRun.find(importer_run_id).increment!(:processed_relationships, child_work_ids.count) # rubocop:disable Rails/SkipsModelValidations
|
90
90
|
end
|
91
91
|
|
92
92
|
# Collection-Collection membership is added to the as member_ids
|
93
93
|
def collection_parent_collection_child
|
94
94
|
child_records[:collections].each do |child_record|
|
95
95
|
::Hyrax::Collections::NestedCollectionPersistenceService.persist_nested_collection_for(parent: parent_record, child: child_record)
|
96
|
-
|
96
|
+
ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -103,14 +103,12 @@ module Bulkrax
|
|
103
103
|
child_records[:works].each_with_index do |child_record, i|
|
104
104
|
records_hash[i] = { id: child_record.id }
|
105
105
|
end
|
106
|
-
attrs = {
|
107
|
-
|
108
|
-
}
|
109
|
-
parent_record.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if parent_record.respond_to?(:reindex_extent)
|
106
|
+
attrs = { work_members_attributes: records_hash }
|
107
|
+
parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX)
|
110
108
|
env = Hyrax::Actors::Environment.new(parent_record, Ability.new(user), attrs)
|
109
|
+
|
111
110
|
Hyrax::CurationConcern.actor.update(env)
|
112
|
-
|
113
|
-
Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
|
111
|
+
ImporterRun.find(importer_run_id).increment!(:processed_relationships, child_records[:works].count) # rubocop:disable Rails/SkipsModelValidations
|
114
112
|
end
|
115
113
|
|
116
114
|
def reschedule(parent_identifier:, importer_run_id:)
|
@@ -96,7 +96,8 @@ module Bulkrax
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def current_run
|
99
|
-
|
99
|
+
total = self.limit || parser.total
|
100
|
+
@current_run ||= self.exporter_runs.create!(total_work_entries: total, enqueued_records: total)
|
100
101
|
end
|
101
102
|
|
102
103
|
def last_run
|
@@ -142,7 +142,7 @@ module Bulkrax
|
|
142
142
|
|
143
143
|
def import_objects(types_array = nil)
|
144
144
|
self.only_updates ||= false
|
145
|
-
types = types_array || %w[work
|
145
|
+
types = types_array || %w[collection work file_set relationship]
|
146
146
|
if parser.class == Bulkrax::CsvParser
|
147
147
|
parser.create_objects(types)
|
148
148
|
else
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Bulkrax
|
4
4
|
# Import Behavior for Entry classes
|
5
|
-
module ImportBehavior
|
5
|
+
module ImportBehavior # rubocop:disable Metrics/ModuleLength
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
def build_for_importer
|
@@ -21,6 +21,8 @@ module Bulkrax
|
|
21
21
|
status_info(e)
|
22
22
|
else
|
23
23
|
status_info
|
24
|
+
ensure
|
25
|
+
self.save!
|
24
26
|
end
|
25
27
|
return @item
|
26
28
|
end
|
@@ -103,6 +105,65 @@ module Bulkrax
|
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
108
|
+
# Attempt to sanitize Questioning Authority URI values for configured controlled fields of common
|
109
|
+
# data entry mistakes. Controlled URI values are only valid if they are an exact match.
|
110
|
+
# Example:
|
111
|
+
# Valid value: http://rightsstatements.org/vocab/InC/1.0/
|
112
|
+
# Provided value: https://rightsstatements.org/vocab/InC/1.0
|
113
|
+
# Sanitized value: http://rightsstatements.org/vocab/InC/1.0/ ("s" from "https" removed, trailing "/" added)
|
114
|
+
#
|
115
|
+
# @return [Boolean] true if all controlled URI values are sanitized successfully
|
116
|
+
def sanitize_controlled_uri_values!
|
117
|
+
Bulkrax.qa_controlled_properties.each do |field|
|
118
|
+
next if parsed_metadata[field].blank?
|
119
|
+
|
120
|
+
parsed_metadata[field].each_with_index do |value, i|
|
121
|
+
next if value.blank?
|
122
|
+
|
123
|
+
if (validated_uri_value = validate_value(value, field))
|
124
|
+
parsed_metadata[field][i] = validated_uri_value
|
125
|
+
else
|
126
|
+
debug_msg = %(Unable to locate active authority ID "#{value}" in config/authorities/#{field.pluralize}.yml)
|
127
|
+
Rails.logger.debug(debug_msg)
|
128
|
+
error_msg = %("#{value}" is not a valid and/or active authority ID for the :#{field} field)
|
129
|
+
raise ::StandardError, error_msg
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
true
|
135
|
+
end
|
136
|
+
|
137
|
+
# @param value [String] value to validate
|
138
|
+
# @param field [String] name of the controlled property
|
139
|
+
# @return [String, nil] validated URI value or nil
|
140
|
+
def validate_value(value, field)
|
141
|
+
if value.match?(::URI::DEFAULT_PARSER.make_regexp)
|
142
|
+
value = value.strip.chomp
|
143
|
+
# add trailing forward slash unless one is already present
|
144
|
+
value << '/' unless value.match?(%r{/$})
|
145
|
+
end
|
146
|
+
|
147
|
+
valid = if active_id_for_authority?(value, field)
|
148
|
+
true
|
149
|
+
else
|
150
|
+
value.include?('https') ? value.sub!('https', 'http') : value.sub!('http', 'https')
|
151
|
+
active_id_for_authority?(value, field)
|
152
|
+
end
|
153
|
+
|
154
|
+
valid ? value : nil
|
155
|
+
end
|
156
|
+
|
157
|
+
# @param value [String] value to check
|
158
|
+
# @param field [String] name of the controlled property
|
159
|
+
# @return [Boolean] provided value is a present, active authority ID for the provided field
|
160
|
+
def active_id_for_authority?(value, field)
|
161
|
+
field_service = ('Hyrax::' + "#{field}_service".camelcase).constantize
|
162
|
+
active_authority_ids = field_service.new.active_elements.map { |ae| ae['id'] }
|
163
|
+
|
164
|
+
active_authority_ids.include?(value)
|
165
|
+
end
|
166
|
+
|
106
167
|
def factory
|
107
168
|
@factory ||= Bulkrax::ObjectFactory.new(attributes: self.parsed_metadata,
|
108
169
|
source_identifier_value: identifier,
|
@@ -270,7 +270,7 @@ module Bulkrax
|
|
270
270
|
# Changed to grep as wc -l counts blank lines, and ignores the final unescaped line (which may or may not contain data)
|
271
271
|
def total
|
272
272
|
@total = importer.parser_fields['total'] || 0 if importer?
|
273
|
-
@total =
|
273
|
+
@total = limit || current_record_ids.count if exporter?
|
274
274
|
|
275
275
|
return @total || 0
|
276
276
|
rescue StandardError
|
data/lib/bulkrax/version.rb
CHANGED
data/lib/bulkrax.rb
CHANGED
@@ -12,13 +12,13 @@ module Bulkrax
|
|
12
12
|
:related_children_field_mapping,
|
13
13
|
:related_parents_field_mapping,
|
14
14
|
:reserved_properties,
|
15
|
+
:qa_controlled_properties,
|
15
16
|
:field_mappings,
|
16
17
|
:import_path,
|
17
18
|
:export_path,
|
18
19
|
:removed_image_path,
|
19
20
|
:server_name,
|
20
|
-
:api_definition
|
21
|
-
:removed_image_path
|
21
|
+
:api_definition
|
22
22
|
|
23
23
|
self.parsers = [
|
24
24
|
{ name: "OAI - Dublin Core", class_name: "Bulkrax::OaiDcParser", partial: "oai_fields" },
|
@@ -119,6 +119,11 @@ module Bulkrax
|
|
119
119
|
original_url
|
120
120
|
relative_path
|
121
121
|
]
|
122
|
+
|
123
|
+
# List of Questioning Authority properties that are controlled via YAML files in
|
124
|
+
# the config/authorities/ directory. For example, the :rights_statement property
|
125
|
+
# is controlled by the active terms in config/authorities/rights_statements.yml
|
126
|
+
self.qa_controlled_properties = %w[rights_statement license]
|
122
127
|
end
|
123
128
|
|
124
129
|
def self.api_definition
|
@@ -131,8 +136,6 @@ module Bulkrax
|
|
131
136
|
)
|
132
137
|
end
|
133
138
|
|
134
|
-
self.removed_image_path = 'app/assets/images/bulkrax/removed.png'
|
135
|
-
|
136
139
|
# this function maps the vars from your app into your engine
|
137
140
|
def self.setup
|
138
141
|
yield self
|
@@ -61,6 +61,12 @@ Bulkrax.setup do |config|
|
|
61
61
|
|
62
62
|
# Properties that should not be used in imports/exports. They are reserved for use by Hyrax.
|
63
63
|
# config.reserved_properties += ['my_field']
|
64
|
+
|
65
|
+
# List of Questioning Authority properties that are controlled via YAML files in
|
66
|
+
# the config/authorities/ directory. For example, the :rights_statement property
|
67
|
+
# is controlled by the active terms in config/authorities/rights_statements.yml
|
68
|
+
# Defaults: 'rights_statement' and 'license'
|
69
|
+
# config.qa_controlled_properties += ['my_field']
|
64
70
|
end
|
65
71
|
|
66
72
|
# Sidebar for hyrax 3+ support
|
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.1.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-05-
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -393,9 +393,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
393
393
|
version: '0'
|
394
394
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
395
395
|
requirements:
|
396
|
-
- - "
|
396
|
+
- - ">="
|
397
397
|
- !ruby/object:Gem::Version
|
398
|
-
version:
|
398
|
+
version: '0'
|
399
399
|
requirements: []
|
400
400
|
rubygems_version: 3.1.4
|
401
401
|
signing_key:
|