uc3-dmp-id 0.0.93 → 0.0.94

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: effd6e9f621b4a0a2ff038e01a9db04f39284eebe520c18df70b6a224984e030
4
- data.tar.gz: be8087477ee5ae03e4c82b24cecf4f8b92b5fb4fa090520277738b0538d3324c
3
+ metadata.gz: 6e1f1181484200c982f852613b05b15f2e7a7e5ada500395d0c3d2dadc784f9e
4
+ data.tar.gz: c8edfcf737056d7e81f29545ccaefc6206da8e20a76ae42754206204a82145be
5
5
  SHA512:
6
- metadata.gz: 31d8ab61ec9adef5daba45bb25d26bfbb5559b5ac468bc3b05231e814e24e0670d84644040006ab723049f7c7b469e13a4ac53a9fd34c88ba8473232b0beb93e
7
- data.tar.gz: 1c2b1e95f0f01ca0ef7e641338eac0ab18e59b1137980dd912cb8b7321d7311a0dfa4f7458d796d73040e73ba91768399f19f9320be2a7da4b8941026337783e
6
+ metadata.gz: eed9ebc90a13702268f189f24ae23909227adb2531a53f709599483d1075372b1ce0442d6e8b158e280d493e8a7dd6ab053fe2fd21f7b5f7ac9dd30608a4c914
7
+ data.tar.gz: fe1042e750a090a3e5d9f5447e17a7a2a378294a4dccd866c09d5fe76f21ce75db9cd6c72882dab7261758c2be687070b23f87044b14aa5219b5c42e20ad0718
@@ -49,7 +49,7 @@ module Uc3DmpId
49
49
 
50
50
  # Find the DMP by its PK and SK
51
51
  # -------------------------------------------------------------------------
52
- def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, logger: nil)
52
+ def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, cleanse: true, logger: nil)
53
53
  raise FinderError, MSG_MISSING_PK if p_key.nil?
54
54
 
55
55
  s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.to_s.strip.empty?
@@ -67,7 +67,7 @@ module Uc3DmpId
67
67
  return nil if dmp['dmp']['PK'].nil?
68
68
 
69
69
  dmp = Versioner.append_versions(p_key: dmp['dmp']['PK'], dmp: dmp, client: client, logger: logger)
70
- Helper.cleanse_dmp_json(json: dmp)
70
+ cleanse ? Helper.cleanse_dmp_json(json: dmp) : dmp
71
71
  end
72
72
 
73
73
  # Fetch just the PK to see if a record exists
@@ -21,7 +21,7 @@ module Uc3DmpId
21
21
 
22
22
  # fetch the existing latest version of the DMP ID
23
23
  client = Uc3DmpDynamo::Client.new(logger: logger)
24
- existing = Finder.by_pk(p_key: p_key, client: client, logger: logger)
24
+ existing = Finder.by_pk(p_key: p_key, client: client, logger: logger, cleanse: false)
25
25
  logger.debug(message: "Existing latest record", details: existing) if logger.respond_to?(:debug)
26
26
 
27
27
  errs = _updateable?(provenance: provenance, p_key: p_key, json: annotated)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.93'
4
+ VERSION = '0.0.94'
5
5
  end
@@ -36,11 +36,9 @@ module Uc3DmpId
36
36
  puts "Provenance: #{provenance}, PK: #{p_key}"
37
37
  puts dmp
38
38
 
39
- return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(dmp: dmp)
39
+ return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(p_key: p_key, dmp: latest_version)
40
40
 
41
41
  client = Uc3DmpDynamo::Client.new if client.nil?
42
- latest_version = Finder.by_p_key(client: client, p_key: p_key) unless latest_version.is_a?(Hash) &&
43
- !latest_version['PK'].nil?
44
42
 
45
43
  owner = latest_version['dmphub_provenance_id']
46
44
  updater = provenance['PK']
@@ -86,8 +84,10 @@ puts dmp
86
84
  private
87
85
 
88
86
  # Determine whether the specified DMP metadata is versionable - returns boolean
89
- def _versionable?(dmp:)
90
- return false unless dmp.is_a?(Hash) && dmp['PK'].nil? && dmp['SK'].nil?
87
+ def _versionable?(p_key:, dmp:)
88
+ return false unless dmp.is_a?(Hash) &&
89
+ dmp['PK']&.to_s&.downcase == p_key&.to_s&.downcase &&
90
+ dmp['SK'] == Helper::DMP_LATEST_VERSION
91
91
 
92
92
  # It's versionable if it has a DMP ID
93
93
  !dmp.fetch('dmp_id', {})['identifier'].nil?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.93
4
+ version: 0.0.94
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley