uc3-dmp-id 0.0.105 → 0.0.107

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e989d8d3d5932bb292a7116d479b6ccaf57611741d0af54e6e31a9177a0a5fa
4
- data.tar.gz: 10bef83307a97389e8cb512fb83a6558259f569c4e69225c023c77553060fca5
3
+ metadata.gz: 7da70a2b2604989dfafbd5cde63a1b83bebbb3b28d32d1819af2cdc2753e1c11
4
+ data.tar.gz: 9f5f266f053738ecfdae324326ea3ad2df44e7a47dbf2e8ca6c48764caa3d979
5
5
  SHA512:
6
- metadata.gz: 0afbd3c9861c4d26d0b9002c28cea9443522e77300ceb24c80d15812725637508312cbcae33bf355c4386fe9aa51b34ccf4f52275a18e910363e7ff46b77b71b
7
- data.tar.gz: 8c79f4ac8d1ed0f44ee13512d006488b52af89983f5835a70fc80e773f8c92311bd66b286a2abba2a4a963dd3fa1891c2258a03a2574e15ea51bc958c3ae8bbe
6
+ metadata.gz: ef4ecc2584dc4e09730dd605aa979bbc0b9b9819886f3f57d885d8da8e6fea4da8eec60b523610d5c9c52d54ee2178a7100ade55afdad656529d6640ea1c5357
7
+ data.tar.gz: 7412edf48dc0997df0d80251912a9112545f593f7eaf4a30eda41c2c5d8b9fb666073f64eabcc429454b00d1acd8b10d9d1068aff399b648a1023b66d47e69c6
@@ -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.107'
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.107
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley