uc3-dmp-id 0.0.50 → 0.0.52

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: be8e880666031df3010f048c10afe83dbd614d7a5e51015f53fc67964a1519f5
4
- data.tar.gz: d765faf0c263d97c09ee30a0b64aa176e9968fbe1b4eb065b273d3a1aacfc6f5
3
+ metadata.gz: 3259fcdd4e0878c48793799628f8b99386301581352b694469b311cf72d1e553
4
+ data.tar.gz: d43a114272138af758e54fbb113398fef23d4fe6b2fff8a28b89fc7cd973a367
5
5
  SHA512:
6
- metadata.gz: 422f3912f9fa3eda4fa33a989e898378f3afb6080c8191c7ae43de6edea116b6f3aed0859b1825eddf09582416b5c5f69b51175a330846d3fed8fddcb197a380
7
- data.tar.gz: a819663b7e7bbe5be506a71b83d94a337dd3699c5f3cde9378f6b5bf2323dda56cca4e9b170c0d81d36e840d4939d556fd064a8329d1e820f62a743e47397176
6
+ metadata.gz: f539afeb4ddc714a737649b68bfa55e7b2c5b7c49afcb64c7d42a7c1281d59b68523ba7f1188da94026c4cd4b69a75df63f1ef86dc4e7c11523cf48e5e77e9ae
7
+ data.tar.gz: ec959594a81a6b63ccb2f08676c5cd7bfda4de7baefad0acc80020a2f13d4a5198d3f72b8244d608aaa65d88eed52246c369c1337f21fe3e6a4a0bc4a587f065
@@ -54,15 +54,9 @@ module Uc3DmpId
54
54
 
55
55
  def _preregister_dmp_id(client:, provenance:, json:, debug: false)
56
56
  # Use the specified DMP ID if the provenance has permission
57
- existing = json.fetch('dmp_id', {})
57
+ existing = json.fetch('dmp', {}).fetch('dmp_id', {})
58
58
  id = existing['identifier'].gsub(%r{https?://}, Helper::PK_DMP_PREFIX) if existing.is_a?(Hash) &&
59
59
  !existing['identifier'].nil?
60
-
61
- puts "_preregister_dmp_id:"
62
- puts provenance
63
- puts json
64
- puts id
65
-
66
60
  return id if !id.nil? &&
67
61
  existing.fetch('type', 'other').to_s.downcase == 'doi' &&
68
62
  provenance.fetch('seedingWithLiveDmpIds', false).to_s.downcase == 'true' &&
@@ -10,11 +10,11 @@ module Uc3DmpId
10
10
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
11
11
  # -------------------------------------------------------------------------
12
12
  def update(provenance:, p_key:, json: {})
13
- raise DeleterError, MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
13
+ raise UpdaterError, MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
14
14
 
15
15
  dmp = Helper.parse_json(json: json)
16
16
  errs = _updateable?(provenance: provenance, p_key: p_key, dmp: dmp)
17
- raise DeleterError, errs if errs.is_a?(Array) && errs.any?
17
+ raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
18
18
 
19
19
  # Add the DMPHub specific attributes
20
20
  annotated = Helper.annotate_dmp(provenance: provenance, json: dmp['dmp'], p_key: p_key)
@@ -23,15 +23,15 @@ module Uc3DmpId
23
23
  client = Uc3DmpDynamo::Client.new(debug: debug)
24
24
  existing = Finder.by_pk(p_key: p_key, client: client, debug: debug)
25
25
  # Don't continue if nothing has changed!
26
- raise DeleterError, MSG_NO_CHANGE if Helper.eql?(dmp_a: existing, dmp_b: annotated)
26
+ raise UpdaterError, MSG_NO_CHANGE if Helper.eql?(dmp_a: existing, dmp_b: annotated)
27
27
 
28
28
  # Generate a new version of the DMP. This involves versioning the current latest version
29
29
  new_version = versioner.new_version(p_key: p_key, dmp: json)
30
- raise DeleterError, MSG_DMP_UNABLE_TO_VERSION if new_version.nil?
30
+ raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if new_version.nil?
31
31
 
32
32
  # Save the changes as the new latest version
33
33
  resp = client.put_item(json: new_version, debug: debug)
34
- raise DeleterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
34
+ raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
35
35
 
36
36
  # Send the updates to EZID, notify the provenance and download the PDF if applicable
37
37
  _post_process(json: dmp, debug: debug)
@@ -40,6 +40,30 @@ module Uc3DmpId
40
40
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
41
41
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
42
42
 
43
+ def attach_narrative(provenance:, p_key:, url:, debug: false)
44
+ raise UpdaterError, MSG_DMP_INVALID_DMP_ID unless p_key.is_a?(String) && !p_key.strip.empty?
45
+
46
+ # fetch the existing latest version of the DMP ID
47
+ client = Uc3DmpDynamo::Client.new(debug: debug)
48
+ dmp = Finder.by_pk(p_key: p_key, client: client, debug: debug)
49
+ # Don't continue if nothing has changed!
50
+ raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil?
51
+
52
+ errs = _updateable?(provenance: provenance, p_key: p_key, dmp: dmp)
53
+ raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
54
+
55
+ # Add the DMPHub specific attributes
56
+ annotated = Helper.annotate_dmp(provenance: provenance, json: dmp['dmp'], p_key: p_key)
57
+ annotated['dmproadmap_related_identifiers'] = [] if annotated['dmproadmap_related_identifiers'].nil?
58
+ annotated << { descriptor: 'is_metadata_for', work_type: 'output_management_plan', type: 'url', identifier: url }
59
+
60
+ # Save the changes as the new latest version
61
+ resp = client.put_item(json: annotated, debug: debug)
62
+ raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
63
+
64
+ true
65
+ end
66
+
43
67
  private
44
68
 
45
69
  # Check if the DMP ID is updateable by the provenance
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.50'
4
+ VERSION = '0.0.52'
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.50
4
+ version: 0.0.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley