bolognese 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/bolognese/datacite_utils.rb +8 -9
  4. data/lib/bolognese/metadata.rb +7 -44
  5. data/lib/bolognese/metadata_utils.rb +2 -2
  6. data/lib/bolognese/readers/bibtex_reader.rb +18 -7
  7. data/lib/bolognese/readers/citeproc_reader.rb +26 -11
  8. data/lib/bolognese/readers/codemeta_reader.rb +17 -16
  9. data/lib/bolognese/readers/crossref_reader.rb +23 -15
  10. data/lib/bolognese/readers/datacite_json_reader.rb +19 -11
  11. data/lib/bolognese/readers/datacite_reader.rb +15 -15
  12. data/lib/bolognese/readers/ris_reader.rb +14 -8
  13. data/lib/bolognese/readers/schema_org_reader.rb +17 -11
  14. data/lib/bolognese/utils.rb +22 -5
  15. data/lib/bolognese/version.rb +1 -1
  16. data/lib/bolognese/writers/bibtex_writer.rb +1 -1
  17. data/lib/bolognese/writers/codemeta_writer.rb +3 -3
  18. data/lib/bolognese/writers/crosscite_writer.rb +3 -10
  19. data/lib/bolognese/writers/datacite_json_writer.rb +5 -8
  20. data/lib/bolognese/writers/jats_writer.rb +3 -3
  21. data/lib/bolognese/writers/ris_writer.rb +1 -1
  22. data/lib/bolognese/writers/schema_org_writer.rb +7 -7
  23. data/spec/datacite_utils_spec.rb +8 -7
  24. data/spec/fixtures/crosscite.json +13 -8
  25. data/spec/fixtures/datacite.json +8 -4
  26. data/spec/fixtures/datacite_software.json +0 -1
  27. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date/publication_date.yml +37 -0
  28. data/spec/readers/bibtex_reader_spec.rb +6 -10
  29. data/spec/readers/citeproc_reader_spec.rb +3 -3
  30. data/spec/readers/codemeta_reader_spec.rb +12 -16
  31. data/spec/readers/crosscite_reader_spec.rb +9 -8
  32. data/spec/readers/crossref_reader_spec.rb +27 -63
  33. data/spec/readers/datacite_json_reader_spec.rb +3 -4
  34. data/spec/readers/datacite_reader_spec.rb +156 -142
  35. data/spec/readers/ris_reader_spec.rb +6 -7
  36. data/spec/readers/schema_org_reader_spec.rb +26 -25
  37. data/spec/utils_spec.rb +8 -0
  38. data/spec/writers/bibtex_writer_spec.rb +1 -1
  39. data/spec/writers/citeproc_writer_spec.rb +1 -1
  40. data/spec/writers/crosscite_writer_spec.rb +6 -5
  41. data/spec/writers/datacite_writer_spec.rb +14 -17
  42. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acbbf45161f598000d9ff25bb9377c5332eb1482830a2e2b4137aab2fcc33043
4
- data.tar.gz: 3a6c992a04626c916ec2f579aad4f9ab303756071db6a8178499a996834416cd
3
+ metadata.gz: 101bd48af59219c102771f24b66e6b19d1be7a533cbdf4a1f1ce49919769be35
4
+ data.tar.gz: 2e1ec013d5ab433476452390f535c0bb675e611b4c8e0a94d13d6cb9984150f7
5
5
  SHA512:
6
- metadata.gz: 65dba0019f3401ae22dbd8d05da1cda01900ab0f865a3b37c8b4d7983e7d8616779e0ad7b7a123815eef252db8c5734982321bcf5cc2cc599e75a70dec436417
7
- data.tar.gz: d856dea89a299b900acd9462cf01b2cb1c88fe0d8619cd003b6f2fb4da4e54624e86bb580db50488c7d31a256c9fbede5802b185b126c253328c714bc3dd1191
6
+ metadata.gz: 92561676aae45f01727f68080a316343b8dc8eb4112562965504d571add5337024a882da16b6370e58c89b491c9bd82fb24a6e2bd161cdd67c5247073650b8a5
7
+ data.tar.gz: 490cadbec75e93b049b067ab6297aa5ffde7f9965c3d08e79a3752b39d1a913c268130c817a2d74d03a3c4ca5b5bae2470cb989fe823fbf2d095bd1716d92e1c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (1.0.2)
4
+ bolognese (1.0.3)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -93,12 +93,12 @@ module Bolognese
93
93
  end
94
94
 
95
95
  def res_type
96
- { "resource_type_general" => resource_type_general || Metadata::SO_TO_DC_TRANSLATIONS[type] || "Other",
97
- "__content__" => additional_type || type }
96
+ { "resource_type_general" => types["resource_type_general"] || Metadata::SO_TO_DC_TRANSLATIONS[types["type"]] || "Other",
97
+ "__content__" => types["resource_type"] || types["type"] }
98
98
  end
99
99
 
100
100
  def insert_resource_type(xml)
101
- return xml unless type.present?
101
+ return xml unless types["type"].present?
102
102
 
103
103
  xml.resourceType(res_type["__content__"],
104
104
  'resourceTypeGeneral' => res_type["resource_type_general"])
@@ -115,16 +115,15 @@ module Bolognese
115
115
  end
116
116
 
117
117
  def insert_dates(xml)
118
+ return xml unless Array.wrap(dates).present?
119
+
118
120
  xml.dates do
119
- insert_date(xml, date_published, 'Issued') if date_published.present?
120
- insert_date(xml, date_modified, 'Updated') if date_modified.present?
121
+ Array.wrap(dates).each do |date|
122
+ xml.date(date["date"], 'dateType' => date["date_type"] || "Issued")
123
+ end
121
124
  end
122
125
  end
123
126
 
124
- def insert_date(xml, date, date_type)
125
- xml.date(date, 'dateType' => date_type)
126
- end
127
-
128
127
  def insert_funding_references(xml)
129
128
  return xml unless Array.wrap(funding_references).present?
130
129
 
@@ -6,13 +6,12 @@ module Bolognese
6
6
  class Metadata
7
7
  include Bolognese::MetadataUtils
8
8
 
9
- attr_writer :id, :provider_id, :client_id, :doi, :identifier, :creator, :title, :publisher, :rights, :dates, :date_published, :date_modified,
10
- :date_updated, :journal, :volume, :first_page, :last_page, :url, :version, :resource_type_general,
9
+ attr_writer :id, :provider_id, :client_id, :doi, :identifier, :creator, :title, :publisher, :rights, :dates, :publication_year,
10
+ :volume, :first_page, :last_page, :url, :version,
11
11
  :keywords, :editor, :description, :alternate_identifiers, :language, :size,
12
- :formats, :schema_version, :resource_type_general, :meta, :periodical,
12
+ :formats, :schema_version, :meta, :periodical,
13
13
  :format, :funding_references, :style, :locale, :state, :geo_location,
14
- :type, :additional_type, :citeproc_type, :bibtex_type, :ris_type, :content_url, :related_identifiers
15
-
14
+ :types, :content_url, :related_identifiers
16
15
 
17
16
  def initialize(input: nil, from: nil, **options)
18
17
  id = normalize_id(input, options)
@@ -150,17 +149,13 @@ module Bolognese
150
149
  end
151
150
 
152
151
  def publication_year
153
- date_published.present? ? date_published[0..3].to_i.presence : nil
152
+ @publication_year ||= meta.fetch("publication_year", nil)
154
153
  end
155
154
 
156
155
  def periodical
157
156
  @periodical ||= meta.fetch("periodical", nil)
158
157
  end
159
158
 
160
- def descriptions
161
- Array.wrap(description)
162
- end
163
-
164
159
  def geo_location
165
160
  @geo_location ||= meta.fetch("geo_location", nil)
