bolognese 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bolognese/author_utils.rb +1 -1
- data/lib/bolognese/datacite_utils.rb +51 -55
- data/lib/bolognese/metadata.rb +16 -16
- data/lib/bolognese/metadata_utils.rb +5 -5
- data/lib/bolognese/readers/bibtex_reader.rb +4 -4
- data/lib/bolognese/readers/citeproc_reader.rb +9 -6
- data/lib/bolognese/readers/codemeta_reader.rb +7 -4
- data/lib/bolognese/readers/crossref_reader.rb +23 -17
- data/lib/bolognese/readers/datacite_json_reader.rb +21 -19
- data/lib/bolognese/readers/datacite_reader.rb +30 -66
- data/lib/bolognese/readers/ris_reader.rb +6 -3
- data/lib/bolognese/readers/schema_org_reader.rb +12 -9
- data/lib/bolognese/utils.rb +15 -14
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/writers/bibtex_writer.rb +2 -2
- data/lib/bolognese/writers/codemeta_writer.rb +3 -3
- data/lib/bolognese/writers/crosscite_writer.rb +6 -6
- data/lib/bolognese/writers/datacite_json_writer.rb +9 -9
- data/lib/bolognese/writers/jats_writer.rb +4 -4
- data/lib/bolognese/writers/ris_writer.rb +4 -4
- data/lib/bolognese/writers/schema_org_writer.rb +6 -6
- data/spec/author_utils_spec.rb +1 -1
- data/spec/datacite_utils_spec.rb +2 -2
- data/spec/fixtures/crosscite.json +26 -16
- data/spec/fixtures/datacite.json +20 -14
- data/spec/fixtures/datacite_software.json +10 -6
- data/spec/readers/bibtex_reader_spec.rb +6 -6
- data/spec/readers/citeproc_reader_spec.rb +3 -3
- data/spec/readers/codemeta_reader_spec.rb +14 -14
- data/spec/readers/crosscite_reader_spec.rb +8 -9
- data/spec/readers/crossref_reader_spec.rb +31 -28
- data/spec/readers/datacite_json_reader_spec.rb +20 -6
- data/spec/readers/datacite_reader_spec.rb +94 -93
- data/spec/readers/ris_reader_spec.rb +5 -5
- data/spec/readers/schema_org_reader_spec.rb +41 -34
- data/spec/utils_spec.rb +3 -3
- data/spec/writers/bibtex_writer_spec.rb +1 -1
- data/spec/writers/citeproc_writer_spec.rb +1 -1
- data/spec/writers/codemeta_writer_spec.rb +15 -15
- data/spec/writers/crosscite_writer_spec.rb +16 -16
- data/spec/writers/datacite_json_writer_spec.rb +17 -17
- data/spec/writers/datacite_writer_spec.rb +26 -26
- data/spec/writers/ris_writer_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb41752abec17479d1f11b7b7f0f7a4c5aad50698eae00d55e0e8adc71d2b5ce
|
4
|
+
data.tar.gz: d5b6df042eccfd780f2af437d79a12c26a28d99e6c740a06644f84a651cc458d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54669b2f390738ea6232ffde8866b4e57d829784b96168f5d0fde43b7672250be828e4c62cab815670cbac7056569e012338539022a78b0ef8979c4a05f8a52b
|
7
|
+
data.tar.gz: fc73f2fd0a8306c71458b0eff727f6b338d65623c5bf58079bb08eb711a02d90e57895599ba2b499a9fbf23f8a22f22e02490f12cf2a2c6af4afadcd8857d018
|
data/Gemfile.lock
CHANGED
@@ -105,7 +105,7 @@ module Bolognese
|
|
105
105
|
|
106
106
|
# parse array of author strings into CSL format
|
107
107
|
def get_authors(authors)
|
108
|
-
Array.wrap(authors).map { |author| get_one_author(author) }.
|
108
|
+
Array.wrap(authors).map { |author| get_one_author(author) }.compact
|
109
109
|
end
|
110
110
|
|
111
111
|
# parse nameIdentifier from DataCite
|
@@ -58,7 +58,7 @@ module Bolognese
|
|
58
58
|
|
59
59
|
xml.contributors do
|
60
60
|
Array.wrap(contributor).each do |con|
|
61
|
-
xml.contributor("contributorType" => con["
|
61
|
+
xml.contributor("contributorType" => con["contributor_type"] || "Other") do
|
62
62
|
insert_person(xml, con, "contributor")
|
63
63
|
end
|
64
64
|
end
|
@@ -67,8 +67,9 @@ module Bolognese
|
|
67
67
|
|
68
68
|
def insert_person(xml, person, type)
|
69
69
|
person_name = person["familyName"].present? ? [person["familyName"], person["givenName"]].compact.join(", ") : person["name"]
|
70
|
+
attributes = person["type"].present? ? { "nameType" => person["type"] + "al" } : {}
|
70
71
|
|
71
|
-
xml.send(type + "Name", person_name)
|
72
|
+
xml.send(type + "Name", person_name, attributes)
|
72
73
|
xml.givenName(person["givenName"]) if person["givenName"].present?
|
73
74
|
xml.familyName(person["familyName"]) if person["familyName"].present?
|
74
75
|
xml.nameIdentifier(person["id"], 'schemeURI' => 'http://orcid.org/', 'nameIdentifierScheme' => 'ORCID') if person["id"].present?
|
@@ -76,16 +77,16 @@ module Bolognese
|
|
76
77
|
|
77
78
|
def insert_titles(xml)
|
78
79
|
xml.titles do
|
79
|
-
Array.wrap(
|
80
|
-
if
|
81
|
-
t =
|
80
|
+
Array.wrap(titles).each do |title|
|
81
|
+
if title.is_a?(Hash)
|
82
|
+
t = title
|
82
83
|
else
|
83
84
|
t = {}
|
84
|
-
t["
|
85
|
+
t["title"] = title
|
85
86
|
end
|
86
87
|
|
87
|
-
attributes = { '
|
88
|
-
xml.title(t["
|
88
|
+
attributes = { 'titleType' => t["title_type"], 'lang' => t["lang"] }.compact
|
89
|
+
xml.title(t["title"], attributes)
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
@@ -98,16 +99,11 @@ module Bolognese
|
|
98
99
|
xml.publicationYear(publication_year)
|
99
100
|
end
|
100
101
|
|
101
|
-
def res_type
|
102
|
-
{ "resource_type_general" => types["resource_type_general"] || Metadata::SO_TO_DC_TRANSLATIONS[types["type"]] || "Other",
|
103
|
-
"__content__" => types["resource_type"] || types["type"] }
|
104
|
-
end
|
105
|
-
|
106
102
|
def insert_resource_type(xml)
|
107
103
|
return xml unless types["type"].present?
|
108
104
|
|
109
|
-
xml.resourceType(
|
110
|
-
'resourceTypeGeneral' =>
|
105
|
+
xml.resourceType(types["resource_type"] || types["type"],
|
106
|
+
'resourceTypeGeneral' => types["resource_type_general"] || Metadata::SO_TO_DC_TRANSLATIONS[types["type"]] || "Other")
|
111
107
|
end
|
112
108
|
|
113
109
|
def insert_alternate_identifiers(xml)
|
@@ -115,7 +111,7 @@ module Bolognese
|
|
115
111
|
|
116
112
|
xml.alternateIdentifiers do
|
117
113
|
Array.wrap(alternate_identifiers).each do |alternate_identifier|
|
118
|
-
xml.alternateIdentifier(alternate_identifier["
|
114
|
+
xml.alternateIdentifier(alternate_identifier["alternate_identifier"], 'alternateIdentifierType' => alternate_identifier["alternate_identifier_type"])
|
119
115
|
end
|
120
116
|
end
|
121
117
|
end
|
@@ -125,7 +121,8 @@ module Bolognese
|
|
125
121
|
|
126
122
|
xml.dates do
|
127
123
|
Array.wrap(dates).each do |date|
|
128
|
-
|
124
|
+
attributes = { 'dateType' => date["date_type"] || "Issued", 'dateInformation' => date["date_information"] }.compact
|
125
|
+
xml.date(date["date"], attributes)
|
129
126
|
end
|
130
127
|
end
|
131
128
|
end
|
@@ -136,36 +133,30 @@ module Bolognese
|
|
136
133
|
xml.fundingReferences do
|
137
134
|
Array.wrap(funding_references).each do |funding_reference|
|
138
135
|
xml.fundingReference do
|
139
|
-
|
136
|
+
xml.funderName(funding_reference["funder_name"])
|
137
|
+
xml.funderIdentifier(funding_reference["funder_identifier"], { "funderIdentifierType" => funding_reference["funder_identifier_type"] }.compact) if funding_reference["funder_identifier"].present?
|
138
|
+
xml.awardNumber(funding_reference["award_number"], { "awardURI" => funding_reference["award_uri"] }.compact) if funding_reference["award_number"].present? || funding_reference["award_uri"].present?
|
139
|
+
xml.awardTitle(funding_reference["award_title"]) if funding_reference["award_title"].present?
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
def insert_funding_reference(xml, funding_reference)
|
146
|
-
xml.funderName(funding_reference["funder_name"]) if funding_reference["funder_name"].present?
|
147
|
-
xml.funderIdentifier(funding_reference["funder_identifier"], "funderIdentifierType" => "Crossref Funder ID") if funding_reference["funder_identifier"].present?
|
148
|
-
end
|
149
|
-
|
150
145
|
def insert_subjects(xml)
|
151
|
-
return xml unless
|
146
|
+
return xml unless subjects.present?
|
152
147
|
|
153
148
|
xml.subjects do
|
154
|
-
|
155
|
-
if subject.is_a?(
|
156
|
-
|
157
|
-
xml.subject(subject)
|
149
|
+
subjects.each do |subject|
|
150
|
+
if subject.is_a?(Hash)
|
151
|
+
s = subject
|
158
152
|
else
|
159
|
-
|
160
|
-
|
161
|
-
if subject["subject_scheme"].present? then
|
162
|
-
subject_node['subjectScheme'] = subject["subject_scheme"]
|
163
|
-
end
|
164
|
-
|
165
|
-
if subject["scheme_uri"].present? then
|
166
|
-
subject_node['schemeURI'] = subject["scheme_uri"]
|
167
|
-
end
|
153
|
+
s = {}
|
154
|
+
s["subject"] = subject
|
168
155
|
end
|
156
|
+
|
157
|
+
attributes = { "subjectScheme" => s["subject_scheme"], "schemeURI" => s["scheme_uri"], "valueURI" => s["value_uri"], "lang" => s["lang"] }.compact
|
158
|
+
|
159
|
+
xml.subject(s["subject"], attributes)
|
169
160
|
end
|
170
161
|
end
|
171
162
|
end
|
@@ -185,51 +176,56 @@ module Bolognese
|
|
185
176
|
'relatedIdentifierType' => related_identifier["related_identifier_type"],
|
186
177
|
'relationType' => related_identifier["relation_type"],
|
187
178
|
'resourceTypeGeneral' => related_identifier["resource_type_general"] }.compact
|
188
|
-
|
179
|
+
|
180
|
+
attributes.merge({ 'relatedMetadataScheme' => related_identifier["related_metadata_schema"],
|
181
|
+
'schemeURI' => related_identifier["scheme_uri"],
|
182
|
+
'schemeType' => related_identifier["scheme_type"]}.compact) if %w(HasMetadata IsMetadataFor).include?(related_identifier["relation_type"])
|
183
|
+
|
184
|
+
xml.relatedIdentifier(related_identifier["related_identifier"], attributes)
|
189
185
|
end
|
190
186
|
end
|
191
187
|
end
|
192
188
|
|
193
189
|
def insert_rights_list(xml)
|
194
|
-
return xml unless
|
190
|
+
return xml unless rights_list.present?
|
195
191
|
|
196
192
|
xml.rightsList do
|
197
|
-
Array.wrap(
|
198
|
-
if
|
199
|
-
|
193
|
+
Array.wrap(rights_list).each do |rights|
|
194
|
+
if rights.is_a?(Hash)
|
195
|
+
r = rights
|
200
196
|
else
|
201
|
-
|
202
|
-
|
203
|
-
|
197
|
+
r = {}
|
198
|
+
r["rights"] = rights
|
199
|
+
r["rights_uri"] = normalize_id(rights)
|
204
200
|
end
|
205
201
|
|
206
|
-
attributes = { 'rightsURI' =>
|
202
|
+
attributes = { 'rightsURI' => r["rights_uri"], 'lang' => r["lang"] }.compact
|
207
203
|
|
208
|
-
xml.rights(
|
204
|
+
xml.rights(r["rights"], attributes)
|
209
205
|
end
|
210
206
|
end
|
211
207
|
end
|
212
208
|
|
213
209
|
def insert_descriptions(xml)
|
214
|
-
return xml unless
|
210
|
+
return xml unless descriptions.present? || periodical && periodical["title"].present?
|
215
211
|
|
216
212
|
xml.descriptions do
|
217
213
|
if periodical && periodical["title"].present?
|
218
214
|
xml.description(periodical["title"], 'descriptionType' => "SeriesInformation")
|
219
215
|
end
|
220
216
|
|
221
|
-
Array.wrap(
|
222
|
-
if
|
223
|
-
d =
|
217
|
+
Array.wrap(descriptions).each do |description|
|
218
|
+
if description.is_a?(Hash)
|
219
|
+
d = description
|
224
220
|
else
|
225
221
|
d = {}
|
226
|
-
d["
|
227
|
-
d["
|
222
|
+
d["description"] = description
|
223
|
+
d["description_type"] = "Abstract"
|
228
224
|
end
|
229
225
|
|
230
|
-
attributes = { 'lang' => d["lang"], 'descriptionType' => d["
|
226
|
+
attributes = { 'lang' => d["lang"], 'descriptionType' => d["description_type"] || "Abstract" }.compact
|
231
227
|
|
232
|
-
xml.description(d["
|
228
|
+
xml.description(d["description"], attributes)
|
233
229
|
end
|
234
230
|
end
|
235
231
|
end
|
data/lib/bolognese/metadata.rb
CHANGED
@@ -6,11 +6,11 @@ module Bolognese
|
|
6
6
|
class Metadata
|
7
7
|
include Bolognese::MetadataUtils
|
8
8
|
|
9
|
-
attr_writer :id, :provider_id, :client_id, :doi, :identifier, :creator, :contributor, :
|
10
|
-
:
|
11
|
-
:
|
9
|
+
attr_writer :id, :provider_id, :client_id, :doi, :identifier, :creator, :contributor, :titles, :publisher,
|
10
|
+
:rights_list, :dates, :publication_year, :volume, :first_page, :last_page, :url, :version,
|
11
|
+
:subjects, :contributor, :descriptions, :alternate_identifiers, :language, :sizes,
|
12
12
|
:formats, :schema_version, :meta, :periodical,
|
13
|
-
:format, :funding_references, :state, :
|
13
|
+
:format, :funding_references, :state, :geo_locations,
|
14
14
|
:types, :content_url, :related_identifiers
|
15
15
|
|
16
16
|
def initialize(input: nil, from: nil, **options)
|
@@ -104,24 +104,24 @@ module Bolognese
|
|
104
104
|
meta.fetch("errors", nil) || datacite_errors(xml: datacite, schema_version: schema_version)
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
@
|
107
|
+
def descriptions
|
108
|
+
@descriptions ||= meta.fetch("descriptions", nil)
|
109
109
|
end
|
110
110
|
|
111
|
-
def
|
112
|
-
@
|
111
|
+
def rights_list
|
112
|
+
@rights_list ||= meta.fetch("rights_list", nil)
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
116
|
-
@
|
115
|
+
def subjects
|
116
|
+
@subjects ||= meta.fetch("subjects", nil)
|
117
117
|
end
|
118
118
|
|
119
119
|
def language
|
120
120
|
@language ||= meta.fetch("language", nil)
|
121
121
|
end
|
122
122
|
|
123
|
-
def
|
124
|
-
@
|
123
|
+
def sizes
|
124
|
+
@sizes ||= meta.fetch("sizes", nil)
|
125
125
|
end
|
126
126
|
|
127
127
|
def formats
|
@@ -156,8 +156,8 @@ module Bolognese
|
|
156
156
|
@periodical ||= meta.fetch("periodical", nil)
|
157
157
|
end
|
158
158
|
|
159
|
-
def
|
160
|
-
@
|
159
|
+
def geo_locations
|
160
|
+
@geo_locations ||= meta.fetch("geo_locations", nil)
|
161
161
|
end
|
162
162
|
|
163
163
|
def dates
|
@@ -188,8 +188,8 @@ module Bolognese
|
|
188
188
|
@types ||= meta.fetch("types", nil)
|
189
189
|
end
|
190
190
|
|
191
|
-
def
|
192
|
-
@
|
191
|
+
def titles
|
192
|
+
@titles ||= meta.fetch("titles", nil)
|
193
193
|
end
|
194
194
|
|
195
195
|
def creator
|
@@ -103,12 +103,12 @@ module Bolognese
|
|
103
103
|
|
104
104
|
def reverse
|
105
105
|
{ "citation" => Array.wrap(related_identifiers).select { |ri| ri["relation_type"] == "IsReferencedBy" }.map do |r|
|
106
|
-
{ "@id" => normalize_doi(r["
|
106
|
+
{ "@id" => normalize_doi(r["related_identifier"]),
|
107
107
|
"@type" => r["resource_type_general"] || "CreativeWork",
|
108
108
|
"identifier" => r["related_identifier_type"] == "DOI" ? nil : to_identifier(r) }.compact
|
109
109
|
end.unwrap,
|
110
110
|
"isBasedOn" => Array.wrap(related_identifiers).select { |ri| ri["relation_type"] == "IsSupplementTo" }.map do |r|
|
111
|
-
{ "@id" => normalize_doi(r["
|
111
|
+
{ "@id" => normalize_doi(r["related_identifier"]),
|
112
112
|
"@type" => r["resource_type_general"] || "CreativeWork",
|
113
113
|
"identifier" => r["related_identifier_type"] == "DOI" ? nil : to_identifier(r) }.compact
|
114
114
|
end.unwrap }.compact
|
@@ -122,19 +122,19 @@ module Bolognese
|
|
122
122
|
{
|
123
123
|
"type" => types["citeproc"],
|
124
124
|
"id" => identifier,
|
125
|
-
"categories" => Array.wrap(
|
125
|
+
"categories" => Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) }.presence,
|
126
126
|
"language" => language,
|
127
127
|
"author" => to_citeproc(creator),
|
128
128
|
"contributor" => to_citeproc(contributor),
|
129
129
|
"issued" => get_date(dates, "Issued") ? get_date_parts(get_date(dates, "Issued")) : nil,
|
130
130
|
"submitted" => Array.wrap(dates).find { |d| d["type"] == "Submitted" }.to_h.fetch("__content__", nil),
|
131
|
-
"abstract" => parse_attributes(
|
131
|
+
"abstract" => parse_attributes(descriptions, content: "description", first: true),
|
132
132
|
"container-title" => periodical && periodical["title"],
|
133
133
|
"DOI" => doi,
|
134
134
|
"issue" => issue,
|
135
135
|
"page" => [first_page, last_page].compact.join("-").presence,
|
136
136
|
"publisher" => publisher,
|
137
|
-
"title" => parse_attributes(
|
137
|
+
"title" => parse_attributes(titles, content: "title", first: true),
|
138
138
|
"URL" => url,
|
139
139
|
"version" => version,
|
140
140
|
"volume" => volume
|
@@ -52,7 +52,7 @@ module Bolognese
|
|
52
52
|
"relation_type" => "IsPartOf",
|
53
53
|
"related_identifier_type" => "ISSN",
|
54
54
|
"title" => meta.journal.to_s,
|
55
|
-
"
|
55
|
+
"related_identifier" => meta.try(:issn).to_s.presence }.compact]
|
56
56
|
else
|
57
57
|
nil
|
58
58
|
end
|
@@ -79,7 +79,7 @@ module Bolognese
|
|
79
79
|
"types" => types,
|
80
80
|
"doi" => doi,
|
81
81
|
"url" => meta.try(:url).to_s,
|
82
|
-
"
|
82
|
+
"titles" => [{ "title" => meta.try(:title).to_s }],
|
83
83
|
"creator" => author,
|
84
84
|
"periodical" => periodical,
|
85
85
|
"publisher" => meta.try(:publisher).to_s.presence,
|
@@ -89,8 +89,8 @@ module Bolognese
|
|
89
89
|
"volume" => meta.try(:volume).to_s.presence,
|
90
90
|
"page_first" => page_first,
|
91
91
|
"page_last" => page_last,
|
92
|
-
"
|
93
|
-
"
|
92
|
+
"descriptions" => [{ "description" => meta.try(:abstract) && sanitize(meta.abstract.to_s).presence }],
|
93
|
+
"rights_list" => [{ "rights_uri" => meta.try(:copyright).to_s.presence }.compact],
|
94
94
|
"state" => state
|
95
95
|
}
|
96
96
|
end
|
@@ -53,8 +53,8 @@ module Bolognese
|
|
53
53
|
nil
|
54
54
|
end
|
55
55
|
publication_year = get_date_from_date_parts(meta.fetch("issued", nil)).to_s[0..3]
|
56
|
-
|
57
|
-
[{ "
|
56
|
+
rights_list = if meta.fetch("copyright", nil)
|
57
|
+
[{ "rights_uri" => normalize_url(meta.fetch("copyright")) }.compact]
|
58
58
|
else
|
59
59
|
nil
|
60
60
|
end
|
@@ -76,12 +76,15 @@ module Bolognese
|
|
76
76
|
end
|
77
77
|
id = normalize_id(meta.fetch("id", nil))
|
78
78
|
state = id.present? ? "findable" : "not_found"
|
79
|
+
subjects = Array.wrap(meta.fetch("categories")).map do |s|
|
80
|
+
{ "subject" => s }
|
81
|
+
end
|
79
82
|
|
80
83
|
{ "id" => id,
|
81
84
|
"types" => types,
|
82
85
|
"doi" => doi_from_url(doi),
|
83
86
|
"url" => normalize_id(meta.fetch("URL", nil)),
|
84
|
-
"
|
87
|
+
"titles" => [{ "title" => meta.fetch("title", nil) }],
|
85
88
|
"creator" => creator,
|
86
89
|
"contributor" => contributor,
|
87
90
|
"periodical" => periodical,
|
@@ -91,10 +94,10 @@ module Bolognese
|
|
91
94
|
"publication_year" => publication_year,
|
92
95
|
"volume" => meta.fetch("volume", nil),
|
93
96
|
#{}"pagination" => meta.pages.to_s.presence,
|
94
|
-
"
|
95
|
-
"
|
97
|
+
"descriptions" => meta.fetch("abstract", nil).present? ? [{ "description" => sanitize(meta.fetch("abstract")) }] : [],
|
98
|
+
"rights_list" => rights_list,
|
96
99
|
"version" => meta.fetch("version", nil),
|
97
|
-
"
|
100
|
+
"subjects" => subjects,
|
98
101
|
"state" => state
|
99
102
|
}
|
100
103
|
end
|
@@ -39,23 +39,26 @@ module Bolognese
|
|
39
39
|
"bibtex" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
|
40
40
|
"ris" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[type] || "GEN"
|
41
41
|
}.compact
|
42
|
+
subjects = Array.wrap(meta.fetch("tags", nil)).map do |s|
|
43
|
+
{ "subject" => s }
|
44
|
+
end
|
42
45
|
|
43
46
|
{ "id" => id,
|
44
47
|
"types" => types,
|
45
48
|
"identifier" => identifier,
|
46
49
|
"doi" => validate_doi(id),
|
47
50
|
"url" => normalize_id(meta.fetch("codeRepository", nil)),
|
48
|
-
"
|
51
|
+
"titles" => [{ "title" => meta.fetch("title", nil) }],
|
49
52
|
"creator" => author,
|
50
53
|
"contributor" => contributor,
|
51
54
|
"publisher" => publisher,
|
52
55
|
#{}"is_part_of" => is_part_of,
|
53
56
|
"dates" => dates,
|
54
57
|
"publication_year" => publication_year,
|
55
|
-
"
|
56
|
-
"
|
58
|
+
"descriptions" => meta.fetch("description", nil).present? ? [{ "description" => sanitize(meta.fetch("description")) }] : nil,
|
59
|
+
"rights_list" => [{ "rights_uri" => meta.fetch("license", nil) }.compact],
|
57
60
|
"version" => meta.fetch("version", nil),
|
58
|
-
"
|
61
|
+
"subjects" => subjects,
|
59
62
|
"state" => state
|
60
63
|
}
|
61
64
|
end
|
@@ -106,7 +106,7 @@ module Bolognese
|
|
106
106
|
"types" => types,
|
107
107
|
"doi" => doi,
|
108
108
|
"url" => bibliographic_metadata.dig("doi_data", "resource"),
|
109
|
-
"
|
109
|
+
"titles" => [{ "title" => parse_attributes(bibliographic_metadata.dig("titles", "title")) }],
|
110
110
|
"alternate_identifiers" => crossref_alternate_identifiers(bibliographic_metadata),
|
111
111
|
"creator" => crossref_people(bibliographic_metadata, "author"),
|
112
112
|
"contributor" => crossref_people(bibliographic_metadata, "editor"),
|
@@ -121,12 +121,12 @@ module Bolognese
|
|
121
121
|
"issue" => journal_issue.dig("issue"),
|
122
122
|
"first_page" => bibliographic_metadata.dig("pages", "first_page"),
|
123
123
|
"last_page" => bibliographic_metadata.dig("pages", "last_page"),
|
124
|
-
"
|
125
|
-
"
|
124
|
+
"descriptions" => crossref_description(bibliographic_metadata),
|
125
|
+
"rights_list" => crossref_license(program_metadata),
|
126
126
|
"version" => nil,
|
127
|
-
"
|
127
|
+
"subjects" => nil,
|
128
128
|
"language" => nil,
|
129
|
-
"
|
129
|
+
"sizes" => nil,
|
130
130
|
"schema_version" => nil,
|
131
131
|
"state" => state
|
132
132
|
}
|
@@ -134,19 +134,21 @@ module Bolognese
|
|
134
134
|
|
135
135
|
def crossref_alternate_identifiers(bibliographic_metadata)
|
136
136
|
if bibliographic_metadata.fetch("publisher_item", nil).present?
|
137
|
-
parse_attributes(bibliographic_metadata.dig("publisher_item", "item_number"))
|
137
|
+
{ "alternate_identifier" => parse_attributes(bibliographic_metadata.dig("publisher_item", "item_number")),
|
138
|
+
"alternate_identifier_type" => "Publisher ID" }
|
138
139
|
else
|
139
|
-
parse_attributes(bibliographic_metadata.fetch("item_number", nil))
|
140
|
+
{ "alternate_identifier" => parse_attributes(bibliographic_metadata.fetch("item_number", nil)),
|
141
|
+
"alternate_identifier_type" => "Publisher ID" }
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
143
145
|
def crossref_description(bibliographic_metadata)
|
144
146
|
abstract = Array.wrap(bibliographic_metadata.dig("abstract")).map do |r|
|
145
|
-
{ "
|
147
|
+
{ "description_type" => "Abstract", "description" => sanitize(parse_attributes(r, content: 'p')) }.compact
|
146
148
|
end
|
147
149
|
|
148
150
|
description = Array.wrap(bibliographic_metadata.dig("description")).map do |r|
|
149
|
-
{ "
|
151
|
+
{ "description_type" => "Other", "description" => sanitize(parse_attributes(r)) }.compact
|
150
152
|
end
|
151
153
|
|
152
154
|
(abstract + description)
|
@@ -156,7 +158,7 @@ module Bolognese
|
|
156
158
|
access_indicator = Array.wrap(program_metadata).find { |m| m["name"] == "AccessIndicators" }
|
157
159
|
if access_indicator.present?
|
158
160
|
Array.wrap(access_indicator["license_ref"]).map do |license|
|
159
|
-
{ "
|
161
|
+
{ "rights_uri" => normalize_url(parse_attributes(license)) }
|
160
162
|
end.uniq
|
161
163
|
else
|
162
164
|
nil
|
@@ -179,13 +181,17 @@ module Bolognese
|
|
179
181
|
fundref = Array.wrap(program_metadata).find { |a| a["name"] == "fundref" } || {}
|
180
182
|
Array.wrap(fundref.fetch("assertion", [])).select { |a| a["name"] == "fundgroup" }.map do |f|
|
181
183
|
f = Array.wrap(f.fetch("assertion", nil)).first
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
184
|
+
funder_identifier = normalize_id(f.dig("assertion", "__content__"))
|
185
|
+
funder_identifier_type = funder_identifier.present? ? "Crossref Funder ID" : nil
|
186
|
+
award_title = f.fetch("awardTitle", nil).present? ? f.fetch("awardTitle") : nil
|
187
|
+
|
188
|
+
{ "funder_identifier" => funder_identifier,
|
189
|
+
"funder_identifier_type" => funder_identifier_type,
|
190
|
+
"funder_name" => f.fetch("__content__", "").strip,
|
191
|
+
"award_title" => award_title,
|
186
192
|
"award_number" => f.dig("awardNumber", "__content__"),
|
187
193
|
"award_uri" => f.dig("awardNumber", "awardURI") }.compact
|
188
|
-
end
|
194
|
+
end
|
189
195
|
end
|
190
196
|
|
191
197
|
def crossref_date_published(bibliographic_metadata)
|
@@ -200,7 +206,7 @@ module Bolognese
|
|
200
206
|
|
201
207
|
def crossref_is_part_of(model_metadata)
|
202
208
|
if model_metadata.present? && model_metadata.fetch("issn", nil).present?
|
203
|
-
{ "
|
209
|
+
{ "related_identifier" => parse_attributes(model_metadata.fetch("issn", nil), first: true),
|
204
210
|
"relation_type" => "IsPartOf",
|
205
211
|
"related_identifier_type" => "ISSN",
|
206
212
|
"type" => "Periodical",
|
@@ -214,7 +220,7 @@ module Bolognese
|
|
214
220
|
refs = bibliographic_metadata.dig("citation_list", "citation")
|
215
221
|
Array.wrap(refs).select { |a| a["doi"].present? }.map do |c|
|
216
222
|
if c["doi"].present?
|
217
|
-
{ "
|
223
|
+
{ "related_identifier" => parse_attributes(c["doi"]).downcase,
|
218
224
|
"relation_type" => "References",
|
219
225
|
"related_identifier_type" => "DOI",
|
220
226
|
"title" => c["article_title"] }.compact
|