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 +4 -4
- data/lib/uc3-dmp-id/creator.rb +1 -7
- data/lib/uc3-dmp-id/updater.rb +29 -5
- 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: 3259fcdd4e0878c48793799628f8b99386301581352b694469b311cf72d1e553
|
4
|
+
data.tar.gz: d43a114272138af758e54fbb113398fef23d4fe6b2fff8a28b89fc7cd973a367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f539afeb4ddc714a737649b68bfa55e7b2c5b7c49afcb64c7d42a7c1281d59b68523ba7f1188da94026c4cd4b69a75df63f1ef86dc4e7c11523cf48e5e77e9ae
|
7
|
+
data.tar.gz: ec959594a81a6b63ccb2f08676c5cd7bfda4de7baefad0acc80020a2f13d4a5198d3f72b8244d608aaa65d88eed52246c369c1337f21fe3e6a4a0bc4a587f065
|
data/lib/uc3-dmp-id/creator.rb
CHANGED
@@ -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' &&
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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
|
data/lib/uc3-dmp-id/version.rb
CHANGED