uc3-dmp-id 0.0.60 → 0.0.61
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/helper.rb +6 -0
- data/lib/uc3-dmp-id/updater.rb +14 -8
- 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: f57c20b88aa66fde624307bb92a176682f83058929d36c54f5bc8f3930a98b2d
|
4
|
+
data.tar.gz: 2dc28c07fc2fc766904b3360b043cd6c3b3af7a772765f5681e9dd29040d0a39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9896f63e4d891d16bd97d5293516bf3dc4694ae9dcb8490431433d1061e03dca23c5f99a5d0b6959e7316e6eec19cd5c16aaa7ec93d3fd156b6d877097aec8c9
|
7
|
+
data.tar.gz: fe9a16d6cf9cfad66eb1547137fa5a43583b59c3198476809249a311a01ee91a3086802108a9196dfeb0a95f48620e992505f03d4fe178b434059cf7722b2809
|
data/lib/uc3-dmp-id/helper.rb
CHANGED
@@ -136,10 +136,16 @@ module Uc3DmpId
|
|
136
136
|
# Add DMPHub specific fields to the DMP ID JSON
|
137
137
|
def annotate_dmp_json(provenance:, owner_org:, p_key:, json:)
|
138
138
|
json = parse_json(json: json)
|
139
|
+
|
140
|
+
puts "annotate - prov: #{provenance['PK']}, owner_org: #{owner_org}, p_key: #{p_key}, Hash? #{json.is_a?(Hash)} ::: #{provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)}"
|
141
|
+
|
139
142
|
return json if provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)
|
140
143
|
|
141
144
|
# Fail the json as is if the :PK does not match the :dmp_id if the json has a :PK
|
142
145
|
id = dmp_id_to_pk(json: json.fetch('dmp_id', {}))
|
146
|
+
|
147
|
+
puts "annotate - id: #{id}, PK exist? #{json['PK']} ::: #{id != p_key && !json['PK'].nil?}"
|
148
|
+
|
143
149
|
return json if id != p_key && !json['PK'].nil?
|
144
150
|
|
145
151
|
annotated = deep_copy_dmp(obj: json)
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -46,23 +46,29 @@ module Uc3DmpId
|
|
46
46
|
# fetch the existing latest version of the DMP ID
|
47
47
|
client = Uc3DmpDynamo::Client.new(debug: debug)
|
48
48
|
dmp = Finder.by_pk(p_key: p_key, client: client, debug: debug)
|
49
|
-
|
50
|
-
|
49
|
+
owner_org = dmp['dmp'].fetch('contact', {}).fetch('dmproadmap_affiliation', {}) unless dmp.nil?
|
50
|
+
owner_org = owner_org.fetch('affiliation_id', {})['identifier'] unless owner_org.nil?
|
51
|
+
|
52
|
+
puts "OWNER ORG: #{owner_org}"
|
53
|
+
|
54
|
+
# Don't continue if DMP ID could not be found or the contact has no identifier (should be impossible)
|
55
|
+
raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil? || owner_org.nil?
|
51
56
|
|
52
57
|
errs = _updateable?(provenance: provenance, p_key: p_key, json: dmp['dmp'])
|
53
58
|
raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
|
54
59
|
|
55
|
-
# Add the DMPHub specific attributes
|
56
|
-
|
57
|
-
|
60
|
+
# Add the DMPHub specific attributes and then add the download URl for the PDF
|
61
|
+
annotated = Helper.annotate_dmp_json(provenance: provenance, owner_org: owner_org, p_key: p_key, json: dmp['dmp'])
|
62
|
+
annotated['dmproadmap_related_identifiers'] = [] if annotated['dmproadmap_related_identifiers'].nil?
|
63
|
+
annotated['dmproadmap_related_identifiers'] << {
|
58
64
|
descriptor: 'is_metadata_for', work_type: 'output_management_plan', type: 'url', identifier: url
|
59
65
|
}
|
60
66
|
|
61
67
|
puts "Attached:"
|
62
|
-
puts
|
68
|
+
puts annotated
|
63
69
|
|
64
|
-
# Save the changes
|
65
|
-
resp = client.put_item(json:
|
70
|
+
# Save the changes without creating a new version!
|
71
|
+
resp = client.put_item(json: annotated, debug: debug)
|
66
72
|
raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
|
67
73
|
|
68
74
|
true
|
data/lib/uc3-dmp-id/version.rb
CHANGED