bulkrax 2.1.1 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a35c9f6307c21a9933950a3d383ab04e5a49e15b9980d76f6cfb52a5378f5dd0
4
- data.tar.gz: d5a58eeb2b755c68e6c66103afb5dbc649205aed73b2d85167246ca912bb07bf
3
+ metadata.gz: 2f9006f783a5184f832fe78344acc3e7acca920c75a9a92ed2c604246102f6e8
4
+ data.tar.gz: c834fa1558b8dba4e0fd1024e552ddfc0eb5dfdad307aa13283da41abc2ca609
5
5
  SHA512:
6
- metadata.gz: d01b9ecd45171f2b20a5c33605fafe645b7c389a141ed70b41a04ecb7bcf1d1f1c4f430ea50fda7d7ef702fd12123cfd904868ba6468a306a41eca5643061e45
7
- data.tar.gz: 943eb873c86e40adf96cd7b0badb1ccce719f088d01aada4e18df90ec5a4f4df5b5ebfda5bfe6f74943c6fa371632937a0918f6aed70a4e14a75bcef0b7eaa0b
6
+ metadata.gz: 1c4a559ee030dc0b259b808cdc7067ad89ffcfe8d17f2483190e3503104edbd8daec737a8727a171eaca8a5bf218deb20c5c462eed5855ee1adaa9d60002ef26
7
+ data.tar.gz: 2882c50b2eee13f6df2e4b395c246e4909c3529cd7ead177fb5ec85effa1b32470c6da1e87d569b2efe22891a88e43b85855ae0a1bd30c204c1846daa33e41d4
@@ -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*]\]\[url\]/
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
@@ -12,7 +12,7 @@ module Bulkrax
12
12
 
13
13
  parsed_metadata['file'][i] = path_to_file
14
14
  end
15
- raise ::StandardError, 'one or more file paths are invalid' unless parsed_metadata['file'].map { |file_path| ::File.file?(file_path) }.all?
15
+ raise ::StandardError, "one or more file paths are invalid: #{parsed_metadata['file'].join(', ')}" unless parsed_metadata['file'].map { |file_path| ::File.file?(file_path) }.all?
16
16
 
17
17
  parsed_metadata['file']
18
18
  end
@@ -30,7 +30,7 @@ module Bulkrax
30
30
 
31
31
  # Create some headers for the datastream
32
32
  def content_options
33
- { disposition: 'inline', type: download_content_type, filename: file_name }
33
+ { disposition: 'attachment', type: download_content_type, filename: file_name }
34
34
  end
35
35
 
36
36
  # render an HTTP HEAD response
@@ -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
- current_run.total_collection_entries = index + 1 unless parser.collections_total.positive?
27
+ importer_run.total_collection_entries = index + 1 unless parser.collections_total.positive?
27
28
  elsif file_set
28
- current_run.total_file_set_entries = index + 1 unless parser.file_sets_total.positive?
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
- current_run.total_work_entries = index + 1 unless limit.to_i.positive? || parser.total.positive?
32
+ importer_run.total_work_entries = index + 1 unless limit.to_i.positive? || parser.total.positive?
32
33
  end
33
- current_run.enqueued_records += 1
34
- current_run.save!
34
+ importer_run.enqueued_records += 1
35
+ importer_run.save!
35
36
  end
36
37
 
37
38
  def keys_without_numbers(keys)
@@ -110,9 +110,9 @@ module Bulkrax
110
110
  ## END
111
111
 
112
112
  new_entry = find_or_create_entry(collection_entry_class, collection_hash[source_identifier], 'Bulkrax::Importer', collection_hash)
113
+ increment_counters(index, collection: true)
113
114
  # TODO: add support for :delete option
114
115
  ImportCollectionJob.perform_now(new_entry.id, current_run.id)
115
- increment_counters(index, collection: true)
116
116
  end
117
117
  importer.record_status
118
118
  rescue StandardError => e
@@ -177,40 +177,74 @@ module Bulkrax
177
177
  end
178
178
 
179
179
  def current_work_ids
180
+ ActiveSupport::Deprication.warn('Bulkrax::CsvParser#current_work_ids will be replaced with #current_record_ids in version 3.0')
181
+ current_record_ids
182
+ end
183
+
184
+ def current_record_ids
185
+ @work_ids = []
186
+ @collection_ids = []
187
+ @file_set_ids = []
188
+
180
189
  case importerexporter.export_from
181
190
  when 'all'
182
- ActiveFedora::SolrService.query("has_model_ssim:(#{Hyrax.config.curation_concerns.join(' OR ')}) #{extra_filters}", rows: 2_147_483_647).map(&:id)
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)
183
194
  when 'collection'
184
- ActiveFedora::SolrService.query("member_of_collection_ids_ssim:#{importerexporter.export_source + extra_filters}", rows: 2_000_000_000).map(&:id)
195
+ @work_ids = ActiveFedora::SolrService.query("member_of_collection_ids_ssim:#{importerexporter.export_source + extra_filters}", rows: 2_000_000_000).map(&:id)
185
196
  when 'worktype'
186
- ActiveFedora::SolrService.query("has_model_ssim:#{importerexporter.export_source + extra_filters}", rows: 2_000_000_000).map(&:id)
197
+ @work_ids = ActiveFedora::SolrService.query("has_model_ssim:#{importerexporter.export_source + extra_filters}", rows: 2_000_000_000).map(&:id)
187
198
  when 'importer'
