uc3-dmp-id 0.0.105 → 0.0.106

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: 4e989d8d3d5932bb292a7116d479b6ccaf57611741d0af54e6e31a9177a0a5fa
4
- data.tar.gz: 10bef83307a97389e8cb512fb83a6558259f569c4e69225c023c77553060fca5
3
+ metadata.gz: 23097d67b2f230b8c3a194cc3eed7c31f7f90056b7a8e0fae5c2d72af09a9927
4
+ data.tar.gz: e517ebc36f9ecddc28723d0334626ff348a95e9f91b050fbc938b628e04aae64
5
5
  SHA512:
6
- metadata.gz: 0afbd3c9861c4d26d0b9002c28cea9443522e77300ceb24c80d15812725637508312cbcae33bf355c4386fe9aa51b34ccf4f52275a18e910363e7ff46b77b71b
7
- data.tar.gz: 8c79f4ac8d1ed0f44ee13512d006488b52af89983f5835a70fc80e773f8c92311bd66b286a2abba2a4a963dd3fa1891c2258a03a2574e15ea51bc958c3ae8bbe
6
+ metadata.gz: 619e35ef6240834357d62e57dcab4c70359085fff7d73d31f0505361c836c38749b35fc3b7d27967a7c7415dd49cb6de61df6b8076d714d0d329160badb7f751
7
+ data.tar.gz: 97d30d99e8ff0e258507f6830b10bede00c88538d3b36f3c8a1fd63711d14f0e1a32730a1fb3a196dfe1c4c99555db8eec2a8cc2b18017e617e242cb38bf0881
@@ -49,14 +49,14 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
49
49
  logger.debug(message: "Incoming modifications", details: incoming_assertions) if logger.respond_to?(:debug)
50
50
 
51
51
  # Keep any assetions that were made after the dmphub_updated_at on the incoming changes
52
- latest_version['dmphub_assertions'] = existing_assertions.select do |entry|
52
+ modified_version['dmphub_assertions'] = existing_assertions.select do |entry|
53
53
  !entry['timestamp'].nil? && Time.parse(entry['timestamp']) > Time.parse(modified_version['dmphub_updated_at'])
54
54
  end
55
- return latest_version unless incoming_assertions.any?
55
+ return modified_version unless incoming_assertions.any?
56
56
 
57
57
  # Add any of the assertions still on the incoming record back to the latest record
58
- incoming_assertions.each { |entry| latest_version['dmphub_assertions'] << entry }
59
- latest_version
58
+ incoming_assertions.each { |entry| modified_version['dmphub_assertions'] << entry }
59
+ modified_version
60
60
  end
61
61
 
62
62
  private
@@ -114,10 +114,28 @@ puts version
114
114
  return mods unless version.is_a?(Hash) && !owner.nil?
115
115
 
116
116
  # Splice together any assertions that may have been made while the user was editing the DMP ID
117
- return Asserter.splice(latest_version: version, modified_version: mods, logger: logger) if owner == updater
117
+ updated = Asserter.splice(latest_version: version, modified_version: mods, logger: logger) if owner == updater
118
118
 
119
119
  # Attach the incoming changes as an assertion to the DMP ID since the updater is NOT the owner
120
- Asserter.add(updater: provenance['PK'], dmp: version, mods: mods, note: note, logger: logger)
120
+ updater = provenance['PK']
121
+ updated = Asserter.add(updater: updater, dmp: version, mods: mods, note: note, logger: logger) if owner != updater
122
+
123
+ merge_versions(latest_version: version, mods: updated, logger: logger)
124
+ end
125
+
126
+ # We are replacing the latest version with the modifcations but want to retain the PK, SK and any dmphub_ prefixed
127
+ # entries in the metadata so that we do not lose creation timestamps, provenance ids, etc.
128
+ def merge_versions(latest_version:, mods:, logger: nil)
129
+ logger.debug(message: 'Modifications before merge.', details: mods)
130
+ keys_to_retain = latest_version.keys.select do |key|
131
+ (key.start_with?('dmphub_') && !%w[dmphub_assertions].include?(key)) ||
132
+ key.start_with?('PK') || key.start_with?('SK')
133
+ end
134
+ keys_to_retain.each do |key|
135
+ mods[key] = latest_version[key]
136
+ end
137
+ logger.debug(message: 'Modifications after merge.', details mods)
138
+ mods
121
139
  end
122
140
 
123
141
  # Once the DMP has been updated, we need to update it's DOI metadata
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.105'
4
+ VERSION = '0.0.106'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.105
4
+ version: 0.0.106
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley