ddr-batch 1.5.1 → 1.6.0.rc1

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
  SHA1:
3
- metadata.gz: 97d177d4e80a1a9e289950be656083ef6cd911fb
4
- data.tar.gz: 6de543210db6c67cf114bd10e6834145f92fc65f
3
+ metadata.gz: b669a1b89bbb629092cf71f8f4618d0a17dae0e0
4
+ data.tar.gz: 46f1292e988fb407dd28ead7a3ab52fa8772ddf3
5
5
  SHA512:
6
- metadata.gz: abc0fcf24f05cf8722124ca3a76e017b34450986b30c7381f2f724379d4f3bc29325357343b7849bd235e101abb768a019803989ad150ee2ed12a1b490fc3452
7
- data.tar.gz: 2c5ab1d54c81d3aff6427107da4a4fa55fcc96fc534701beb3c48ec3a004b2b6caca3b24d356439787f2b611ca52a7a52825b6c330533bfc46d5d95cd71e18d0
6
+ metadata.gz: d68302d269a1a68c359be955cc28654af8d975b0c2562b5d6a3c6dd21da119307ef8666e8137e8db400fb1015a6f6fa8dd9cceffeba6d7f6fd202f474bab8833
7
+ data.tar.gz: bddd38e9a212a44110ebad531b01dec844b7a0d322fccadd02915c1b6f43cb92c64bef47892610776ca404cf9cf67ac99aab74e8c78c3e965ea7820709f6be0f
@@ -5,15 +5,32 @@ module Ddr::Batch
5
5
  def send_notification(batch)
6
6
  @batch = batch
7
7
  @title = "Batch Processor Run #{@batch.status} #{@batch.outcome}"
8
+ @title << " - #{@batch.collection_title}" if @batch.collection_title.present?
8
9
  @host = `uname -n`.strip
9
10
  @subject = "[#{@host}] #{@title}"
10
11
  @size = @batch.batch_objects.size
11
12
  @handled = @batch.handled_count
12
13
  @success = @batch.success_count
13
- attachments["details.txt"] = File.read(@batch.logfile.path)
14
+ attachments[attachment_file_name(@batch)] = File.read(@batch.logfile.path)
14
15
  mail(to: @batch.user.email, subject: @subject)
15
16
  end
16
17
 
18
+ private
19
+
20
+ def attachment_file_name(batch)
21
+ if batch.collection_title.present?
22
+ sanitized_title = sanitize_title_for_filename(batch.collection_title)
23
+ "details_#{sanitized_title}.txt"
24
+ else
25
+ "details.txt"
26
+ end
27
+ end
28
+
29
+ def sanitize_title_for_filename(title)
30
+ title
31
+ .gsub(/[^\w\s_-]+/, '')
32
+ .gsub(/\s+/, '_')
33
+ end
17
34
  end
18
35
 
19
36
  end
@@ -63,6 +63,12 @@ module Ddr::Batch
63
63
  status == STATUS_FINISHED
64
64
  end
65
65
 
66
+ def deletable?
67
+ [ nil,
68
+ Ddr::Batch::Batch::STATUS_READY,
69
+ Ddr::Batch::Batch::STATUS_VALIDATED,
70
+ Ddr::Batch::Batch::STATUS_INVALID ].include?(status)
71
+ end
66
72
  end
67
73
 
68
74
  end
@@ -47,7 +47,7 @@ module Ddr::Batch
47
47
  end
48
48
 
49
49
  def ingest(user, opts = {})
50
- repo_object = create_repository_object
50
+ repo_object = create_repository_object(user)
51
51
  if !repo_object.nil? && !repo_object.new_record?
52
52
  ingest_outcome_detail = []
53
53
  ingest_outcome_detail << "Ingested #{model} #{identifier} into #{repo_object.pid}"
@@ -90,14 +90,14 @@ module Ddr::Batch
90
90
  repo_object
91
91
  end
92
92
 
93
- def create_repository_object
93
+ def create_repository_object(user)
94
94
  repo_pid = pid if pid.present?
95
95
  repo_object = nil
96
96
  begin
97
97
  repo_object = model.constantize.new(:pid => repo_pid)
98
98
  repo_object.label = label if label
99
99
  batch_object_attributes.each { |a| repo_object = add_attribute(repo_object, a) }
100
- repo_object.save(validate: false, skip_structure_updates: true)
100
+ repo_object.save(validate: false, skip_structure_updates: true, user: user)
101
101
  batch_object_datastreams.each { |d| repo_object = populate_datastream(repo_object, d) }
102
102
  batch_object_relationships.each { |r| repo_object = add_relationship(repo_object, r) }
103
103
  batch_object_roles.each { |r| repo_object = add_role(repo_object, r) }
@@ -40,7 +40,8 @@ module Ddr::Batch
40
40
  end
41
41
 
42
42
  def track_result(results_tracker, batch_object)
43
- type, model = [ batch_object.type, batch_object.model ]
43
+ type = batch_object.type
44
+ model = batch_object.model || "Missing Model"
44
45
  results_tracker[type] = Hash.new unless results_tracker.has_key?(type)
45
46
  results_tracker[type][model] = Hash.new unless results_tracker[type].has_key?(model)
46
47
  results_tracker[type][model][:successes] = 0 unless results_tracker[type][model].has_key?(:successes)
@@ -84,6 +85,3 @@ module Ddr::Batch
84
85
 
85
86
  end
86
87
  end
87
-
88
-
89
-
@@ -25,6 +25,7 @@ module Ddr::Batch
25
25
 
26
26
  def log_batch_start(batch)
27
27
  logger = Ddr::Batch::Log.logger(batch.id)
28
+ logger.info "Collection: #{batch.collection_title}" if batch.collection_title.present?
28
29
  logger.info "Batch id: #{batch.id}"
29
30
  logger.info "Batch name: #{batch.name}" if name
30
31
  logger.info "Batch size: #{batch.batch_objects.size}"
@@ -0,0 +1,8 @@
1
+ class AddCollectionColumnsToBatch < ActiveRecord::Migration
2
+ def change
3
+ change_table :batches do |t|
4
+ t.string "collection_id", null: true
5
+ t.string "collection_title", null: true
6
+ end
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Batch
3
- VERSION = "1.5.1"
3
+ VERSION = "1.6.0.rc1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-batch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-31 00:00:00.000000000 Z
12
+ date: 2017-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -230,6 +230,7 @@ files:
230
230
  - db/migrate/20161115191636_add_columns_to_batch_object.rb
231
231
  - db/migrate/20161116142512_create_batch_object_messages.rb
232
232
  - db/migrate/20161222192611_remove_columns_from_batch.rb
233
+ - db/migrate/20171116183514_add_collection_columns_to_batch.rb
233
234
  - lib/ddr-batch.rb
234
235
  - lib/ddr/batch.rb
235
236
  - lib/ddr/batch/batch_user.rb
@@ -251,9 +252,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
251
252
  version: '0'
252
253
  required_rubygems_version: !ruby/object:Gem::Requirement
253
254
  requirements:
254
- - - ">="
255
+ - - ">"
255
256
  - !ruby/object:Gem::Version
256
- version: '0'
257
+ version: 1.3.1
257
258
  requirements: []
258
259
  rubyforge_project:
259
260
  rubygems_version: 2.6.11