166
161
  end
@@ -189,28 +184,8 @@ module Bolognese
189
184
  @identifier ||= meta.fetch("id", nil)
190
185
  end
191
186
 
192
- def type
193
- @type ||= meta.fetch("type", nil)
194
- end
195
-
196
- def additional_type
197
- @additional_type ||= meta.fetch("additional_type", nil)
198
- end
199
-
200
- def citeproc_type
201
- @citeproc_type ||= meta.fetch("citeproc_type", nil)
202
- end
203
-
204
- def bibtex_type
205
- @bibtex_type ||= meta.fetch("bibtex_type", nil)
206
- end
207
-
208
- def ris_type
209
- @ris_type ||= meta.fetch("ris_type", nil)
210
- end
211
-
212
- def resource_type_general
213
- @resource_type_general ||= meta.fetch("resource_type_general", nil)
187
+ def types
188
+ @types ||= meta.fetch("types", nil)
214
189
  end
215
190
 
216
191
  def title
@@ -220,17 +195,5 @@ module Bolognese
220
195
  def creator
221
196
  @creator ||= meta.fetch("creator", nil)
222
197
  end
223
-
224
- def date_published
225
- @date_published ||= meta.fetch("date_published", nil)
226
- end
227
-
228
- def date_modified
229
- @date_modified ||= meta.fetch("date_modified", nil)
230
- end
231
-
232
- def date_updated
233
- @date_updated ||= meta.fetch("date_updated", nil)
234
- end
235
198
  end
236
199
  end
@@ -123,13 +123,13 @@ module Bolognese
123
123
 
124
124
  def citeproc_hsh
125
125
  {
126
- "type" => citeproc_type,
126
+ "type" => types["citeproc"],
127
127
  "id" => identifier,
128
128
  "categories" => Array.wrap(keywords).map { |k| parse_attributes(k, content: "text", first: true) }.presence,
129
129
  "language" => language,
130
130
  "author" => to_citeproc(creator),
131
131
  "editor" => to_citeproc(editor),
132
- "issued" => date_published ? get_date_parts(date_published) : nil,
132
+ "issued" => get_date(dates, "Issued") ? get_date_parts(get_date(dates, "Issued")) : nil,
133
133
  "submitted" => Array.wrap(dates).find { |d| d["type"] == "Submitted" }.to_h.fetch("__content__", nil),
134
134
  "abstract" => parse_attributes(description, content: "text", first: true),
135
135
  "container-title" => periodical && periodical["title"],
@@ -30,6 +30,14 @@ module Bolognese
30
30
  meta = string.present? ? BibTeX.parse(string).first : OpenStruct.new
31
31
 
32
32
  type = BIB_TO_SO_TRANSLATIONS[meta.try(:type).to_s] || "ScholarlyArticle"
33
+ types = {
34
+ "type" => type,
35
+ "resource_type_general" => Metadata::SO_TO_DC_TRANSLATIONS[type],
36
+ "resource_type" => Bolognese::Utils::BIB_TO_CR_TRANSLATIONS[meta.try(:type).to_s] || meta.try(:type).to_s,
37
+ "bibtex" => meta.type.to_s,
38
+ "citeproc" => BIB_TO_CP_TRANSLATIONS[meta.try(:type).to_s] || "misc",
39
+ "ris" => BIB_TO_RIS_TRANSLATIONS[meta.try(:type).to_s] || "GEN"
40
+ }.compact
33
41
  doi = meta.try(:doi).to_s.presence
34
42
 
35
43
  author = Array(meta.try(:author)).map do |a|
@@ -59,14 +67,16 @@ module Bolognese
59
67
 
60
68
  page_first, page_last = meta.try(:pages).to_s.split("-")
61
69
  state = doi.present? ? "findable" : "not_found"
70
+ dates = if meta.try(:date).present?
71
+ [{ "date" => meta.date.to_s,
72
+ "date_type" => "Issued" }]
73
+ else
74
+ nil
75
+ end
76
+ publication_year = meta.try(:date).present? ? meta.date.to_s[0..3] : nil
62
77
 
63
78
  { "id" => normalize_doi(doi),
64
- "type" => type,
65
- "bibtex_type" => meta.type.to_s,
66
- "citeproc_type" => BIB_TO_CP_TRANSLATIONS[meta.try(:type).to_s] || "misc",
67
- "ris_type" => BIB_TO_RIS_TRANSLATIONS[meta.try(:type).to_s] || "GEN",
68
- "resource_type_general" => Metadata::SO_TO_DC_TRANSLATIONS[type],
69
- "additional_type" => Bolognese::Utils::BIB_TO_CR_TRANSLATIONS[meta.try(:type).to_s] || meta.try(:type).to_s,
79
+ "types" => types,
70
80
  "doi" => doi,
71
81
  "url" => meta.try(:url).to_s,
72
82
  "title" => meta.try(:title).to_s,
@@ -74,7 +84,8 @@ module Bolognese
74
84
  "periodical" => periodical,
75
85
  "publisher" => meta.try(:publisher).to_s.presence,
76
86
  "related_identifiers" => related_identifiers,
77
- "date_published" => meta.try(:date).to_s.presence,
87
+ "dates" => dates,
88
+ "publication_year" => publication_year,
78
89
  "volume" => meta.try(:volume).to_s.presence,
79
90
  "page_first" => page_first,
80
91
  "page_last" => page_last,
@@ -35,10 +35,29 @@ module Bolognese
35
35
 
36
36
  citeproc_type = meta.fetch("type", nil)
37
37
  type = CP_TO_SO_TRANSLATIONS[citeproc_type] || "CreativeWork"
38
+ types = {
39
+ "type" => type,
40
+ "resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
41
+ "reource_type" => meta.fetch("additionalType", nil),
42
+ "citeproc" => citeproc_type,
43
+ "bibtex" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
44
+ "ris" => CP_TO_RIS_TRANSLATIONS[type] || "GEN"
45
+ }.compact
38
46
  doi = normalize_doi(meta.fetch("DOI", nil))
39
- author = get_authors(from_citeproc(Array.wrap(meta.fetch("author", nil))))
47
+ creator = get_authors(from_citeproc(Array.wrap(meta.fetch("author", nil))))
40
48
  editor = get_authors(from_citeproc(Array.wrap(meta.fetch("editor", nil))))
41
- date_published = get_date_from_date_parts(meta.fetch("issued", nil))
49
+ dates = if meta.fetch("issued", nil).present?
50
+ [{ "date" => get_date_from_date_parts(meta.fetch("issued", nil)),
51
+ "date_type" => "Issued" }]
52
+ else
53
+ nil
54
+ end
55
+ publication_year = get_date_from_date_parts(meta.fetch("issued", nil)).to_s[0..3]
56
+ rights = if meta.fetch("copyright", nil)
57
+ { "id" => normalize_url(meta.fetch("copyright")) }.compact
58
+ else
59
+ nil
60
+ end
42
61
  related_identifiers = if meta.fetch("container-title", nil).present? && meta.fetch("ISSN", nil).present?
43
62
  [{ "type" => "Periodical",
44
63
  "relation_type" => "IsPartOf",
@@ -59,24 +78,20 @@ module Bolognese
59
78
  state = id.present? ? "findable" : "not_found"
60
79
 
61
80
  { "id" => id,
62
- "type" => type,
63
- "additional_type" => meta.fetch("additionalType", nil),
64
- "citeproc_type" => citeproc_type,
65
- "bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
66
- "ris_type" => CP_TO_RIS_TRANSLATIONS[type] || "GEN",
67
- "resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
81
+ "types" => types,
68
82
  "doi" => doi_from_url(doi),
69
83
  "url" => normalize_id(meta.fetch("URL", nil)),
70
84
  "title" => meta.fetch("title", nil),
71
- "creator" => author,
85
+ "creator" => creator,
72
86
  "periodical" => periodical,
73
87
  "publisher" => meta.fetch("publisher", nil),
74
88
  "related_identifiers" => related_identifiers,
75
- "date_published" => date_published,
89
+ "dates" => dates,
90
+ "publication_year" => publication_year,
76
91
  "volume" => meta.fetch("volume", nil),
77
92
  #{}"pagination" => meta.pages.to_s.presence,
78
93
  "description" => meta.fetch("abstract", nil).present? ? { "text" => sanitize(meta.fetch("abstract")) } : nil,
79
- #{ }"rights" => { "id" => meta.field?(:copyright) && meta.copyright.to_s.presence },
94
+ "rights" => rights,
80
95
  "version" => meta.fetch("version", nil),
81
96
  "keywords" => meta.fetch("categories", nil),
82
97
  "state" => state
@@ -21,25 +21,27 @@ module Bolognese
21
21
  meta = string.present? ? Maremma.from_json(string) : {}
22
22
  identifier = meta.fetch("identifier", nil)
23
23
  id = normalize_id(meta.fetch("@id", nil) || identifier)
24
- type = meta.fetch("@type", nil)
25
24
  author = get_authors(from_schema_org(Array.wrap(meta.fetch("agents", nil))))
26
25
  editor = get_authors(from_schema_org(Array.wrap(meta.fetch("editor", nil))))
27
- date_published = meta.fetch("datePublished", nil)
26
+ dates = []
27
+ dates << { "date" => meta.fetch("datePublished"), "date_type" => "Issued" } if meta.fetch("datePublished", nil).present?
28
+ dates << { "date" => meta.fetch("dateCreated"), "date_type" => "Created" } if meta.fetch("dateCreated", nil).present?
29
+ dates << { "date" => meta.fetch("dateModified"), "date_type" => "Updated" } if meta.fetch("dateModified", nil).present?
30
+ publication_year = meta.fetch("datePublished")[0..3] if meta.fetch("datePublished", nil).present?
28
31
  publisher = meta.fetch("publisher", nil)
29
32
  state = meta.present? ? "findable" : "not_found"
30
- dates = [
31
- { "type" => "Issued", "__content__" => "date_published" },
32
- { "type" => "Updated", "__content__" => "date_modified" },
33
- { "type" => "Created", "__content__" => meta.fetch("datePublished", nil) }
34
- ]
35
-
36
- { "id" => id,
33
+ type = meta.fetch("@type", nil)
34
+ types = {
37
35
  "type" => type,
38
- "additional_type" => meta.fetch("additionalType", nil),
39
- "citeproc_type" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article-journal",
40
- "bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
41
- "ris_type" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[type] || "GEN",
42
36
  "resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
37
+ "resource_type" => meta.fetch("additionalType", nil),
38
+ "citeproc" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article-journal",
39
+ "bibtex" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
40
+ "ris" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[type] || "GEN"
41
+ }.compact
42
+
43
+ { "id" => id,
44
+ "types" => types,
43
45
  "identifier" => identifier,
44
46
  "doi" => validate_doi(id),
45
47
  "url" => normalize_id(meta.fetch("codeRepository", nil)),
@@ -48,9 +50,8 @@ module Bolognese
48
50
  "editor" => editor,
49
51
  "publisher" => publisher,
50
52
  #{}"is_part_of" => is_part_of,
51
- "dates" => meta.fetch("dateCreated", nil),
52
- "date_published" => date_published,
53
- "date_modified" => meta.fetch("dateModified", nil),
53
+ "dates" => dates,
54
+ "publication_year" => publication_year,
54
55
  "description" => meta.fetch("description", nil).present? ? { "text" => sanitize(meta.fetch("description")) } : nil,
55
56
  "rights" => { "id" => meta.fetch("license", nil) },
56
57
  "version" => meta.fetch("version", nil),
@@ -31,7 +31,7 @@ module Bolognese
31
31
  # report-paper, sa_component, standard
32
32
  model = meta.dig("crossref").to_h.keys.first
33
33
 
34
- additional_type = nil
34
+ resource_type = nil
35
35
  bibliographic_metadata = {}
36
36
  program_metadata = {}
37
37
  journal_metadata = nil
@@ -44,7 +44,7 @@ module Bolognese
44
44
  book_series_metadata = meta.dig("crossref", "book", "book_series_metadata")
45
45
  book_set_metadata = meta.dig("crossref", "book", "book_set_metadata")
46
46
  bibliographic_metadata = meta.dig("crossref", "book", "content_item").to_h
47
- additional_type = bibliographic_metadata.fetch("component_type", nil) ? "book-" + bibliographic_metadata.fetch("component_type") : "book"
47
+ resource_type = bibliographic_metadata.fetch("component_type", nil) ? "book-" + bibliographic_metadata.fetch("component_type") : "book"
48
48
  publisher = book_metadata.dig("publisher", "publisher_name")
49
49
  when "conference"
50
50
  event_metadata = meta.dig("crossref", "conference", "event_metadata") || {}
@@ -56,7 +56,7 @@ module Bolognese
56
56
  journal_issue = meta.dig("crossref", "journal", "journal_issue") || {}
57
57
  journal_article = meta.dig("crossref", "journal", "journal_article") || {}
58
58
 
59
- additional_type = if journal_article.present?
59
+ resource_type = if journal_article.present?
60
60
  "journal_article"
61
61
  elsif journal_issue.present?
62
62
  "journal_issue"
@@ -70,14 +70,27 @@ module Bolognese
70
70
  bibliographic_metadata = meta.dig("crossref", "sa_component", "component_list", "component").to_h
71
71
  end
72
72
 
73
- additional_type = (additional_type || model).to_s.underscore.camelize.presence
74
- type = Bolognese::Utils::CR_TO_SO_TRANSLATIONS[additional_type] || "ScholarlyArticle"
75
-
73
+ resource_type = (resource_type || model).to_s.underscore.camelize.presence
74
+ type = Bolognese::Utils::CR_TO_SO_TRANSLATIONS[resource_type] || "ScholarlyArticle"
75
+ types = {
76
+ "type" => type,
77
+ "resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
78
+ "resource_type" => resource_type,
79
+ "citeproc" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[resource_type] || "article-journal",
80
+ "bibtex" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[resource_type] || "misc",
81
+ "ris" => Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[resource_type] || "JOUR"
82
+ }.compact
76
83
  doi = bibliographic_metadata.dig("doi_data", "doi").to_s.downcase.presence #|| doi_from_url(options[:id])
77
84
 
78
85
  # Crossref servers run on Eastern Time
79
86
  Time.zone = 'Eastern Time (US & Canada)'
80
- date_modified = Time.zone.parse(meta.fetch("timestamp", "2018-01-01")).utc.iso8601
87
+ dates = [
88
+ { "date" => crossref_date_published(bibliographic_metadata),
89
+ "date_type" => "Issued" },
90
+ { "date" => Time.zone.parse(meta.fetch("timestamp", "2018-01-01")).utc.iso8601,
91
+ "date_type" => "Updated" }
92
+ ]
93
+ publication_year = crossref_date_published(bibliographic_metadata).present? ? crossref_date_published(bibliographic_metadata)[0..3] : nil
81
94
  state = meta.present? ? "findable" : "not_found"
82
95
 
83
96
  related_identifiers = Array.wrap(crossref_is_part_of(journal_metadata)) + Array.wrap(crossref_references(bibliographic_metadata))
@@ -90,12 +103,7 @@ module Bolognese
90
103
  end
91
104
 
92
105
  { "id" => normalize_doi(doi),
93
- "type" => type,
94
- "additional_type" => additional_type,
95
- "citeproc_type" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[additional_type] || "article-journal",
96
- "bibtex_type" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[additional_type] || "misc",
97
- "ris_type" => Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[additional_type] || "JOUR",
98
- "resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
106
+ "types" => types,
99
107
  "doi" => doi,
100
108
  "url" => bibliographic_metadata.dig("doi_data", "resource"),
101
109
  "title" => parse_attributes(bibliographic_metadata.dig("titles", "title")),
@@ -107,8 +115,8 @@ module Bolognese
107
115
  "periodical" => periodical,
108
116
  "service_provider" => "Crossref",
109
117
  "related_identifiers" => related_identifiers,
110
- "date_published" => crossref_date_published(bibliographic_metadata),
111
- "date_modified" => date_modified,
118
+ "dates" => dates,
119
+ "publication_year" => publication_year,
112
120
  "volume" => journal_issue.dig("journal_volume", "volume"),
113
121
  "issue" => journal_issue.dig("issue"),
114
122
  "first_page" => bibliographic_metadata.dig("pages", "first_page"),
@@ -9,8 +9,6 @@ module Bolognese
9
9
 
10
10
  meta = string.present? ? Maremma.from_json(string) : {}
11
11
 
12
- resource_type_general = meta.fetch("resource-type-general", nil)
13
- type = Bolognese::Utils::DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
14
12
  state = meta.fetch("doi", nil).present? ? "findable" : "not_found"
15
13
  related_identifiers = Array.wrap(meta.fetch("related-identifiers", nil)).map do |ri|
16
14
  { "id" => ri["id"],
@@ -18,14 +16,25 @@ module Bolognese
18
16
  "related_identifier_type" => ri["related-identifier-type"],
19
17
  "resource_type_general" => ri["resource-type-general"] }.compact
20
18
  end
21
-
22
- { "id" => meta.fetch("id", nil),
19
+ dates = Array.wrap(meta.fetch("dates", nil)).map do |d|
20
+ { "date" => d["date"],
21
+ "date_type" => d["date-type"] }.compact
22
+ end
23
+ dates << { "date" => meta.fetch("publication-year", nil), "date_type" => "Issued" } if meta.fetch("publication-year", nil).present? && get_date(dates, "Issued").blank?
24
+ resource_type_general = meta.fetch("resource-type-general", nil)
25
+ resource_type = meta.fetch("resource-type", nil)
26
+ type = 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"
27
+ types = {
23
28
  "type" => type,
24
- "additional_type" => meta.fetch("resource-type", nil),
25
- "citeproc_type" => Bolognese::Utils::DC_TO_CP_TRANSLATIONS[resource_type_general.to_s.dasherize] || "other",
26
- "bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
27
- "ris_type" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN",
28
29
  "resource_type_general" => resource_type_general,
30
+ "resource_type" => resource_type,
31
+ "citeproc" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article",
32
+ "bibtex" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
33
+ "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"
34
+ }.compact
35
+
36
+ { "id" => meta.fetch("id", nil),
37
+ "types" => types,
29
38
  "doi" => validate_doi(meta.fetch("doi", nil)),
30
39
  "url" => normalize_id(meta.fetch("url", nil)),
31
40
  "title" => meta.fetch("title", nil),
@@ -37,9 +46,8 @@ module Bolognese
37
46
  "service_provider" => "DataCite",
38
47
  "funding_references" => meta.fetch("funding-references", nil),
39
48
  "related_identifiers" => related_identifiers,
40
- "dates" => meta.fetch("dates", nil),
41
- "date_published" => meta.fetch("date-published", nil) || meta.fetch("publication-year", nil),
42
- "date_modified" => meta.fetch("date-modified", nil),
49
+ "dates" => dates,
50
+ "publication_year" => meta.fetch("publication-year", nil),
43
51
  "description" => meta.fetch("description", nil),
44
52
  "rights" => meta.fetch("rights", nil),
45
53
  "version" => meta.fetch("version", nil),