dmp-dynamo_adapter 0.2.5 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dmp/dmp_id_handler.rb +0 -18
- data/lib/dmp/dynamo_adapter.rb +22 -8
- 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: 1fde969438aa9681c5213d60e441b3187de1ed2141c7b244419ba47a007d39fc
|
4
|
+
data.tar.gz: a4a9722f607edf91644043c4adbcb3af7bfe81f33d254da104a0223a27fd6c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba67f79d6cdf0b4d29f416301e88b8b4453f85b7381a82280f5389dde4c12bb5446e59bdd21290d04203dbcdaefc73f08c1bd8ffd5221b945a19e514e4f1c2b
|
7
|
+
data.tar.gz: 8c2a12ccd6b1049a12f254a6ae5f634c63aa2c3b82870778fd541482d6888cd720426ac6cb213d72b6fb3605ad38a3b948abf7393f63b90cc3898fa72f60966e
|
data/lib/dmp/dmp_id_handler.rb
CHANGED
@@ -13,24 +13,6 @@ module Dmp
|
|
13
13
|
ENV['DMP_ID_BASE_URL'].end_with?('/') ? ENV['DMP_ID_BASE_URL'] : "#{ENV['DMP_ID_BASE_URL']}/"
|
14
14
|
end
|
15
15
|
|
16
|
-
# Preassign a DMP ID that will leater be sent to the DOI minting authority (EZID)
|
17
|
-
def preregister_dmp_id
|
18
|
-
dmp_id = ''
|
19
|
-
counter = 0
|
20
|
-
|
21
|
-
p 'PREREGISTER DMP ID:'
|
22
|
-
|
23
|
-
while dmp_id == '' && counter <= 10
|
24
|
-
prefix = "#{ENV['DMP_ID_SHOULDER']}.#{SecureRandom.hex(4).upcase}"
|
25
|
-
dmp_id = prefix if find_by_pk(p_key: Dmp::MetadataHandler.append_pk_prefix(dmp: dmp_id)).empty?
|
26
|
-
counter += 1
|
27
|
-
end
|
28
|
-
# Something went wrong and it was unable to identify a unique id
|
29
|
-
return nil if counter >= 10
|
30
|
-
|
31
|
-
"#{Dmp::MetadataHandler::PK_DMP_PREFIX}#{dmp_id_base_url}#{dmp_id}"
|
32
|
-
end
|
33
|
-
|
34
16
|
# Format the DMP ID in the way we want it
|
35
17
|
def format_dmp_id(value:)
|
36
18
|
dmp_id = value.match(DOI_REGEX).to_s
|
data/lib/dmp/dynamo_adapter.rb
CHANGED
@@ -89,8 +89,7 @@ p "FINDING BY PK: PK - #{p_key.inspect} / SK - #{s_key.inspect}"
|
|
89
89
|
|
90
90
|
# find_by_PK
|
91
91
|
response = find_by_pk(p_key: pk, s_key: json['SK']) unless pk.nil?
|
92
|
-
return response
|
93
|
-
return response unless response[:items].nil? || response[:items].empty?
|
92
|
+
return response unless response[:status] != 404
|
94
93
|
|
95
94
|
# find_by_dmphub_provenance_id -> if no PK and no dmp_id result
|
96
95
|
find_by_dmphub_provenance_identifier(json: json)
|
@@ -105,16 +104,12 @@ p "FINDING BY PK: PK - #{p_key.inspect} / SK - #{s_key.inspect}"
|
|
105
104
|
|
106
105
|
# Try to find it first
|
107
106
|
result = find_by_json(json: json)
|
108
|
-
|
109
|
-
p "RESULT:"
|
110
|
-
pp result
|
111
|
-
|
112
107
|
return { status: 500, error: result.fetch(:error, MSG_DEFAULT) } if result[:status] == 500
|
113
108
|
# Abort if found
|
114
|
-
return { status: 400, error: MSG_EXISTS } if result
|
109
|
+
return { status: 400, error: MSG_EXISTS } if result.fetch(:items, []).any?
|
115
110
|
|
116
111
|
# allocate a DMP ID
|
117
|
-
p_key =
|
112
|
+
p_key = preregister_dmp_id
|
118
113
|
|
119
114
|
p "PRE REGISTERED DMP ID: #{p_key.inspect}"
|
120
115
|
|
@@ -293,6 +288,25 @@ pp response.data
|
|
293
288
|
end
|
294
289
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
295
290
|
|
291
|
+
# Preassign a DMP ID that will leater be sent to the DOI minting authority (EZID)
|
292
|
+
def preregister_dmp_id
|
293
|
+
dmp_id = ''
|
294
|
+
counter = 0
|
295
|
+
|
296
|
+
p 'PREREGISTER DMP ID:'
|
297
|
+
|
298
|
+
while dmp_id == '' && counter <= 10
|
299
|
+
prefix = "#{ENV['DMP_ID_SHOULDER']}.#{SecureRandom.hex(4).upcase}"
|
300
|
+
result = find_by_pk(p_key: Dmp::MetadataHandler.append_pk_prefix(dmp: dmp_id))
|
301
|
+
dmp_id = prefix unless result[:status] != 404
|
302
|
+
counter += 1
|
303
|
+
end
|
304
|
+
# Something went wrong and it was unable to identify a unique id
|
305
|
+
return nil if counter >= 10
|
306
|
+
|
307
|
+
"#{Dmp::MetadataHandler::PK_DMP_PREFIX}#{Dmp::DmpIdHandler.dmp_id_base_url}#{dmp_id}"
|
308
|
+
end
|
309
|
+
|
296
310
|
# Convert the latest version into a historical version
|
297
311
|
# rubocop:disable Metrics/MethodLength
|
298
312
|
def version_it(dmp:)
|