ddr-batch 1.2.0 → 1.3.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: 1e82d997fde48ad251350b642c1e512653872545
4
- data.tar.gz: 7e2f779cf6179d8d0aed43c8cb0c2014d763262a
3
+ metadata.gz: 24bb11b78d0e9c073aa229204b6ff596421b5b0b
4
+ data.tar.gz: 7dcf19a37649facfabe5c8c5efe3ca9b390a88dc
5
5
  SHA512:
6
- metadata.gz: 78cd17bb2b5826bb9a13343f2ab35213b102a1ff3024211c21e50d4ed9b11521b0113dbab588bb0fc03f843f10ba00e0a88f373a759e35cdef88657a0bd9d589
7
- data.tar.gz: 2ccc5e4249c45ae0cbdb964c1c617ad092b3a31c33f65e4a996a831028aaed5dd0bf3908b26084eab02552282ac3b9ceffa653dc748e59ea7ba0e6b3647b39d9
6
+ metadata.gz: 74e39bd73bbe80c30d0c835ecdaec3934af45ee88a059bfacf3c99c45c359312d06fb5d69b0404b66499370a050a7afefe3a0e97c534639a4297319ac7caeef4
7
+ data.tar.gz: e93061dce899944061f74ff52a54d72c8df9b91dfe40d64faa966d9f7f7d590f892f76ad745bca6a7f7cb2efd3815ecedede816a555622a187e087a93e7bb20c
@@ -278,11 +278,7 @@ module Ddr::Batch
278
278
  else
279
279
  ds_content = File.new(datastream[:payload])
280
280
  end
281
- file_name = File.basename(datastream[:payload])
282
- dsid = datastream[:name]
283
- opts = { filename: file_name }
284
- opts.merge({ mime_type: mime_type }) if mime_type
285
- repo_object.add_file(ds_content, dsid, opts)
281
+ repo_object.add_file(ds_content, datastream[:name], mime_type: mime_type)
286
282
  end
287
283
  return repo_object
288
284
  end
@@ -4,11 +4,6 @@ module Ddr::Batch
4
4
 
5
5
  belongs_to :batch_object, :inverse_of => :batch_object_datastreams
6
6
 
7
- DATASTREAMS = [ Ddr::Datastreams::CONTENT,
8
- Ddr::Datastreams::DESC_METADATA,
9
- Ddr::Datastreams::RIGHTS_METADATA,
10
- Ddr::Datastreams::STRUCT_METADATA ]
11
-
12
7
  OPERATION_ADD = "ADD" # add this datastream to the object -- considered an error if datastream already exists
13
8
  OPERATION_ADDUPDATE = "ADDUPDATE" # add this datastream to or update this datastream in the object
14
9
  OPERATION_UPDATE = "UPDATE" # update this datastream in the object -- considered an error if datastream does not already exist
@@ -37,6 +37,18 @@ module Ddr::Batch
37
37
  verified = false if value.eql?(VERIFICATION_FAIL)
38
38
  end
39
39
  update_attributes(:verified => verified)
40
+ Ddr::Events::ValidationEvent.new.tap do |event|
41
+ event.object = repo_object
42
+ event.failure! unless verified
43
+ event.summary = EVENT_SUMMARY % {
44
+ label: "Object update validation",
45
+ batch_id: id,
46
+ identifier: identifier,
47
+ model: model
48
+ }
49
+ event.detail = verification_outcome_detail.join("\n")
50
+ event.save!
51
+ end
40
52
  repo_object
41
53
  end
42
54
  end
@@ -78,9 +90,7 @@ module Ddr::Batch
78
90
  populate_datastream(repo_object, d)
79
91
  end
80
92
  end
81
- if repo_object.save
82
- repo_object.notify_event(:update, user: user, comment: event_log_comment)
83
- end
93
+ repo_object.save!(user: user, comment: event_log_comment)
84
94
  rescue Exception => e
85
95
  logger.error("Error in updating repository object #{pid} for #{identifier} : : #{e}")
86
96
  raise e
@@ -6,6 +6,9 @@ module Ddr::Batch
6
6
  event = ActiveSupport::Notifications::Event.new(*args)
7
7
  batch = Ddr::Batch::Batch.find(event.payload[:batch_id])
8
8
  batch_finished(batch)
9
+ if batch.outcome == Ddr::Batch::Batch::OUTCOME_SUCCESS
10
+ ActiveSupport::Notifications.instrument('success.batch.batch.ddr', batch_id: batch.id)
11
+ end
9
12
  end
10
13
 
11
14
  private
@@ -13,7 +16,7 @@ module Ddr::Batch
13
16
  def batch_finished(batch)
14
17
  log_batch_finish(batch)
15
18
  update_batch(batch)
16
- send_notification(batch) if batch.user && batch.user.email
19
+ send_email(batch) if batch.user && batch.user.email
17
20
  end
18
21
 
19
22
  def log_batch_finish(batch)
@@ -68,7 +71,7 @@ module Ddr::Batch
68
71
  logfile: logfile)
69
72
  end
70
73
 
71
- def send_notification(batch)
74
+ def send_email(batch)
72
75
  begin
73
76
  Ddr::Batch::BatchProcessorRunMailer.send_notification(batch).deliver!
74
77
  rescue => e
@@ -49,10 +49,11 @@ module Ddr::Batch
49
49
  end
50
50
 
51
51
  def enqueue_item_component_ingest(batch_object)
52
- batch_object_ids = [ batch_object.id ]
53
- parent_rel_query = "object = '#{batch_object.pid}' AND name = '#{Ddr::Batch::BatchObjectRelationship::RELATIONSHIP_PARENT}'"
54
- parent_rel_recs = Ddr::Batch::BatchObjectRelationship.where(parent_rel_query)
55
- parent_rel_recs.each { |parent_rel_rec| batch_object_ids << parent_rel_rec.batch_object_id}
52
+ query = [ "object = '#{batch_object.pid}'",
53
+ "batch_object_relationships.name = '#{Ddr::Batch::BatchObjectRelationship::RELATIONSHIP_PARENT}'",
54
+ "batches.id = #{batch_object.batch.id}" ].join(' AND ')
55
+ recs = Ddr::Batch::BatchObjectRelationship.joins(batch_object: :batch).where(query)
56
+ batch_object_ids = recs.map { |rec| rec.batch_object.id }.unshift(batch_object.id)
56
57
  Resque.enqueue(BatchObjectsProcessorJob, batch_object_ids, operator_id)
57
58
  end
58
59
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Batch
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.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.2.0
4
+ version: 1.3.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-01-12 00:00:00.000000000 Z
12
+ date: 2017-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 4.1.13
20
+ version: '4.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 4.1.13
27
+ version: '4.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: devise
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +180,6 @@ files:
180
180
  - app/jobs/ddr/batch/batch_processor_job.rb
181
181
  - app/mailers/ddr/batch/batch_processor_run_mailer.rb
182
182
  - app/models/ddr/batch/batch.rb
183
- - app/models/ddr/batch/batch_ability_definitions.rb
184
183
  - app/models/ddr/batch/batch_object.rb
185
184
  - app/models/ddr/batch/batch_object_attribute.rb
186
185
  - app/models/ddr/batch/batch_object_datastream.rb
@@ -232,12 +231,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
231
  version: '0'
233
232
  required_rubygems_version: !ruby/object:Gem::Requirement
234
233
  requirements:
235
- - - ">="
234
+ - - ">"
236
235
  - !ruby/object:Gem::Version
237
- version: '0'
236
+ version: 1.3.1
238
237
  requirements: []
239
238
  rubyforge_project:
240
- rubygems_version: 2.4.3
239
+ rubygems_version: 2.5.1
241
240
  signing_key:
242
241
  specification_version: 4
243
242
  summary: Batch processing for Duke Digital Repository
@@ -1,14 +0,0 @@
1
- module Ddr::Batch
2
- class BatchAbilityDefinitions < Ddr::Auth::AbilityDefinitions
3
-
4
- def call
5
- if authenticated?
6
- can :manage, Batch, user_id: user.id
7
- end
8
- can :manage, Ddr::Batch::BatchObject do |batch_object|
9
- can? :manage, batch_object.batch
10
- end
11
- end
12
-
13
- end
14
- end