uc3-dmp-id 0.0.59 → 0.0.61

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: a7f1d4153e4af1ce9ef49c831f2c65d995e177100def3bfc473c10e25647cbf4
4
- data.tar.gz: 18d148667df1d518ed423d087d9732c28142691a77ecb74a42e54de2ad544615
3
+ metadata.gz: f57c20b88aa66fde624307bb92a176682f83058929d36c54f5bc8f3930a98b2d
4
+ data.tar.gz: 2dc28c07fc2fc766904b3360b043cd6c3b3af7a772765f5681e9dd29040d0a39
5
5
  SHA512:
6
- metadata.gz: f698bfcb7fff04d14481a5a7e4e4c500fe76e88bdbfe13f1791111fc0c0bffa26751786d9ee647774fc1c6a1a1b6675daa27d158c32479bdc387500b535a2b47
7
- data.tar.gz: bc0e02218ed69278a5fa3b3a479b396d8b344505809cd4a4a2938bbe4afde9e1db80ec0776e0bac03dd794d04169b52e8ba078534b00d11ed64b387d2a541503
6
+ metadata.gz: 9896f63e4d891d16bd97d5293516bf3dc4694ae9dcb8490431433d1061e03dca23c5f99a5d0b6959e7316e6eec19cd5c16aaa7ec93d3fd156b6d877097aec8c9
7
+ data.tar.gz: fe9a16d6cf9cfad66eb1547137fa5a43583b59c3198476809249a311a01ee91a3086802108a9196dfeb0a95f48620e992505f03d4fe178b434059cf7722b2809
@@ -136,10 +136,16 @@ module Uc3DmpId
136
136
  # Add DMPHub specific fields to the DMP ID JSON
137
137
  def annotate_dmp_json(provenance:, owner_org:, p_key:, json:)
138
138
  json = parse_json(json: json)
139
+
140
+ puts "annotate - prov: #{provenance['PK']}, owner_org: #{owner_org}, p_key: #{p_key}, Hash? #{json.is_a?(Hash)} ::: #{provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)}"
141
+
139
142
  return json if provenance.nil? || owner_org.nil? || p_key.nil? || !json.is_a?(Hash)
140
143
 
141
144
  # Fail the json as is if the :PK does not match the :dmp_id if the json has a :PK
142
145
  id = dmp_id_to_pk(json: json.fetch('dmp_id', {}))
146
+
147
+ puts "annotate - id: #{id}, PK exist? #{json['PK']} ::: #{id != p_key && !json['PK'].nil?}"
148
+
143
149
  return json if id != p_key && !json['PK'].nil?
144
150
 
145
151
  annotated = deep_copy_dmp(obj: json)
@@ -46,14 +46,18 @@ module Uc3DmpId
46
46
  # fetch the existing latest version of the DMP ID
47
47
  client = Uc3DmpDynamo::Client.new(debug: debug)
48
48
  dmp = Finder.by_pk(p_key: p_key, client: client, debug: debug)
49
- # Don't continue if nothing has changed!
50
- raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil?
49
+ owner_org = dmp['dmp'].fetch('contact', {}).fetch('dmproadmap_affiliation', {}) unless dmp.nil?
50
+ owner_org = owner_org.fetch('affiliation_id', {})['identifier'] unless owner_org.nil?
51
+
52
+ puts "OWNER ORG: #{owner_org}"
53
+
54
+ # Don't continue if DMP ID could not be found or the contact has no identifier (should be impossible)
55
+ raise UpdaterError, MSG_DMP_NOT_FOUND if dmp.nil? || owner_org.nil?
51
56
 
52
57
  errs = _updateable?(provenance: provenance, p_key: p_key, json: dmp['dmp'])
53
58
  raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
54
59
 
55
- # Add the DMPHub specific attributes
56
- owner_org = dmp['dmp']['dmphub_owner_org']
60
+ # Add the DMPHub specific attributes and then add the download URl for the PDF
57
61
  annotated = Helper.annotate_dmp_json(provenance: provenance, owner_org: owner_org, p_key: p_key, json: dmp['dmp'])
58
62
  annotated['dmproadmap_related_identifiers'] = [] if annotated['dmproadmap_related_identifiers'].nil?
59
63
  annotated['dmproadmap_related_identifiers'] << {
@@ -63,7 +67,7 @@ module Uc3DmpId
63
67
  puts "Attached:"
64
68
  puts annotated
65
69
 
66
- # Save the changes as the new latest version
70
+ # Save the changes without creating a new version!
67
71
  resp = client.put_item(json: annotated, debug: debug)
68
72
  raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
69
73
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.59'
4
+ VERSION = '0.0.61'
5
5
  end
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.59
4
+ version: 0.0.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley