uc3-dmp-id 0.1.71 → 0.1.72

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: 06d836115caac7a07306686448df2e596b9d77f54368e4fb5f1e1f921e8c7ad6
4
- data.tar.gz: afd13d10029262be80f08cc86516292567162bbd87679fe467b0dd23c1b5d72a
3
+ metadata.gz: b90c20a70e3d549ed563b01ac4548f727ff36333e017841fbcc33dd1687e1f9e
4
+ data.tar.gz: a86589814101e440390ec0c637b2a79ba8f6ee1e454cc2eeb8b51801bdbe4e5d
5
5
  SHA512:
6
- metadata.gz: aef2a4c77b3ee99d13f4aac02f544b978e5f7c84495e7fedcf0588f0ffa8efe495be8dc05e984487873620b292da3f9f1bf3e33a6119bbdce26c845df3161ac0
7
- data.tar.gz: 87b47716904176310c6add2c3c7d376077ec462edfa6063b1f7f295b557c78ad4852e6bb3174a68c053b088ee1f8eefe2d43ea80f8d62ee10521fb0c83086a9c
6
+ metadata.gz: 422bd12145eca2376172a80f8c6c66376ce4c792760d5ba4c99fabab266a7f9463831a89c0743edc76c84576c6cc0330db7c8721c765711b80f05339f4a202ba
7
+ data.tar.gz: 6f98e2324a6cd7023960dbe641da9d263baed02503645f1e32933feef751117a4de84c13c20056b9fac0d24d79c12e24ea6f1fbfa507db66b22312c3583f7ed8
@@ -16,9 +16,9 @@ module Uc3DmpId
16
16
  def update(provenance:, p_key:, json: {}, logger: nil)
17
17
  raise UpdaterError, Helper::MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
18
18
 
19
- mods = Helper.parse_json(json:).fetch('dmp', {})
19
+ payload = Helper.parse_json(json:).fetch('dmp', {})
20
20
  p_key = Helper.append_pk_prefix(p_key:)
21
- logger.debug(message: "Incoming modifications for PK #{p_key}", details: mods) if logger.respond_to?(:debug)
21
+ logger.debug(message: "Incoming modifications for PK #{p_key}", details: payload) if logger.respond_to?(:debug)
22
22
 
23
23
  # Fetch the latest version of the DMP ID
24
24
  client = Uc3DmpDynamo::Client.new
@@ -28,48 +28,50 @@ module Uc3DmpId
28
28
 
29
29
  # Verify that the DMP ID is updateable with the info passed in
30
30
  errs = _updateable?(provenance:, p_key:, latest_version: latest_version['dmp'],
31
- mods: mods['dmp'])
31
+ mods: payload['dmp'])
32
32
  logger.error(message: errs.join(', ')) if logger.respond_to?(:error) && errs.is_a?(Array) && errs.any?
33
33
  raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
34
34
  # Don't continue if nothing has changed!
35
- raise UpdaterError, Helper::MSG_NO_CHANGE if Helper.eql?(dmp_a: latest_version, dmp_b: mods)
35
+ raise UpdaterError, Helper::MSG_NO_CHANGE if Helper.eql?(dmp_a: latest_version, dmp_b: payload)
36
36
 
37
37
  # Version the DMP ID record (if applicable).
38
38
  owner = latest_version['dmphub_provenance_id']
39
39
  updater = provenance['PK']
40
40
  version = Versioner.generate_version(client:, latest_version:, owner:,
41
41
  updater:, logger:)
42
+ logger&.debug(message: 'New Version', details: version)
42
43
  raise UpdaterError, Helper::MSG_DMP_UNABLE_TO_VERSION if version.nil?
43
44
  # Bail if the system trying to make the update is not the creator of the DMP ID
44
45
  raise UpdaterError, Helper::MSG_DMP_FORBIDDEN if owner != updater
45
46
 
