uc3-dmp-id 0.0.61 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-id/helper.rb +9 -7
- data/lib/uc3-dmp-id/updater.rb +1 -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: 8d86231b0d9bbba113c84fca3f8496f7a1d09eb07386b13f3a8082d1b79d9cd5
|
|
4
|
+
data.tar.gz: 4c5bdfeda6ad713e7a77e6bb6cc27f5942dc170fe477920a40f42da43ff00f40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55a11fcf0cae95da912fde23d91b10a4cb0b0aed0fe607bab4a6db267e59030faa1c7d53b40bb9780888646bf530c296c9d9532a5b2ed77ab892af4606579ba2
|
|
7
|
+
data.tar.gz: b305efdd75d24efc03ed9a792b7c8b04c3c530618071440c651a65f46f1a60b68d73e01185acbb65f928f4d34dfe35d733ee8ee39ef5af3afc41a23c7ca55b65
|
data/lib/uc3-dmp-id/helper.rb
CHANGED
|
@@ -133,23 +133,25 @@ module Uc3DmpId
|
|
|
133
133
|
a == b
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
+
# Extract the Contact's affiliaiton ROR ID
|
|
137
|
+
def extract_owner_org(json: {})
|
|
138
|
+
return nil unless json.is_a?(Hash)
|
|
139
|
+
|
|
140
|
+
dmp = json['dmp'].nil? ? json : json['dmp']
|
|
141
|
+
owner_org = dmp.fetch('contact', {}).fetch('dmproadmap_affiliation', {}).fetch('affiliation_id', {})['identifier']
|
|
142
|
+
end
|
|
143
|
+
|
|
136
144
|
# Add DMPHub specific fields to the DMP ID JSON
|
|
137
145
|
def annotate_dmp_json(provenance:, owner_org:, p_key:, json:)
|
|
138
146
|
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
|
-
|
|
142
147
|
return json if provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)
|
|
143
148
|
|
|
144
149
|
# Fail the json as is if the :PK does not match the :dmp_id if the json has a :PK
|
|
145
150
|
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
|
-
|
|
149
151
|
return json if id != p_key && !json['PK'].nil?
|
|
150
152
|
|
|
151
153
|
annotated = deep_copy_dmp(obj: json)
|
|
152
|
-
annotated['PK'] = json['PK'] || p_key
|
|
154
|
+
annotated['PK'] = json['PK'] || append_pk_prefix(p_key: p_key)
|
|
153
155
|
annotated['SK'] = DMP_LATEST_VERSION
|
|
154
156
|
|
|
155
157
|
# Ensure that the :dmp_id matches the :PK
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
|
@@ -46,11 +46,7 @@ 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
|
-
owner_org =
|
|
50
|
-
owner_org = owner_org.fetch('affiliation_id', {})['identifier'] unless owner_org.nil?
|
|
51
|
-
|
|
52
|
-
puts "OWNER ORG: #{owner_org}"
|
|
53
|
-
|
|
49
|
+
owner_org = Helper.extract_owner_org(json: dmp)
|
|
54
50
|
# Don't continue if DMP ID could not be found or the contact has no identifier (should be impossible)
|
|
55
51
|
raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil? || owner_org.nil?
|
|
56
52
|
|
data/lib/uc3-dmp-id/version.rb
CHANGED