uc3-dmp-id 0.0.94 → 0.0.96

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: 6e1f1181484200c982f852613b05b15f2e7a7e5ada500395d0c3d2dadc784f9e
4
- data.tar.gz: c8edfcf737056d7e81f29545ccaefc6206da8e20a76ae42754206204a82145be
3
+ metadata.gz: c6623f79604248f9a0f7ea88837a0d75a85fb4b30766352bb68a6c5de08125cf
4
+ data.tar.gz: 6e51e71740077defbd9b456fa5557532fc143484ac75de58510cc25ac96d073b
5
5
  SHA512:
6
- metadata.gz: eed9ebc90a13702268f189f24ae23909227adb2531a53f709599483d1075372b1ce0442d6e8b158e280d493e8a7dd6ab053fe2fd21f7b5f7ac9dd30608a4c914
7
- data.tar.gz: fe1042e750a090a3e5d9f5447e17a7a2a378294a4dccd866c09d5fe76f21ce75db9cd6c72882dab7261758c2be687070b23f87044b14aa5219b5c42e20ad0718
6
+ metadata.gz: 254631a72b6bae0629df5f6b7606a9d0b2323071de9b573a9712225b73a3c2a1a514236edad355b6fd9241f3267397ac275b47e92759025b4bd5f41cb21bacdf
7
+ data.tar.gz: 8274ce2a62b81621cef098f70d8f62c10a3a56b09bb8b7832a4dd2fa16aa09af09ab9cc2d343c2a672ca6f8d70a6766a27aac0710d32df77221551ba694116bf
@@ -30,7 +30,7 @@ module Uc3DmpId
30
30
 
31
31
  # Find a DMP based on the contents of the incoming JSON
32
32
  # -------------------------------------------------------------------------
33
- def by_json(json:, logger: nil)
33
+ def by_json(json:, cleanse: true, logger: nil)
34
34
  json = Helper.parse_json(json: json)&.fetch('dmp', {})
35
35
  raise FinderError, MSG_INVALID_ARGS if json.nil? || (json['PK'].nil? && json['dmp_id'].nil?)
36
36
 
@@ -44,7 +44,7 @@ module Uc3DmpId
44
44
  # return by_provenance_identifier(json: json, client: client, logger: logger) if p_key.nil?
45
45
 
46
46
  # find_by_PK
47
- p_key.nil? ? nil : by_pk(p_key: p_key, s_key: json['SK'], client: client, logger: logger)
47
+ p_key.nil? ? nil : by_pk(p_key: p_key, s_key: json['SK'], client: client, cleanse: cleanse, logger: logger)
48
48
  end
49
49
 
50
50
  # Find the DMP by its PK and SK
@@ -88,7 +88,7 @@ module Uc3DmpId
88
88
  # Attempt to find the DMP item by the provenance system's identifier
89
89
  # -------------------------------------------------------------------------
90
90
  # rubocop:disable Metrics/AbcSize
91
- def by_provenance_identifier(json:, client: nil, logger: nil)
91
+ def by_provenance_identifier(json:, client: nil, cleanse: true, logger: nil)
92
92
  raise FinderError, MSG_MISSING_PROV_ID if json.nil? || json.fetch('dmp_id', {})['identifier'].nil?
93
93
 
94
94
  args = {
@@ -110,7 +110,7 @@ module Uc3DmpId
110
110
  return nil if dmp['dmp']['PK'].nil?
111
111
 
112
112
  # If we got a hit, fetch the DMP and return it.
113
- by_pk(p_key: dmp['dmp']['PK'], s_key: dmp['dmp']['SK'])
113
+ by_pk(p_key: dmp['dmp']['PK'], s_key: dmp['dmp']['SK'], cleanse: cleanse, logger: logger)
114
114
  end
115
115
  # rubocop:enable Metrics/AbcSize
116
116
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.94'
4
+ VERSION = '0.0.96'
5
5
  end
@@ -36,16 +36,16 @@ 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?(p_key: p_key, dmp: latest_version)
39
+ return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(p_key: p_key, dmp: latest_version['dmp'])
40
40
 
41
41
  client = Uc3DmpDynamo::Client.new if client.nil?
42
42
 
43
43
  owner = latest_version['dmphub_provenance_id']
44
44
  updater = provenance['PK']
45
- prior = _generate_version(client: client, latest_version: latest_version, owner: owner, updater: updater)
45
+ prior = _generate_version(client: client, latest_version: latest_version['dmp'], owner: owner, updater: updater)
46
46
  return nil if prior.nil?
47
47
 
48
- args = { owner: owner, updater: updater, base: prior, mods: dmp, logger: logger }
48
+ args = { owner: owner, updater: updater, base: prior, mods: dmp['dmp'], logger: logger }
49
49
  logger.debug(message: "#{SOURCE} record prior to splicing", details: dmp) if logger.respond_to?(:debug)
50
50
 
51
51
  # If the system of provenance is making the change then just use the
@@ -85,9 +85,10 @@ puts dmp
85
85
 
86
86
  # Determine whether the specified DMP metadata is versionable - returns boolean
87
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
88
+
89
+ puts "PK MATCH? #{dmp['PK'] == p_key}, SK IS LATEST? #{dmp['SK'] == Helper::DMP_LATEST_VERSION}, DMP ID PRESENT? #{!dmp.fetch('dmp_id', {})['identifier'].nil?}"
90
+
91
+ return false unless dmp.is_a?(Hash) && dmp['PK'] == p_key && dmp['SK'] == Helper::DMP_LATEST_VERSION
91
92
 
92
93
  # It's versionable if it has a DMP ID
93
94
  !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.94
4
+ version: 0.0.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley