bolognese 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bolognese/datacite_utils.rb +23 -23
- data/lib/bolognese/metadata.rb +5 -1
- data/lib/bolognese/metadata_utils.rb +10 -14
- data/lib/bolognese/readers/bibtex_reader.rb +9 -9
- data/lib/bolognese/readers/citeproc_reader.rb +12 -12
- data/lib/bolognese/readers/codemeta_reader.rb +12 -12
- data/lib/bolognese/readers/crossref_reader.rb +27 -29
- data/lib/bolognese/readers/datacite_json_reader.rb +19 -28
- data/lib/bolognese/readers/datacite_reader.rb +37 -37
- data/lib/bolognese/readers/ris_reader.rb +9 -9
- data/lib/bolognese/readers/schema_org_reader.rb +37 -32
- data/lib/bolognese/utils.rb +31 -34
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/writers/codemeta_writer.rb +1 -1
- data/lib/bolognese/writers/crosscite_writer.rb +1 -1
- data/lib/bolognese/writers/datacite_json_writer.rb +10 -10
- data/lib/bolognese/writers/jats_writer.rb +1 -1
- data/lib/bolognese/writers/ris_writer.rb +1 -1
- data/lib/bolognese/writers/schema_org_writer.rb +6 -6
- data/spec/datacite_utils_spec.rb +1 -1
- data/spec/fixtures/crosscite.json +8 -8
- data/spec/fixtures/datacite.json +22 -22
- data/spec/readers/bibtex_reader_spec.rb +6 -6
- data/spec/readers/citeproc_reader_spec.rb +2 -2
- data/spec/readers/codemeta_reader_spec.rb +8 -8
- data/spec/readers/crosscite_reader_spec.rb +4 -4
- data/spec/readers/crossref_reader_spec.rb +56 -59
- data/spec/readers/datacite_json_reader_spec.rb +7 -7
- data/spec/readers/datacite_reader_spec.rb +193 -194
- data/spec/readers/ris_reader_spec.rb +5 -5
- data/spec/readers/schema_org_reader_spec.rb +31 -32
- data/spec/utils_spec.rb +4 -4
- data/spec/writers/crosscite_writer_spec.rb +10 -13
- data/spec/writers/datacite_json_writer_spec.rb +9 -9
- data/spec/writers/datacite_writer_spec.rb +24 -26
- data/spec/writers/schema_org_writer_spec.rb +2 -2
- metadata +2 -2
@@ -10,55 +10,46 @@ module Bolognese
|
|
10
10
|
meta = string.present? ? Maremma.from_json(string) : {}
|
11
11
|
|
12
12
|
state = meta.fetch("doi", nil).present? ? "findable" : "not_found"
|
13
|
-
|
14
|
-
{ "related_identifier" => ri["related-identifier"],
|
15
|
-
"relation_type" => ri["relation-type"],
|
16
|
-
"related_identifier_type" => ri["related-identifier-type"],
|
17
|
-
"resource_type_general" => ri["resource-type-general"] }.compact
|
18
|
-
end
|
19
|
-
alternate_identifiers = Array.wrap(meta.fetch("alternate-identifiers", nil)).map do |ai|
|
20
|
-
{ "alternate_identifier" => ai["alternate-identifier"],
|
21
|
-
"alternate_identifier_type" => ai["alternate-identifier-type"] }.compact
|
22
|
-
end
|
13
|
+
|
23
14
|
dates = Array.wrap(meta.fetch("dates", nil)).map do |d|
|
24
15
|
{ "date" => d["date"],
|
25
|
-
"
|
26
|
-
"
|
16
|
+
"dateType" => d["dateType"],
|
17
|
+
"dateInformation" => d["dateInformation"] }.compact
|
27
18
|
end
|
28
|
-
dates << { "date" => meta.fetch("
|
29
|
-
|
19
|
+
dates << { "date" => meta.fetch("publicationYear", nil), "dateType" => "Issued" } if meta.fetch("publicationYear", nil).present? && get_date(dates, "Issued").blank?
|
20
|
+
schema_org = meta.dig("types", "type") || Bolognese::Utils::CR_TO_SO_TRANSLATIONS[meta.dig("types", "resourceType").to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_SO_TRANSLATIONS[meta.dig("types", "resourceTypeGeneral").to_s.dasherize] || "CreativeWork"
|
30
21
|
types = {
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"bibtex" => meta.dig("types", "bibtex") || Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[meta.dig("types", "
|
35
|
-
"citeproc" => meta.dig("types", "citeproc") || Bolognese::Utils::CR_TO_CP_TRANSLATIONS[meta.dig("types", "
|
36
|
-
"ris" => meta.dig("types", "ris") || Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[meta.dig("types", "
|
22
|
+
"resourceTypeGeneral" => meta.dig("types", "resourceTypeGeneral"),
|
23
|
+
"resourceType" => meta.dig("types", "resourceType"),
|
24
|
+
"schemaOrg" => schema_org,
|
25
|
+
"bibtex" => meta.dig("types", "bibtex") || Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[meta.dig("types", "resourceType").to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[schema_org] || "misc",
|
26
|
+
"citeproc" => meta.dig("types", "citeproc") || Bolognese::Utils::CR_TO_CP_TRANSLATIONS[meta.dig("types", "resourceType").to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_CP_TRANSLATIONS[schema_org] || "article",
|
27
|
+
"ris" => meta.dig("types", "ris") || Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[meta.dig("types", "resourceType").to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_RIS_TRANSLATIONS[meta.dig("types", "resourceTypeGeneral").to_s.dasherize] || "GEN" }.compact
|
37
28
|
|
38
29
|
{ "id" => meta.fetch("id", nil),
|
39
30
|
"types" => types,
|
40
31
|
"doi" => validate_doi(meta.fetch("doi", nil)),
|
41
32
|
"url" => normalize_id(meta.fetch("url", nil)),
|
42
33
|
"titles" => meta.fetch("titles", nil),
|
43
|
-
"alternate_identifiers" =>
|
34
|
+
"alternate_identifiers" => Array.wrap(meta.fetch("alternateIdentifiers", nil)),
|
44
35
|
"creator" => meta.fetch("creator", nil),
|
45
36
|
"contributor" => meta.fetch("contributor", nil),
|
46
37
|
"publisher" => meta.fetch("publisher", nil),
|
47
38
|
"periodical" => meta.fetch("periodical", nil),
|
48
|
-
"
|
49
|
-
"funding_references" => meta.fetch("
|
50
|
-
"related_identifiers" =>
|
39
|
+
"source" => "DataCite",
|
40
|
+
"funding_references" => meta.fetch("fundingReferences", nil),
|
41
|
+
"related_identifiers" => Array.wrap(meta.fetch("relatedIdentifiers", nil)),
|
51
42
|
"dates" => dates,
|
52
|
-
"publication_year" => meta.fetch("
|
43
|
+
"publication_year" => meta.fetch("publicationYear", nil),
|
53
44
|
"descriptions" => meta.fetch("descriptions", nil),
|
54
|
-
"rights_list" => meta.fetch("
|
45
|
+
"rights_list" => meta.fetch("rightsList", nil),
|
55
46
|
"version" => meta.fetch("version", nil),
|
56
47
|
"subjects" => meta.fetch("subjects", nil),
|
57
48
|
"language" => meta.fetch("language", nil),
|
58
49
|
"sizes" => meta.fetch("sizes", nil),
|
59
50
|
"formats" => meta.fetch("formats", nil),
|
60
|
-
"geo_locations" => meta.fetch("
|
61
|
-
"schema_version" => meta.fetch("
|
51
|
+
"geo_locations" => meta.fetch("geoLocations", nil),
|
52
|
+
"schema_version" => meta.fetch("schemaVersion", nil),
|
62
53
|
"state" => state
|
63
54
|
}
|
64
55
|
end
|
@@ -74,13 +74,13 @@ module Bolognese
|
|
74
74
|
|
75
75
|
resource_type_general = meta.dig("resourceType", "resourceTypeGeneral")
|
76
76
|
resource_type = meta.dig("resourceType", "__content__")
|
77
|
-
|
77
|
+
schema_org = Bolognese::Utils::CR_TO_SO_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
|
78
78
|
types = {
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"
|
82
|
-
"citeproc" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_CP_TRANSLATIONS[
|
83
|
-
"bibtex" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[
|
79
|
+
"resourceTypeGeneral" => resource_type_general,
|
80
|
+
"resourceType" => resource_type,
|
81
|
+
"schemaOrg" => schema_org,
|
82
|
+
"citeproc" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_CP_TRANSLATIONS[schema_org] || "article",
|
83
|
+
"bibtex" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[schema_org] || "misc",
|
84
84
|
"ris" => Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
85
85
|
}.compact
|
86
86
|
|
@@ -88,18 +88,18 @@ module Bolognese
|
|
88
88
|
if r.is_a?(String)
|
89
89
|
{ "title" => sanitize(r) }
|
90
90
|
else
|
91
|
-
{ "title" => sanitize(r["__content__"]), "
|
91
|
+
{ "title" => sanitize(r["__content__"]), "titleType" => r["titleType"], "lang" => r["lang"] }.compact
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
alternate_identifiers = Array.wrap(meta.dig("alternateIdentifiers", "alternateIdentifier")).map do |r|
|
96
|
-
{ "
|
96
|
+
{ "alternateIdentifierType" => r["alternateIdentifierType"], "alternateIdentifier" => r["__content__"] }
|
97
97
|
end
|
98
98
|
descriptions = Array.wrap(meta.dig("descriptions", "description")).select { |r| r["descriptionType"] != "SeriesInformation" }.map do |r|
|
99
|
-
{ "description" => sanitize(r["__content__"]), "
|
99
|
+
{ "description" => sanitize(r["__content__"]), "descriptionType" => r["descriptionType"], "lang" => r["lang"] }.compact
|
100
100
|
end
|
101
101
|
rights_list = Array.wrap(meta.dig("rightsList", "rights")).map do |r|
|
102
|
-
{ "rights" => r["__content__"], "
|
102
|
+
{ "rights" => r["__content__"], "rightsUri" => normalize_url(r["rightsURI"]), "lang" => r["lang"] }.compact
|
103
103
|
end
|
104
104
|
subjects = Array.wrap(meta.dig("subjects", "subject")).map do |k|
|
105
105
|
if k.nil?
|
@@ -107,27 +107,27 @@ module Bolognese
|
|
107
107
|
elsif k.is_a?(String)
|
108
108
|
{ "subject" => sanitize(k) }
|
109
109
|
else
|
110
|
-
{ "subject" => sanitize(k["__content__"]), "
|
110
|
+
{ "subject" => sanitize(k["__content__"]), "subjectScheme" => k["subjectScheme"], "schemeUri" => k["schemeURI"], "valueUri" => k["valueURI"], "lang" => k["lang"] }.compact
|
111
111
|
end
|
112
112
|
end.compact
|
113
113
|
dates = Array.wrap(meta.dig("dates", "date")).map do |d|
|
114
114
|
{
|
115
115
|
"date" => parse_attributes(d),
|
116
|
-
"
|
117
|
-
"
|
116
|
+
"dateType" => parse_attributes(d, content: "dateType"),
|
117
|
+
"dateInformation" => parse_attributes(d, content: "dateInformation")
|
118
118
|
}.compact
|
119
119
|
end
|
120
|
-
dates << { "date" => meta.fetch("publicationYear", nil), "
|
120
|
+
dates << { "date" => meta.fetch("publicationYear", nil), "dateType" => "Issued" } if meta.fetch("publicationYear", nil).present? && get_date(dates, "Issued").blank?
|
121
121
|
sizes = Array.wrap(meta.dig("sizes", "size"))
|
122
122
|
formats = Array.wrap(meta.dig("formats", "format"))
|
123
123
|
funding_references = Array.wrap(meta.dig("fundingReferences", "fundingReference")).compact.map do |fr|
|
124
124
|
{
|
125
|
-
"
|
126
|
-
"
|
127
|
-
"
|
128
|
-
"
|
129
|
-
"
|
130
|
-
"
|
125
|
+
"funderName" => fr["funderName"],
|
126
|
+
"funderIdentifier" => normalize_id(parse_attributes(fr["funderIdentifier"])),
|
127
|
+
"funderIdentifierType" => parse_attributes(fr["funderIdentifier"], content: "funderIdentifierType"),
|
128
|
+
"awardNumber" => parse_attributes(fr["awardNumber"]),
|
129
|
+
"awardUri" => parse_attributes(fr["awardNumber"], content: "awardURI"),
|
130
|
+
"awardTitle" => fr["awardTitle"] }.compact
|
131
131
|
end
|
132
132
|
related_identifiers = Array.wrap(meta.dig("relatedIdentifiers", "relatedIdentifier")).map do |ri|
|
133
133
|
if ri["relatedIdentifierType"] == "DOI"
|
@@ -137,13 +137,13 @@ module Bolognese
|
|
137
137
|
end
|
138
138
|
|
139
139
|
{
|
140
|
-
"
|
141
|
-
"
|
142
|
-
"
|
143
|
-
"
|
144
|
-
"
|
145
|
-
"
|
146
|
-
"
|
140
|
+
"relatedIdentifier" => rid,
|
141
|
+
"relatedIdentifierType" => ri["relatedIdentifierType"],
|
142
|
+
"relationType" => ri["relationType"],
|
143
|
+
"resourceTypeGeneral" => ri["resourceTypeGeneral"],
|
144
|
+
"relatedMetadataScheme" => ri["relatedMetadataScheme"],
|
145
|
+
"schemeUri" => ri["schemeURI"],
|
146
|
+
"schemeType" => ri["schemeType"]
|
147
147
|
}.compact
|
148
148
|
end
|
149
149
|
geo_locations = Array.wrap(meta.dig("geoLocations", "geoLocation")).map do |gl|
|
@@ -151,17 +151,17 @@ module Bolognese
|
|
151
151
|
nil
|
152
152
|
else
|
153
153
|
{
|
154
|
-
"
|
155
|
-
"
|
156
|
-
"
|
154
|
+
"geoLocationPoint" => {
|
155
|
+
"pointLatitude" => gl.dig("geoLocationPoint", "pointLatitude"),
|
156
|
+
"pointLongitude" => gl.dig("geoLocationPoint", "pointLongitude")
|
157
157
|
}.compact.presence,
|
158
|
-
"
|
159
|
-
"
|
160
|
-
"
|
161
|
-
"
|
162
|
-
"
|
158
|
+
"geoLocationBox" => {
|
159
|
+
"westBoundLongitude" => gl.dig("geoLocationBox", "westBoundLongitude"),
|
160
|
+
"eastBoundLongitude" => gl.dig("geoLocationBox", "eastBoundLongitude"),
|
161
|
+
"southBoundLatitude" => gl.dig("geoLocationBox", "southBoundLatitude"),
|
162
|
+
"northBoundLatitude" => gl.dig("geoLocationBox", "northBoundLatitude")
|
163
163
|
}.compact.presence,
|
164
|
-
"
|
164
|
+
"geoLocationPlace" => gl["geoLocationPlace"],
|
165
165
|
}.compact
|
166
166
|
end
|
167
167
|
end
|
@@ -178,7 +178,7 @@ module Bolognese
|
|
178
178
|
"contributor" => get_authors(Array.wrap(meta.dig("contributors", "contributor"))),
|
179
179
|
"periodical" => periodical,
|
180
180
|
"publisher" => meta.fetch("publisher", "").strip.presence,
|
181
|
-
"
|
181
|
+
"source" => "DataCite",
|
182
182
|
"funding_references" => funding_references,
|
183
183
|
"dates" => dates,
|
184
184
|
"publication_year" => meta.fetch("publicationYear", nil),
|
@@ -37,11 +37,11 @@ module Bolognese
|
|
37
37
|
meta = ris_meta(string: string)
|
38
38
|
|
39
39
|
ris_type = meta.fetch("TY", nil) || "GEN"
|
40
|
-
|
40
|
+
schema_org = RIS_TO_SO_TRANSLATIONS[ris_type] || "CreativeWork"
|
41
41
|
types = {
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"citeproc" => RIS_TO_CP_TRANSLATIONS[
|
42
|
+
"resourceTypeGeneral" => Metadata::SO_TO_DC_TRANSLATIONS[schema_org],
|
43
|
+
"schemaOrg" => schema_org,
|
44
|
+
"citeproc" => RIS_TO_CP_TRANSLATIONS[schema_org] || "misc",
|
45
45
|
"ris" => ris_type
|
46
46
|
}.compact
|
47
47
|
|
@@ -50,14 +50,14 @@ module Bolognese
|
|
50
50
|
date_parts = meta.fetch("PY", nil).to_s.split("/")
|
51
51
|
created_date_parts = meta.fetch("Y1", nil).to_s.split("/")
|
52
52
|
dates = []
|
53
|
-
dates << { "date" => get_date_from_parts(*date_parts), "
|
54
|
-
dates << { "date" => get_date_from_parts(*created_date_parts), "
|
53
|
+
dates << { "date" => get_date_from_parts(*date_parts), "dateType" => "Issued" } if meta.fetch("PY", nil).present?
|
54
|
+
dates << { "date" => get_date_from_parts(*created_date_parts), "dateType" => "Created" } if meta.fetch("Y1", nil).present?
|
55
55
|
publication_year = get_date_from_parts(*date_parts).to_s[0..3]
|
56
56
|
related_identifiers = if meta.fetch("T2", nil).present? && meta.fetch("SN", nil).present?
|
57
57
|
[{ "type" => "Periodical",
|
58
58
|
"id" => meta.fetch("SN", nil),
|
59
|
-
"
|
60
|
-
"
|
59
|
+
"relatedIdentifierType" => "ISSN",
|
60
|
+
"relationType" => "IsPartOf",
|
61
61
|
"title" => meta.fetch("T2", nil), }.compact]
|
62
62
|
else
|
63
63
|
[]
|
@@ -85,7 +85,7 @@ module Bolognese
|
|
85
85
|
"related_identifiers" => related_identifiers,
|
86
86
|
"dates" => dates,
|
87
87
|
"publication_year" => publication_year,
|
88
|
-
"descriptions" => meta.fetch("AB", nil).present? ? [{ "description" => sanitize(meta.fetch("AB")) }] : nil,
|
88
|
+
"descriptions" => meta.fetch("AB", nil).present? ? [{ "description" => sanitize(meta.fetch("AB")), "descriptionType" => "Abstract" }] : nil,
|
89
89
|
"volume" => meta.fetch("VL", nil),
|
90
90
|
"issue" => meta.fetch("IS", nil),
|
91
91
|
"first_page" => meta.fetch("SP", nil),
|
@@ -39,9 +39,9 @@ module Bolognese
|
|
39
39
|
if identifier.length > 1
|
40
40
|
alternate_identifiers = identifier[1..-1].map do |r|
|
41
41
|
if r.is_a?(String)
|
42
|
-
{ "
|
42
|
+
{ "alternateIdentifierType" => "URL", "alternateIdentifier" => r }
|
43
43
|
elsif r.is_a?(Hash)
|
44
|
-
{ "
|
44
|
+
{ "alternateIdentifierType" => r["propertyID"], "alternateIdentifier" => r["value"] }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
else
|
@@ -50,14 +50,14 @@ module Bolognese
|
|
50
50
|
identifier = identifier.first
|
51
51
|
|
52
52
|
id = normalize_id(meta.fetch("@id", nil) || meta.fetch("identifier", nil))
|
53
|
-
|
54
|
-
resource_type_general = Bolognese::Utils::SO_TO_DC_TRANSLATIONS[
|
53
|
+
schema_org = meta.fetch("@type", nil) && meta.fetch("@type").camelcase
|
54
|
+
resource_type_general = Bolognese::Utils::SO_TO_DC_TRANSLATIONS[schema_org]
|
55
55
|
types = {
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"citeproc" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[
|
60
|
-
"bibtex" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[
|
56
|
+
"resourceTypeGeneral" => resource_type_general,
|
57
|
+
"resourceType" => meta.fetch("additionalType", nil),
|
58
|
+
"schemaOrg" => schema_org,
|
59
|
+
"citeproc" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[schema_org] || "article-journal",
|
60
|
+
"bibtex" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[schema_org] || "misc",
|
61
61
|
"ris" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
62
62
|
}.compact
|
63
63
|
authors = meta.fetch("author", nil) || meta.fetch("creator", nil)
|
@@ -65,10 +65,10 @@ module Bolognese
|
|
65
65
|
contributor = get_authors(from_schema_org(Array.wrap(meta.fetch("editor", nil))))
|
66
66
|
publisher = parse_attributes(meta.fetch("publisher", nil), content: "name", first: true)
|
67
67
|
|
68
|
-
ct = (
|
68
|
+
ct = (schema_org == "Dataset") ? "includedInDataCatalog" : "Periodical"
|
69
69
|
periodical = if meta.fetch(ct, nil).present?
|
70
70
|
{
|
71
|
-
"type" => (
|
71
|
+
"type" => (schema_org == "Dataset") ? "DataCatalog" : "Periodical",
|
72
72
|
"title" => parse_attributes(from_schema_org(meta.fetch(ct, nil)), content: "name", first: true),
|
73
73
|
"url" => parse_attributes(from_schema_org(meta.fetch(ct, nil)), content: "url", first: true)
|
74
74
|
}.compact
|
@@ -86,21 +86,26 @@ module Bolognese
|
|
86
86
|
Array.wrap(schema_org_is_supplement_to(meta)) +
|
87
87
|
Array.wrap(schema_org_is_supplemented_by(meta))
|
88
88
|
|
89
|
-
|
90
|
-
"
|
91
|
-
"
|
89
|
+
rights_list = {
|
90
|
+
"rightsUri" => parse_attributes(meta.fetch("license", nil), content: "id", first: true),
|
91
|
+
"rights" => parse_attributes(meta.fetch("license", nil), content: "name", first: true)
|
92
92
|
}
|
93
93
|
|
94
94
|
funding_references = Array.wrap(meta.fetch("funder", nil)).compact.map do |fr|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
if fr["@id"].present?
|
96
|
+
{
|
97
|
+
"funderName" => fr["name"],
|
98
|
+
"funderIdentifier" => fr["@id"],
|
99
|
+
"funderIdentifierType" => fr["@id"].to_s.start_with?("https://doi.org/10.13039") ? "Crossref Funder ID" : "Other" }.compact
|
100
|
+
else
|
101
|
+
{
|
102
|
+
"funderName" => fr["name"] }.compact
|
103
|
+
end
|
99
104
|
end
|
100
105
|
dates = []
|
101
|
-
dates << { "date" => meta.fetch("datePublished"), "
|
102
|
-
dates << { "date" => meta.fetch("dateCreated"), "
|
103
|
-
dates << { "date" => meta.fetch("dateModified"), "
|
106
|
+
dates << { "date" => meta.fetch("datePublished"), "dateType" => "Issued" } if meta.fetch("datePublished", nil).present?
|
107
|
+
dates << { "date" => meta.fetch("dateCreated"), "dateType" => "Created" } if meta.fetch("dateCreated", nil).present?
|
108
|
+
dates << { "date" => meta.fetch("dateModified"), "dateType" => "Updated" } if meta.fetch("dateModified", nil).present?
|
104
109
|
publication_year = meta.fetch("datePublished")[0..3] if meta.fetch("datePublished", nil).present?
|
105
110
|
|
106
111
|
state = meta.present? ? "findable" : "not_found"
|
@@ -108,20 +113,20 @@ module Bolognese
|
|
108
113
|
if gl.dig("geo", "box")
|
109
114
|
s, w, n, e = gl.dig("geo", "box").split(" ", 4)
|
110
115
|
geo_location_box = {
|
111
|
-
"
|
112
|
-
"
|
113
|
-
"
|
114
|
-
"
|
116
|
+
"westBoundLongitude" => w,
|
117
|
+
"eastBoundLongitude" => e,
|
118
|
+
"southBoundLatitude" => s,
|
119
|
+
"northBoundLatitude" => n
|
115
120
|
}.compact.presence
|
116
121
|
else
|
117
122
|
geo_location_box = nil
|
118
123
|
end
|
119
|
-
geo_location_point = { "
|
124
|
+
geo_location_point = { "pointLongitude" => gl.dig("geo", "longitude"), "pointLatitude" => gl.dig("geo", "latitude") }.compact.presence
|
120
125
|
|
121
126
|
{
|
122
|
-
"
|
123
|
-
"
|
124
|
-
"
|
127
|
+
"geoLocationPlace" => gl.dig("geo", "address"),
|
128
|
+
"geoLocationPoint" => geo_location_point,
|
129
|
+
"geoLocationBox" => geo_location_box
|
125
130
|
}.compact
|
126
131
|
end
|
127
132
|
subjects = Array.wrap(meta.fetch("keywords", nil).to_s.split(", ")).map do |s|
|
@@ -141,13 +146,13 @@ module Bolognese
|
|
141
146
|
"creator" => author,
|
142
147
|
"contributor" => contributor,
|
143
148
|
"publisher" => publisher,
|
144
|
-
"
|
149
|
+
"source" => parse_attributes(meta.fetch("provider", nil), content: "name", first: true),
|
145
150
|
"periodical" => periodical,
|
146
151
|
"related_identifiers" => related_identifiers,
|
147
152
|
"publication_year" => publication_year,
|
148
153
|
"dates" => dates,
|
149
|
-
"descriptions" => meta.fetch("description", nil).present? ? [{ "description" => sanitize(meta.fetch("description")) }] : nil,
|
150
|
-
"
|
154
|
+
"descriptions" => meta.fetch("description", nil).present? ? [{ "description" => sanitize(meta.fetch("description")), "descriptionType" => "Abstract" }] : nil,
|
155
|
+
"rights_list" => rights_list,
|
151
156
|
"version" => meta.fetch("version", nil),
|
152
157
|
"subjects" => subjects,
|
153
158
|
"state" => state,
|
data/lib/bolognese/utils.rb
CHANGED
@@ -362,7 +362,7 @@ module Bolognese
|
|
362
362
|
"schema_org"
|
363
363
|
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("@context") == ("https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld")
|
364
364
|
"codemeta"
|
365
|
-
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("
|
365
|
+
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("schemaVersion").to_s.start_with?("http://datacite.org/schema/kernel")
|
366
366
|
"datacite_json"
|
367
367
|
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("types")
|
368
368
|
"crosscite"
|
@@ -479,11 +479,10 @@ module Bolognese
|
|
479
479
|
related_identifier_type = doi_from_url(id).present? ? "DOI" : "URL"
|
480
480
|
id = doi_from_url(id) || id
|
481
481
|
|
482
|
-
{ "
|
483
|
-
"
|
484
|
-
"
|
485
|
-
"
|
486
|
-
"title" => idx["title"] || idx["name"] }.compact
|
482
|
+
{ "relatedIdentifier" => id,
|
483
|
+
"relationType" => relation_type,
|
484
|
+
"relatedIdentifierType" => related_identifier_type,
|
485
|
+
"resourceTypeGeneral" => Metadata::SO_TO_DC_TRANSLATIONS[idx["@type"]] }.compact
|
487
486
|
end.unwrap
|
488
487
|
end
|
489
488
|
|
@@ -547,7 +546,7 @@ module Bolognese
|
|
547
546
|
return nil unless (element.is_a?(Hash) || (element.nil? && options[:container_title].present?))
|
548
547
|
|
549
548
|
{
|
550
|
-
"@id" => element["
|
549
|
+
"@id" => element["relatedIdentifier"],
|
551
550
|
"@type" => (options[:type] == "Dataset") ? "DataCatalog" : "Periodical",
|
552
551
|
"name" => element["title"] || options[:container_title] }
|
553
552
|
end
|
@@ -560,13 +559,13 @@ module Bolognese
|
|
560
559
|
|
561
560
|
if options[:alternate_identifiers].present?
|
562
561
|
[ident] + Array.wrap(options[:alternate_identifiers]).map do |ai|
|
563
|
-
if ai["
|
564
|
-
ai["
|
562
|
+
if ai["alternateIdentifierType"].to_s.downcase == "url"
|
563
|
+
ai["alternateIdentifier"]
|
565
564
|
else
|
566
565
|
{
|
567
566
|
"@type" => "PropertyValue",
|
568
|
-
"propertyID" => ai["
|
569
|
-
"value" => ai["
|
567
|
+
"propertyID" => ai["alternateIdentifierType"],
|
568
|
+
"value" => ai["alternateIdentifier"] }
|
570
569
|
end
|
571
570
|
end
|
572
571
|
else
|
@@ -579,17 +578,15 @@ module Bolognese
|
|
579
578
|
|
580
579
|
relation_type = relation_type == "References" ? ["References", "Cites", "Documents"] : [relation_type]
|
581
580
|
|
582
|
-
Array.wrap(related_identifiers).select { |ri| relation_type.include?(ri["
|
583
|
-
if r["
|
581
|
+
Array.wrap(related_identifiers).select { |ri| relation_type.include?(ri["relationType"]) }.map do |r|
|
582
|
+
if r["relatedIdentifierType"] == "ISSN" && r["relationType"] == "IsPartOf"
|
584
583
|
{
|
585
584
|
"@type" => "Periodical",
|
586
|
-
"issn" => r["
|
587
|
-
"name" => r["title"] }.compact
|
585
|
+
"issn" => r["relatedIdentifier"] }.compact
|
588
586
|
else
|
589
587
|
{
|
590
|
-
"@id" => normalize_id(r["
|
591
|
-
"@type" => DC_TO_SO_TRANSLATIONS[r["
|
592
|
-
"name" => r["title"] }.compact
|
588
|
+
"@id" => normalize_id(r["relatedIdentifier"]),
|
589
|
+
"@type" => DC_TO_SO_TRANSLATIONS[r["resourceTypeGeneral"]] || "CreativeWork" }.compact
|
593
590
|
end
|
594
591
|
end.unwrap
|
595
592
|
end
|
@@ -599,9 +596,9 @@ module Bolognese
|
|
599
596
|
|
600
597
|
Array.wrap(funding_references).map do |fr|
|
601
598
|
{
|
602
|
-
"@id" => fr["
|
599
|
+
"@id" => fr["funderIdentifier"],
|
603
600
|
"@type" => "Organization",
|
604
|
-
"name" => fr["
|
601
|
+
"name" => fr["funderName"] }.compact
|
605
602
|
end.unwrap
|
606
603
|
end
|
607
604
|
|
@@ -609,26 +606,26 @@ module Bolognese
|
|
609
606
|
return nil unless geo_location.present?
|
610
607
|
|
611
608
|
Array.wrap(geo_location).map do |gl|
|
612
|
-
if gl.fetch("
|
609
|
+
if gl.fetch("geoLocationPoint", nil)
|
613
610
|
{
|
614
611
|
"@type" => "Place",
|
615
612
|
"geo" => {
|
616
613
|
"@type" => "GeoCoordinates",
|
617
|
-
"address" => gl["
|
618
|
-
"latitude" => gl.dig("
|
619
|
-
"longitude" => gl.dig("
|
614
|
+
"address" => gl["geoLocationPlace"],
|
615
|
+
"latitude" => gl.dig("geoLocationPoint", "pointLatitude"),
|
616
|
+
"longitude" => gl.dig("geoLocationPoint", "pointLongitude")
|
620
617
|
}.compact
|
621
618
|
}
|
622
|
-
elsif gl.fetch("
|
619
|
+
elsif gl.fetch("geoLocationBox", nil)
|
623
620
|
{
|
624
621
|
"@type" => "Place",
|
625
622
|
"geo" => {
|
626
623
|
"@type" => "GeoShape",
|
627
|
-
"address" => gl["
|
628
|
-
"box" => [gl.dig("
|
629
|
-
gl.dig("
|
630
|
-
gl.dig("
|
631
|
-
gl.dig("
|
624
|
+
"address" => gl["geoLocationPlace"],
|
625
|
+
"box" => [gl.dig("geoLocationBox", "southBoundLatitude"),
|
626
|
+
gl.dig("geoLocationBox", "westBoundLongitude"),
|
627
|
+
gl.dig("geoLocationBox", "northBoundLatitude"),
|
628
|
+
gl.dig("geoLocationBox", "eastBoundLongitude")].join(" ")
|
632
629
|
}.compact
|
633
630
|
}
|
634
631
|
end
|
@@ -658,8 +655,8 @@ module Bolognese
|
|
658
655
|
def to_identifier(identifier)
|
659
656
|
{
|
660
657
|
"@type" => "PropertyValue",
|
661
|
-
"propertyID" => identifier["
|
662
|
-
"value" => identifier["
|
658
|
+
"propertyID" => identifier["relatedIdentifierType"],
|
659
|
+
"value" => identifier["relatedIdentifier"] }
|
663
660
|
end
|
664
661
|
|
665
662
|
def from_citeproc(element)
|
@@ -813,12 +810,12 @@ module Bolognese
|
|
813
810
|
end
|
814
811
|
|
815
812
|
def get_date(dates, date_type)
|
816
|
-
dd = dates.find { |d| d["
|
813
|
+
dd = dates.find { |d| d["dateType"] == date_type } || {}
|
817
814
|
dd.fetch("date", nil)
|
818
815
|
end
|
819
816
|
|
820
817
|
def get_contributor(contributor, contributor_type)
|
821
|
-
contributor.select { |c| c["
|
818
|
+
contributor.select { |c| c["contributorType"] == contributor_type }
|
822
819
|
end
|
823
820
|
|
824
821
|
def jsonlint(json)
|