188
- entry_ids = Bulkrax::Importer.find(importerexporter.export_source).entries.pluck(:id)
189
- complete_statuses = Bulkrax::Status.latest_by_statusable
190
- .includes(:statusable)
191
- .where('bulkrax_statuses.statusable_id IN (?) AND bulkrax_statuses.statusable_type = ? AND status_message = ?', entry_ids, 'Bulkrax::Entry', 'Complete')
199
+ set_ids_for_exporting_from_importer
200
+ end
192
201
 
193
- complete_entry_identifiers = complete_statuses.map { |s| s.statusable&.identifier&.gsub(':', '\:') }
194
- extra_filters = extra_filters.presence || '*:*'
202
+ @work_ids + @collection_ids + @file_set_ids
203
+ end
204
+
205
+ # Set the following instance variables: @work_ids, @collection_ids, @file_set_ids
206
+ # @see #current_record_ids
207
+ def set_ids_for_exporting_from_importer
208
+ entry_ids = Importer.find(importerexporter.export_source).entries.pluck(:id)
209
+ complete_statuses = Status.latest_by_statusable
210
+ .includes(:statusable)
211
+ .where('bulkrax_statuses.statusable_id IN (?) AND bulkrax_statuses.statusable_type = ? AND status_message = ?', entry_ids, 'Bulkrax::Entry', 'Complete')
212
+
213
+ complete_entry_identifiers = complete_statuses.map { |s| s.statusable&.identifier&.gsub(':', '\:') }
214
+ extra_filters = extra_filters.presence || '*:*'
195
215
 
196
- ActiveFedora::SolrService.get(
216
+ { :@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.get(
197
218
  extra_filters.to_s,
198
- fq: "#{work_identifier}_sim:(#{complete_entry_identifiers.join(' OR ')})",
219
+ fq: [
220
+ "#{work_identifier}_sim:(#{complete_entry_identifiers.join(' OR ')})",
221
+ "has_model_ssim:(#{models_to_search.join(' OR ')})"
222
+ ],
199
223
  fl: 'id',
200
224
  rows: 2_000_000_000
201
- )['response']['docs'].map { |obj| obj['id'] }
225
+ )['response']['docs'].map { |obj| obj['id'] })
202
226
  end
203
227
  end
204
228
 
205
229
  def create_new_entries
206
- current_work_ids.each_with_index do |wid, index|
230
+ current_record_ids.each_with_index do |id, index|
207
231
  break if limit_reached?(limit, index)
208
- new_entry = find_or_create_entry(entry_class, wid, 'Bulkrax::Exporter')
232
+
233
+ this_entry_class = if @collection_ids.include?(id)
234
+ collection_entry_class
235
+ elsif @file_set_ids.include?(id)
236
+ file_set_entry_class
237
+ else
238
+ entry_class
239
+ end
240
+ new_entry = find_or_create_entry(this_entry_class, id, 'Bulkrax::Exporter')
241
+
209
242
  begin
210
- entry = Bulkrax::ExportWorkJob.perform_now(new_entry.id, current_run.id)
243
+ entry = ExportWorkJob.perform_now(new_entry.id, current_run.id)
211
244
  rescue => e
212
245
  Rails.logger.info("#{e.message} was detected during export")
213
246
  end
247
+
214
248
  self.headers |= entry.parsed_metadata.keys if entry
215
249
  end
216
250
  end
@@ -267,7 +301,7 @@ module Bulkrax
267
301
 
268
302
  def write_files
269
303
  CSV.open(setup_export_file, "w", headers: export_headers, write_headers: true) do |csv|
270
- importerexporter.entries.where(identifier: current_work_ids)[0..limit || total].each do |e|
304
+ importerexporter.entries.where(identifier: current_record_ids)[0..limit || total].each do |e|
271
305
  csv << e.parsed_metadata
272
306
  end
273
307
  end
@@ -7,6 +7,10 @@
7
7
  </div>
8
8
  <% end %>
9
9
 
10
+ <% content_for(:head) do %>
11
+ <meta name="turbolinks-cache-control" content="no-cache">
12
+ <% end %>
13
+
10
14
  <div class="panel panel-default">
11
15
  <div class="panel-body">
12
16
  <% if @exporters.present? %>
@@ -7,6 +7,10 @@
7
7
  </div>
8
8
  <% end %>
9
9
 
10
+ <% content_for(:head) do %>
11
+ <meta name="turbolinks-cache-control" content="no-cache">
12
+ <% end %>
13
+
10
14
  <div class="panel panel-default">
11
15
  <div class="panel-body">
12
16
  <% if @importers.present? %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bulkrax
4
- VERSION = '2.1.1'
4
+ VERSION = '2.2.3'
5
5
  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: 2.1.1
4
+ version: 2.2.3
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-02-03 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -378,7 +378,7 @@ homepage: https://github.com/samvera-labs/bulkrax
378
378
  licenses:
379
379
  - Apache-2.0
380
380
  metadata: {}
381
- post_install_message:
381
+ post_install_message:
382
382
  rdoc_options: []
383
383
  require_paths:
384
384
  - lib
@@ -393,8 +393,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
393
  - !ruby/object:Gem::Version
394
394
  version: '0'
395
395
  requirements: []
396
- rubygems_version: 3.1.4
397
- signing_key:
396
+ rubygems_version: 3.1.2
397
+ signing_key:
398
398
  specification_version: 4
399
399
  summary: Import and export tool for Hyrax and Hyku
400
400
  test_files: []