uc3-dmp-id 0.0.67 → 0.0.69
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 +2 -3
- data/lib/uc3-dmp-id/helper.rb +3 -2
- 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: add557c6bfad4f39ab0fcc4b164b4a50dd2f33c9fefa823ad95145e40d2d2495
|
4
|
+
data.tar.gz: 8b1fb5ab9edbb3e783d95419eac15f645fab8c91804a24f24996dfabb74f130a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 937ecb14c0178243e8c91ec21af41343cc6f9b898104587fa856723a2b9b87d335819f9838f7838382dbc65661c753e6836f526e526954bdaa1c159621d1df1f
|
7
|
+
data.tar.gz: 4d0adec75e6ad372d21a9a2d56565381e5cf898366f55474465c046801ae067c753eda2a4b00e2a69e70116016532d4ee9b3aaf16952a6d216ddb4de3a5e032b
|
data/lib/uc3-dmp-id/creator.rb
CHANGED
@@ -11,7 +11,7 @@ module Uc3DmpId
|
|
11
11
|
MSG_UNABLE_TO_MINT = 'Unable to mint a unique DMP ID.'
|
12
12
|
|
13
13
|
class << self
|
14
|
-
def create(provenance:,
|
14
|
+
def create(provenance:, json:, debug: false)
|
15
15
|
raise CreatorError, MSG_NO_SHOULDER if ENV['DMP_ID_SHOULDER'].nil?
|
16
16
|
raise CreatorError, MSG_NO_BASE_URL if ENV['DMP_ID_BASE_URL'].nil?
|
17
17
|
|
@@ -24,8 +24,7 @@ module Uc3DmpId
|
|
24
24
|
raise CreatorError, errs.join(', ') if errs.is_a?(Array) && errs.any? && errs.first != Validator::MSG_VALID_JSON
|
25
25
|
|
26
26
|
# Fail if the provenance or owner affiliation are not defined
|
27
|
-
raise CreatorError, MSG_NO_PROVENANCE_OWNER if provenance.nil?
|
28
|
-
raise CreatorError, MSG_NO_OWNER_ORG unless owner_org.is_a?(String) && !owner_org.strip.empty?
|
27
|
+
raise CreatorError, MSG_NO_PROVENANCE_OWNER if provenance.nil?
|
29
28
|
|
30
29
|
# TODO: Swap this out with the Finder search once the Dynamo indexes are working
|
31
30
|
# Try to find it first and Fail if found
|
data/lib/uc3-dmp-id/helper.rb
CHANGED
@@ -138,7 +138,8 @@ module Uc3DmpId
|
|
138
138
|
return nil unless json.is_a?(Hash)
|
139
139
|
|
140
140
|
dmp = json['dmp'].nil? ? json : json['dmp']
|
141
|
-
|
141
|
+
id = dmp.fetch('contact', {}).fetch('contact_id', {})['identifier']
|
142
|
+
return id unless id.nil?
|
142
143
|
|
143
144
|
dmp.fetch('contributor', []).map { |contributor| contributor.fetch('contact_id', {})['identifier'] }.first
|
144
145
|
end
|
@@ -160,7 +161,7 @@ module Uc3DmpId
|
|
160
161
|
# Add DMPHub specific fields to the DMP ID JSON
|
161
162
|
def annotate_dmp_json(provenance:, p_key:, json:)
|
162
163
|
json = parse_json(json: json)
|
163
|
-
return json if provenance.nil? ||
|
164
|
+
return json if provenance.nil? || p_key.nil? || !json.is_a?(Hash)
|
164
165
|
|
165
166
|
# Fail the json as is if the :PK does not match the :dmp_id if the json has a :PK
|
166
167
|
id = dmp_id_to_pk(json: json.fetch('dmp_id', {}))
|
data/lib/uc3-dmp-id/version.rb
CHANGED