uc3-dmp-id 0.0.47 → 0.0.49

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43c55916e9c3c7e5dffebe207a69de110ff182000a72ae3ea915036653199be0
4
- data.tar.gz: 7eb32abc118b66d38084716f34dd0994043c62421c7cba00ff85353f9442d3a9
3
+ metadata.gz: 07f8f7d24b3a076d6f6f04a4e797fb4d054eacabb744c4899451664fcf453cb1
4
+ data.tar.gz: a50778c06dc79cfb3a0893ae3848c72270223d97a3306a8a645e72591c143b07
5
5
  SHA512:
6
- metadata.gz: 0f758910ef012627c05710e6dda80e3c72abdf77f0e7cff64ea46cb93a7697bacf8802ed73e3d455cb98dc245640a45d43f2f3b8ed2945d9b3043d31ec83e203
7
- data.tar.gz: 45737a59db0d8e2a5e9a59ddadbccb7a36af9513a91ba04ba04f1919bef867060ba6139c8abdb55c4c1bb1452a599a35bce23cad8a59aab1037c522486c72dde
6
+ metadata.gz: 7641129e679125b75d11af27adb29b50e7d7496b0a27032d2cff147cd8b389bbfafdcecc99e8b9b6e69eadde9f7b7b27fcdd9f58b3b594362f3080101c115f06
7
+ data.tar.gz: 3586977e6d06503b1a81440174eec61afb0fea2c0faa29a9090de9f894b34927802359d45fd184aa036072e259971c79d3b1a26d861718f94500dbe9bc2aeb46
@@ -34,7 +34,7 @@ module Uc3DmpId
34
34
  raise CreatorError, Uc3DmpId::MSG_DMP_EXISTS unless json['PK'].nil?
35
35
 
36
36
  client = Uc3DmpDynamo::Client.new(debug: debug)
37
- p_key = _preregister_dmp_id(client: client, json: json, debug: debug)
37
+ p_key = _preregister_dmp_id(client: client, provenance: provenance, json: json, debug: debug)
38
38
  raise CreatorError, MSG_UNABLE_TO_MINT if p_key.nil?
39
39
 
40
40
  # Add the DMPHub specific attributes and then save
@@ -52,12 +52,21 @@ module Uc3DmpId
52
52
 
53
53
  private
54
54
 
55
- def _preregister_dmp_id(client:, json:, debug: false)
55
+ def _preregister_dmp_id(client:, provenance:, json:, debug: false)
56
56
  # Use the specified DMP ID if the provenance has permission
57
57
  existing = json.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
- return id if !id.nil? && existing['type'].downcase == 'doi' && !Finder.exists?(client: client, p_key: id)
60
+
61
+ puts "_preregister_dmp_id:"
62
+ puts provenance
63
+ puts id
64
+
65
+
66
+ return id if !id.nil? &&
67
+ existing['type'].downcase == 'doi' &&
68
+ provenance['seedingWithLiveDmpIds'].downcase == 'true' &&
69
+ !Finder.exists?(client: client, p_key: id)
61
70
 
62
71
  dmp_id = ''
63
72
  counter = 0
@@ -213,6 +213,35 @@ module Uc3DmpId
213
213
  end
214
214
  end
215
215
  # rubocop:enable Metrics/AbcSize
216
+
217
+ # Appends the Provenance system's identifier to the value
218
+ # For a DOI, it will return the DOI as-is
219
+ #
220
+ # For a :provenance whose PK is 'PROVENANCE#example' and homepage is 'https://example.com' and
221
+ # callbackUri is 'https://example.com/callback':
222
+ # when the :value is '12345', it will return 'example#12345'
223
+ # when the :value is 'https://example.com/dmps/12345', it will return 'example#dmp/12345'
224
+ # when the :value is 'https://example.com/callback/12345' it will return 'example#12345'
225
+ #
226
+ # rubocop:disable Metrics/AbcSize
227
+ def format_provenance_id(provenance:, value:)
228
+ # return it as-is if there is no provenance or it's already a URL
229
+ return value if provenance.nil?
230
+
231
+ # return it as-is if it's a DOI
232
+ doi = value.match(DOI_REGEX).to_s
233
+ return value unless doi.nil? || doi == '' || !value.start_with?('http')
234
+
235
+ # Remove the homepage or callbackUri because we will add this when needed. we just want the id
236
+ val = value.downcase
237
+ .gsub(provenance.fetch('callbackUri', '').downcase, '')
238
+ .gsub(provenance.fetch('homepage', '').downcase, '')
239
+ val = val.gsub(%r{https?://}, '')
240
+ val = val[1..val.length] if val.start_with?('/')
241
+ id = provenance['PK']&.gsub('PROVENANCE#', '')
242
+ "#{id}##{val}"
243
+ end
244
+ # rubocop:enable Metrics/AbcSize
216
245
  end
217
246
  end
218
247
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.47'
4
+ VERSION = '0.0.49'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.47
4
+ version: 0.0.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json