uc3-dmp-id 0.1.8 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-id/augmenter.rb +19 -7
- data/lib/uc3-dmp-id/version.rb +1 -1
- 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: 2d988ee80dfa85fc4f592a30bb6d53cb20b47e64998b06111e441343e286c5f9
|
4
|
+
data.tar.gz: 86c974744aee06dd4d5b790159e018f63399438d46a9f131e56babf02cef51e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aad86fe76210fc8255b0513d74737e31884fe7827aa6a66edabf2fa24aaae8ed99eb8f7fabfd34a2f04a340b2a127d2f26d4bdac3ceabf596e115e925e54748
|
7
|
+
data.tar.gz: 7496d05bcc65128c8ff645280994a2e430f0b7ca9ee80224defe1331ea27033af4e29c7ddcdcc3815df5640a9f02e41bad7b13036114fdda18a3a6f4f486dec9
|
data/lib/uc3-dmp-id/augmenter.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'bibtex'
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
|
+
require 'uc3-dmp-citation'
|
7
|
+
|
6
8
|
module Uc3DmpId
|
7
9
|
class AugmenterError < StandardError; end
|
8
10
|
|
@@ -29,7 +31,7 @@ module Uc3DmpId
|
|
29
31
|
end
|
30
32
|
# rubocop:enable Metrics/AbcSize
|
31
33
|
|
32
|
-
# rubocop:disable Metrics/AbcSize
|
34
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
33
35
|
def add_modifications(works:)
|
34
36
|
mod_hash = _generate_mod_header
|
35
37
|
|
@@ -42,13 +44,15 @@ module Uc3DmpId
|
|
42
44
|
fundings = publication.fetch('fundingReferences', [])
|
43
45
|
next unless fundings.any?
|
44
46
|
|
45
|
-
award_hash = fundings.map { |funding| _funding_to_mod_entry(funding:) }
|
47
|
+
award_hash = fundings.map { |funding| _funding_to_mod_entry(work: publication, funding:) }
|
46
48
|
mod_hash.fetch('funding', []) << award_hash unless award_hash.nil?
|
47
49
|
end
|
48
50
|
return 0 unless mod_hash['dmproadmap_related_identifiers'].any? || mod_hash.fetch('funding', []).any?
|
49
51
|
|
52
|
+
# A single work can have multiple fundingReferences, so flatten the array
|
53
|
+
mod_hash['funding'] = mod_hash.fetch('funding', []).flatten.compact.uniq
|
54
|
+
|
50
55
|
# Save the DMP
|
51
|
-
mods = (@known_mods.nil? ? [] : @known_mods)
|
52
56
|
@dmp['dmphub_modifications'] = (@known_mods.nil? ? [] : @known_mods) << mod_hash
|
53
57
|
|
54
58
|
client = Uc3DmpDynamo::Client.new
|
@@ -58,7 +62,7 @@ module Uc3DmpId
|
|
58
62
|
# Return the number of modifications added to the DMP
|
59
63
|
mod_hash.fetch('dmproadmap_related_identifiers', []).length + mod_hash.fetch('funding', []).length
|
60
64
|
end
|
61
|
-
# rubocop:enable Metrics/AbcSize
|
65
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
62
66
|
|
63
67
|
private
|
64
68
|
|
@@ -68,7 +72,7 @@ module Uc3DmpId
|
|
68
72
|
provenance: @augmenter['name'],
|
69
73
|
timestamp: Time.now.utc.iso8601,
|
70
74
|
dmproadmap_related_identifiers: [],
|
71
|
-
|
75
|
+
funding: []
|
72
76
|
}.to_json)
|
73
77
|
end
|
74
78
|
|
@@ -80,10 +84,14 @@ module Uc3DmpId
|
|
80
84
|
type: 'doi',
|
81
85
|
identifier: work['id'],
|
82
86
|
descriptor: 'references',
|
83
|
-
status: 'pending'
|
87
|
+
status: 'pending',
|
88
|
+
confidence: work['confidence'],
|
89
|
+
score: work['score'],
|
90
|
+
notes: work['notes']
|
84
91
|
}
|
85
92
|
work_type = work.fetch('type', 'Text')&.downcase&.strip
|
86
93
|
ret[:work_type] = work_type == 'text' ? type : work_type
|
94
|
+
@logger&.debug(message: "Assessing Work: #{work['id']} (pre citation)", details: ret)
|
87
95
|
return JSON.parse(ret.to_json) if work['bibtex'].nil?
|
88
96
|
|
89
97
|
ret[:citation] = Uc3DmpCitation::Citer.bibtex_to_citation(bibtex_as_string: work['bibtex'])
|
@@ -94,7 +102,7 @@ module Uc3DmpId
|
|
94
102
|
# Convert a funding entry for the dmphub_modification
|
95
103
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
96
104
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
97
|
-
def _funding_to_mod_entry(funding:)
|
105
|
+
def _funding_to_mod_entry(work:, funding:)
|
98
106
|
return nil unless funding.is_a?(Hash) && (!funding['awardUri'] || !funding['awardNumber'])
|
99
107
|
return nil if @known_awards.include?(funding['awardUri']) || @known_awards.include?(funding['awardNumber'])
|
100
108
|
|
@@ -103,6 +111,9 @@ module Uc3DmpId
|
|
103
111
|
|
104
112
|
ret = {
|
105
113
|
status: 'pending',
|
114
|
+
confidence: work['confidence'],
|
115
|
+
score: work['score'],
|
116
|
+
notes: work['notes'],
|
106
117
|
name: funding['funderName'],
|
107
118
|
funding_status: 'granted',
|
108
119
|
grant_id: {
|
@@ -115,6 +126,7 @@ module Uc3DmpId
|
|
115
126
|
}
|
116
127
|
}
|
117
128
|
funder_id = funding['funderIdentifier']
|
129
|
+
@logger&.debug(message: "Assessing Work: #{work['id']} (pre funder_id)", details: ret)
|
118
130
|
return JSON.parse(ret.to_json) if funder_id.nil?
|
119
131
|
|
120
132
|
ret[:funder_id] = {
|
data/lib/uc3-dmp-id/version.rb
CHANGED