46
47
  # Handle any changes to the dmphub_modifications section
47
- version = _process_harvester_mods(client:, p_key:, json: mods, logger:)
48
+ payload = _process_harvester_mods(client:, p_key:, json: payload, logger:)
49
+ logger&.debug(message: 'Mods after process_harvester_mods', details: payload)
48
50
 
49
51
  # Remove the version info because we don't want to save it on the record
50
- version.delete('dmphub_versions')
52
+ payload.delete('dmphub_versions')
51
53
 
52
54
  # Splice the assertions
53
- version = _process_modifications(owner:, updater:, version:, mods:, logger:)
54
- logger&.debug(message: 'Mods after process_modifications', details: version)
55
+ payload = _process_modifications(owner:, updater:, version:, mods: payload, logger:)
56
+ logger&.debug(message: 'Mods after process_modifications', details: payload)
55
57
 
56
58
  # Set the :modified timestamps
57
59
  now = Time.now.utc
58
- version['modified'] = now.iso8601
59
- version['dmphub_modification_day'] = now.strftime('%Y-%m-%d')
60
+ payload['modified'] = now.iso8601
61
+ payload['dmphub_modification_day'] = now.strftime('%Y-%m-%d')
60
62
 
61
63
  # Save the changes
62
- resp = client.put_item(json: version, logger:)
64
+ resp = client.put_item(json: payload, logger:)
63
65
  raise UpdaterError, Helper::MSG_DMP_UNABLE_TO_VERSION if resp.nil?
64
66
 
65
67
  # Send the updates to EZID
66
- _post_process(provenance:, json: version, logger:)
68
+ _post_process(provenance:, json: payload, logger:)
67
69
 
68
70
  # Return the new version record
69
71
  logger.info(message: "Updated DMP ID: #{p_key}") if logger.respond_to?(:debug)
70
72
 
71
73
  # Append the :dmphub_versions Array
72
- json = JSON.parse({ dmp: version }.to_json)
74
+ json = JSON.parse({ dmp: payload }.to_json)
73
75
  json = Versioner.append_versions(p_key:, dmp: json, client:, logger:)
74
76
  Helper.cleanse_dmp_json(json:)
75
77
  end
@@ -140,11 +142,12 @@ module Uc3DmpId
140
142
  logger.debug(message: 'Modifications before merge.', details: mods) if logger.respond_to?(:debug)
141
143
  keys_to_retain = version.keys.select do |key|
142
144
  (key.start_with?('dmphub_') && !%w[dmphub_modifications dmphub_versions].include?(key)) ||
143
- key.start_with?('PK') || key.start_with?('SK') || key.start_with?('dmproadmap_related_identifiers')
145
+ key.start_with?('PK') || key.start_with?('dmproadmap_related_identifiers')
144
146
  end
145
147
  keys_to_retain.each do |key|
146
148
  mods[key] = version[key]
147
149
  end
150
+ mods['SK'] = Helper::DMP_LATEST_VERSION
148
151
  logger.debug(message: 'Modifications after merge.', details: mods) if logger.respond_to?(:debug)
149
152
  mods
150
153
  end
@@ -213,7 +216,7 @@ module Uc3DmpId
213
216
 
214
217
  entry['dmproadmap_related_identifiers'].each do |related|
215
218
  related_id = related.respond_to?(:identifier) ? related.identifier : related['identifier']
216
- related_domain = related.respond_to?(:identifier) ? related.domain : related['domain']
219
+ related_domain = related.respond_to?(:domain) ? related.domain : related['domain']
217
220
  key = "#{related_domain.end_with?('/') ? related_domain : "#{related_domain}/"}#{related_id}"
218
221
  key_found = original['related_works'].has_key?(key)
219
222
  logger&.debug(message: "No matching HARVEST_MOD found for #{key}") unless key_found
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.71'
4
+ VERSION = '0.1.72'
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.1.71
4
+ version: 0.1.72
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley