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 +4 -4
- data/lib/uc3-dmp-id/asserter.rb +4 -4
- data/lib/uc3-dmp-id/updater.rb +20 -2
- 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: 7da70a2b2604989dfafbd5cde63a1b83bebbb3b28d32d1819af2cdc2753e1c11
|
4
|
+
data.tar.gz: 9f5f266f053738ecfdae324326ea3ad2df44e7a47dbf2e8ca6c48764caa3d979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef4ecc2584dc4e09730dd605aa979bbc0b9b9819886f3f57d885d8da8e6fea4da8eec60b523610d5c9c52d54ee2178a7100ade55afdad656529d6640ea1c5357
|
7
|
+
data.tar.gz: 7412edf48dc0997df0d80251912a9112545f593f7eaf4a30eda41c2c5d8b9fb666073f64eabcc429454b00d1acd8b10d9d1068aff399b648a1023b66d47e69c6
|
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
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/uc3-dmp-id/version.rb
CHANGED