uc3-dmp-id 0.1.75 → 0.1.77
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/updater.rb +20 -44
- 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: dcc7bf54d3beeb3610d64490a6037022fbef6569ae0ee67188eeafea34a67ae7
|
4
|
+
data.tar.gz: 722e4bd441ed71e9265d6bde56663cccc6b4ccbf49178ac24d1b46072aa97295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 293ab0fd326ff54633662b53aae5a82a24b456593134196c0f15e167a3acaf57706ee2c432e4ba3bb1ef382f80540f3df9cc7074312606d58c6ec3d1a9c54da9
|
7
|
+
data.tar.gz: a0f9ee659c34501642287dfc4cbbd77b4e184d09272cac143df8d2fd60fab51a05ab5c24d50647c5650b9b8dcd55162b4c4394e65f54748e6ff0ca2e0f4a429a
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -45,35 +45,32 @@ module Uc3DmpId
|
|
45
45
|
raise UpdaterError, Helper::MSG_DMP_FORBIDDEN if owner != updater
|
46
46
|
|
47
47
|
# Handle any changes to the dmphub_modifications section
|
48
|
-
|
49
|
-
logger&.debug(message: '
|
48
|
+
version = _process_harvester_mods(client:, p_key:, json: payload, version:, logger:)
|
49
|
+
logger&.debug(message: 'Version after process_harvester_mods', details: version)
|
50
50
|
|
51
|
-
# Remove the version info
|
52
|
-
|
53
|
-
|
54
|
-
# Splice the assertions
|
55
|
-
payload = _process_modifications(owner:, updater:, version:, mods: payload, logger:)
|
56
|
-
logger&.debug(message: 'Mods after process_modifications', details: payload)
|
51
|
+
# Remove the version info any any lingering modification blocks
|
52
|
+
version.delete('dmphub_versions')
|
53
|
+
version.delete('dmphub_modifications')
|
57
54
|
|
58
55
|
# Set the :modified timestamps
|
59
56
|
now = Time.now.utc
|
60
|
-
|
61
|
-
|
57
|
+
version['modified'] = now.iso8601
|
58
|
+
version['dmphub_modification_day'] = now.strftime('%Y-%m-%d')
|
62
59
|
|
63
60
|
# Save the changes
|
64
|
-
resp = client.put_item(json:
|
61
|
+
resp = client.put_item(json: version, logger:)
|
65
62
|
raise UpdaterError, Helper::MSG_DMP_UNABLE_TO_VERSION if resp.nil?
|
66
63
|
|
67
64
|
# Send the updates to EZID
|
68
|
-
_post_process(provenance:, json:
|
65
|
+
_post_process(provenance:, json: version, logger:)
|
69
66
|
|
70
67
|
# Return the new version record
|
71
68
|
logger.info(message: "Updated DMP ID: #{p_key}") if logger.respond_to?(:debug)
|
72
69
|
|
73
70
|
# Append the :dmphub_versions Array
|
74
|
-
|
75
|
-
|
76
|
-
Helper.cleanse_dmp_json(json:)
|
71
|
+
out = JSON.parse({ dmp: version }.to_json)
|
72
|
+
out = Versioner.append_versions(p_key:, dmp: out, client:, logger:)
|
73
|
+
Helper.cleanse_dmp_json(json: out)
|
77
74
|
end
|
78
75
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
79
76
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -134,25 +131,6 @@ module Uc3DmpId
|
|
134
131
|
end
|
135
132
|
# rubocop:enable Metrics/AbcSize
|
136
133
|
|
137
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
138
|
-
def _process_modifications(owner:, updater:, version:, mods:, logger: nil)
|
139
|
-
return version unless mods.is_a?(Hash) && !updater.nil?
|
140
|
-
return mods unless version.is_a?(Hash) && !owner.nil?
|
141
|
-
|
142
|
-
logger.debug(message: 'Modifications before merge.', details: mods) if logger.respond_to?(:debug)
|
143
|
-
keys_to_retain = version.keys.select do |key|
|
144
|
-
key.start_with?('dmphub_') &&
|
145
|
-
!%w[dmphub_modifications dmphub_versions].include?(key)
|
146
|
-
end
|
147
|
-
keys_to_retain.each { |key| mods[key] = version[key] }
|
148
|
-
|
149
|
-
mods['PK'] = version['PK']
|
150
|
-
mods['SK'] = Helper::DMP_LATEST_VERSION
|
151
|
-
logger.debug(message: 'Modifications after merge.', details: mods) if logger.respond_to?(:debug)
|
152
|
-
mods
|
153
|
-
end
|
154
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
155
|
-
|
156
134
|
# Once the DMP has been updated, we need to update it's DOI metadata
|
157
135
|
# -------------------------------------------------------------------------
|
158
136
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
@@ -196,7 +174,7 @@ module Uc3DmpId
|
|
196
174
|
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
197
175
|
|
198
176
|
# Fetch any Harvester modifications to the JSON
|
199
|
-
def _process_harvester_mods(client:, p_key:, json:, logger: nil)
|
177
|
+
def _process_harvester_mods(client:, p_key:, json:, version:, logger: nil)
|
200
178
|
logger&.debug(message: 'Incoming modifications', details: json)
|
201
179
|
return json if json.fetch('dmphub_modifications', []).empty?
|
202
180
|
|
@@ -229,31 +207,29 @@ module Uc3DmpId
|
|
229
207
|
logger&.debug(message: "Updating status for #{key} from #{original['related_works'][key]['status']} to #{related['status']}")
|
230
208
|
original['related_works'][key]['status'] = related['status']
|
231
209
|
|
232
|
-
existing =
|
210
|
+
existing = version['dmproadmap_related_identifiers'].select do |ri|
|
233
211
|
ri['identifier'] == key
|
234
212
|
end
|
235
213
|
|
236
214
|
# Add it if it was approved and doesn't exist in dmproadmap_related_identifiers
|
237
215
|
if related['status'] == 'approved' && existing.empty?
|
238
|
-
|
216
|
+
version['dmproadmap_related_identifiers'] << {
|
239
217
|
identifier: key,
|
240
218
|
work_type: related['work_type'],
|
241
219
|
type: related['type'],
|
242
220
|
descriptor: related['descriptor'],
|
243
221
|
citation: related['citation']
|
244
|
-
}
|
245
|
-
elsif related['status']
|
222
|
+
}
|
223
|
+
elsif related['status'] == 'rejected' && existing.any?
|
246
224
|
# otherwise remove it
|
247
|
-
|
225
|
+
version['dmproadmap_related_identifiers'] = version['dmproadmap_related_identifiers'].reject { |ri| ri == existing.first }
|
248
226
|
end
|
249
227
|
end
|
250
228
|
end
|
251
229
|
|
252
230
|
logger&.debug(message: 'Updating HARVESTER_MODS with:', details: original)
|
253
|
-
|
254
|
-
|
255
|
-
logger&.debug(message: 'After deleting dmphub_modifications:', details: json)
|
256
|
-
json
|
231
|
+
logger&.debug(message: 'Returning updated VERSION:', details: version)
|
232
|
+
version
|
257
233
|
end
|
258
234
|
end
|
259
235
|
end
|
data/lib/uc3-dmp-id/version.rb
CHANGED