uc3-dmp-id 0.0.104 → 0.0.106
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-id/asserter.rb +4 -4
- data/lib/uc3-dmp-id/updater.rb +24 -10
- data/lib/uc3-dmp-id/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23097d67b2f230b8c3a194cc3eed7c31f7f90056b7a8e0fae5c2d72af09a9927
|
4
|
+
data.tar.gz: e517ebc36f9ecddc28723d0334626ff348a95e9f91b050fbc938b628e04aae64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619e35ef6240834357d62e57dcab4c70359085fff7d73d31f0505361c836c38749b35fc3b7d27967a7c7415dd49cb6de61df6b8076d714d0d329160badb7f751
|
7
|
+
data.tar.gz: 97d30d99e8ff0e258507f6830b10bede00c88538d3b36f3c8a1fd63711d14f0e1a32730a1fb3a196dfe1c4c99555db8eec2a8cc2b18017e617e242cb38bf0881
|
data/lib/uc3-dmp-id/asserter.rb
CHANGED
@@ -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
|
-
|
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
|
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|
|
59
|
-
|
58
|
+
incoming_assertions.each { |entry| modified_version['dmphub_assertions'] << entry }
|
59
|
+
modified_version
|
60
60
|
end
|
61
61
|
|
62
62
|
private
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -49,6 +49,9 @@ puts version
|
|
49
49
|
version = _process_modifications(owner: owner, updater: updater, version: version, mods: mods, note: note,
|
50
50
|
logger: logger)
|
51
51
|
|
52
|
+
puts "AFTER PROCESING MODS:"
|
53
|
+
puts version
|
54
|
+
|
52
55
|
# Save the changes
|
53
56
|
resp = client.put_item(json: version, logger: logger)
|
54
57
|
raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
|
@@ -107,21 +110,32 @@ puts version
|
|
107
110
|
end
|
108
111
|
|
109
112
|
def _process_modifications(owner:, updater:, version:, mods:, note: nil, logger: nil)
|
110
|
-
|
111
|
-
puts "OWNER: #{owner}, UPDATER #{updater}, Version is Hash? #{version.is_a?(Hash)}, Mods is Hash? #{mods.is_a?(Hash)}"
|
112
|
-
|
113
|
-
puts "Returning version? #{!mods.is_a?(Hash) || updater.nil?}"
|
114
|
-
puts "Returning mods? #{!version.is_a?(Hash) || owner.nil?}"
|
115
|
-
|
116
113
|
return version unless mods.is_a?(Hash) && !updater.nil?
|
117
114
|
return mods unless version.is_a?(Hash) && !owner.nil?
|
118
115
|
|
119
|
-
puts "Asserting!"
|
120
|
-
|
121
116
|
# Splice together any assertions that may have been made while the user was editing the DMP ID
|
122
|
-
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
|
+
|
123
119
|
# Attach the incoming changes as an assertion to the DMP ID since the updater is NOT the owner
|
124
|
-
|
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
|
125
139
|
end
|
126
140
|
|
127
141
|
# Once the DMP has been updated, we need to update it's DOI metadata
|
data/lib/uc3-dmp-id/version.rb
CHANGED