Skip to content

Commit 7dc29da

Browse files
authored
Merge pull request #219 from datacite/metadata-47
Metadata 4.7 changes for bolognese
2 parents ff9ced4 + 25b92c2 commit 7dc29da

File tree

51 files changed

+3618
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3618
-26
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
source 'https://rubygems.org'
22

3-
gemspec
3+
gemspec

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
bolognese (2.5.0)
4+
bolognese (2.5.1)
55
activesupport (= 7.2.3)
66
benchmark_methods (~> 0.7)
77
bibtex-ruby (>= 5.1.0)

lib/bolognese/datacite_utils.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ def insert_related_identifiers(xml)
209209
attributes = {
210210
'relatedIdentifierType' => related_identifier["relatedIdentifierType"],
211211
'relationType' => related_identifier["relationType"],
212-
'resourceTypeGeneral' => related_identifier["resourceTypeGeneral"] }.compact
212+
'relationTypeInformation' => related_identifier["relationTypeInformation"],
213+
'resourceTypeGeneral' => related_identifier["resourceTypeGeneral",
214+
] }.compact
213215

214216
attributes.merge({ 'relatedMetadataScheme' => related_identifier["relatedMetadataSchema"],
215217
'schemeURI' => related_identifier["schemeUri"],
@@ -228,6 +230,7 @@ def insert_related_items(xml)
228230
attributes = {
229231
'relatedItemType' => related_item["relatedItemType"],
230232
'relationType' => related_item["relationType"],
233+
'relationTypeInformation' => related_item["relationTypeInformation"],
231234
}.compact
232235

233236
xml.relatedItem(related_item["relatedItem"], attributes) do

lib/bolognese/metadata.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# frozen_string_literal: true
1+
# frozen_string_literal: false
22

33
require_relative 'metadata_utils'
44

@@ -76,8 +76,8 @@ def initialize(options={})
7676
end
7777

7878
# make sure input is encoded as utf8
79-
string = string.force_encoding("UTF-8") if string.present?
80-
@string = string
79+
string1 = string.dup.force_encoding("UTF-8") if string.present?
80+
@string = string1
8181

8282
# input options for citation formatting
8383
@style = options[:style]
@@ -120,7 +120,7 @@ def initialize(options={})
120120

121121
@regenerate = options[:regenerate] || read_options.present?
122122
# generate name for method to call dynamically
123-
opts = { string: string, sandbox: options[:sandbox], doi: options[:doi], id: id, ra: ra }.merge(read_options)
123+
opts = { string: string1, sandbox: options[:sandbox], doi: options[:doi], id: id, ra: ra }.merge(read_options)
124124
@meta = @from.present? ? send("read_" + @from, **opts) : {}
125125
end
126126

lib/bolognese/readers/crossref_reader.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def read_crossref(string: nil, **options)
144144

145145
state = meta.present? || read_options.present? ? "findable" : "not_found"
146146

147-
related_identifiers = Array.wrap(crossref_is_part_of(journal_metadata)) + Array.wrap(crossref_references(bibliographic_metadata)) + Array.wrap(crossref_has_translation(program_metadata)) + Array.wrap(crossref_is_translation_of(program_metadata))
147+
related_identifiers = Array.wrap(crossref_is_part_of(journal_metadata)) + Array.wrap(crossref_references(bibliographic_metadata)) + Array.wrap(crossref_has_translation(program_metadata)) + Array.wrap(crossref_is_translation_of(program_metadata)) + Array.wrap(crossref_is_related_material(program_metadata))
148148

149149
container = if journal_metadata.present?
150150
issn = normalize_issn(journal_metadata.to_h.fetch("issn", nil))
@@ -395,6 +395,19 @@ def crossref_is_translation_of(program_metadata)
395395
end
396396
end.compact.unwrap
397397
end
398+
399+
def crossref_is_related_material(program_metadata)
400+
refs = program_metadata.dig("related_item") if program_metadata.is_a?(Hash)
401+
Array.wrap(refs).select { |a| a.dig("interwork_relation", "relationship_type") == "isRelatedMaterial" }.map do |c|
402+
if c.dig("inter_work_relation", "identifier_type") == "doi"
403+
{ "relatedIdentifier" => parse_attributes(c["inter_work_relation"]).downcase,
404+
"relationType" => "Other",
405+
"relatedIdentifierType" => "DOI" }.compact
406+
else
407+
nil
408+
end
409+
end.compact.unwrap
410+
end
398411
end
399412
end
400413
end

lib/bolognese/readers/datacite_reader.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def read_datacite(string: nil, **options)
206206
"resourceTypeGeneral" => ri["resourceTypeGeneral"],
207207
"relatedMetadataScheme" => ri["relatedMetadataScheme"],
208208
"schemeUri" => ri["schemeURI"],
209-
"schemeType" => ri["schemeType"]
209+
"schemeType" => ri["schemeType"],
210+
"relationTypeInformation" => ri["relationTypeInformation"]
210211
}.compact
211212
end
212213

@@ -226,7 +227,7 @@ def read_datacite(string: nil, **options)
226227
"relatedItemIdentifierType" => rii["relatedItemIdentifierType"],
227228
"relatedMetadataScheme" => rii["relatedMetadataScheme"],
228229
"schemeURI" => rii["schemeURI"],
229-
"schemeType" => rii["schemeType"]
230+
"schemeType" => rii["schemeType"],
230231
}.compact
231232
end
232233

@@ -241,6 +242,7 @@ def read_datacite(string: nil, **options)
241242

242243
a = {
243244
"relationType" => ri["relationType"],
245+
"relationTypeInformation" => ri["relationTypeInformation"],
244246
"relatedItemType" => ri["relatedItemType"],
245247
"relatedItemIdentifier" => relatedItemIdentifier,
246248
"creators" => get_authors(Array.wrap(ri.dig("creators", "creator"))),

lib/bolognese/utils.rb

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ class << self
6767
"OutputManagementPlan" => nil,
6868
"PeerReview" => "Review",
6969
"PhysicalObject" => nil,
70+
"Poster" => "Poster",
7071
"Preprint" => nil,
72+
"Presentation" => "PresentationDigitalDocument",
7173
"Report" => "Report",
7274
"Service" => "Service",
7375
"Software" => "SoftwareSourceCode",
@@ -103,7 +105,9 @@ class << self
103105
"OutputManagementPlan" => nil,
104106
"PeerReview" => "review",
105107
"PhysicalObject" => nil,
108+
"Poster" => "document",
106109
"Preprint" => nil,
110+
"Presentation" => "presentation",
107111
"Report" => "report",
108112
"Service" => nil,
109113
"Sound" => "song",
@@ -280,6 +284,8 @@ class << self
280284
"Event" => "Event",
281285
"ImageObject" => "Image",
282286
"Movie" => "Audiovisual",
287+
"Poster" => "Poster",
288+
"PresentationDigitalDocument" => "Presentation",
283289
"PublicationIssue" => "Text",
284290
"Report" => "Report",
285291
"ScholarlyArticle" => "Text",
@@ -326,6 +332,8 @@ class << self
326332
"Event" => nil,
327333
"ImageObject" => "graphic",
328334
"Movie" => "motion_picture",
335+
"Poster" => "document",
336+
"PresentationDigitalDocument" => "presentation",
329337
"PublicationIssue" => nil,
330338
"Report" => "report",
331339
"ScholarlyArticle" => "article-journal",
@@ -348,8 +356,10 @@ class << self
348356
"Event" => nil,
349357
"ImageObject" => "FIGURE",
350358
"Movie" => "MPCT",
351-
"Report" => "RPRT",
359+
"Poster" => "GEN",
360+
"PresentationDigitalDocument" => "SLIDE",
352361
"PublicationIssue" => nil,
362+
"Report" => "RPRT",
353363
"ScholarlyArticle" => "JOUR",
354364
"Service" => nil,
355365
"SoftwareSourceCode" => "COMP",
@@ -406,7 +416,9 @@ class << self
406416
"OutputManagementPlan" => nil,
407417
"PeerReview" => nil,
408418
"PhysicalObject" => nil,
419+
"Poster" => "GEN",
409420
"Preprint" => nil,
421+
"Presentation" => "SLIDE",
410422
"Report" => "RRPT",
411423
"Service" => nil,
412424
"Software" => "COMP",
@@ -419,7 +431,7 @@ class << self
419431

420432
RIS_TO_DC_TRANSLATIONS = {
421433
"BLOG" => "Text",
422-
"GEN" => "Text",
434+
"GEN" => "Poster",
423435
"CTLG" => "Collection",
424436
"DATA" => "Dataset",
425437
"FIGURE" => "Image",
@@ -428,7 +440,8 @@ class << self
428440
"JOUR" => "JournalArticle",
429441
"COMP" => "Software",
430442
"VIDEO" => "Audiovisual",
431-
"ELEC" => "Text"
443+
"ELEC" => "Text",
444+
"SLIDE" => "Presentation"
432445
}
433446

434447
BIB_TO_DC_TRANSLATIONS = {
@@ -452,7 +465,9 @@ class << self
452465
"motion_picture" => "Audiovisual",
453466
"article-journal" => "JournalArticle",
454467
"broadcast" => "Audiovisual",
455-
"webpage" => "Text"
468+
"webpage" => "Text",
469+
"document" => "Poster",
470+
"presentation" => "Presentation"
456471
}
457472

458473
SO_TO_BIB_TRANSLATIONS = {
@@ -468,6 +483,8 @@ class << self
468483
"Event" => "misc",
469484
"ImageObject" => "misc",
470485
"Movie" => "misc",
486+
"Poster" => "misc",
487+
"PresentationDigitalDocument" => "misc",
471488
"PublicationIssue" => "misc",
472489
"ScholarlyArticle" => "article",
473490
"Service" => "misc",

lib/bolognese/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Bolognese
2-
VERSION = "2.5.0"
2+
VERSION = "2.5.1"
33
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
3+
2013-05 v3.0: Addition of ID to simpleType element, added values "ResearchGroup" & "Other"
4+
2014-08-20 v3.1: Addition of value "DataCurator"
5+
2015-05-14 v4.0 dropped value "Funder", use new "funderReference"
6+
2024-12-05 v4.6: Addition of value "Translator" -->
7+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-4" targetNamespace="http://datacite.org/schema/kernel-4" elementFormDefault="qualified">
8+
<xs:simpleType name="contributorType" id="contributorType">
9+
<xs:annotation>
10+
<xs:documentation>The type of contributor of the resource.</xs:documentation>
11+
</xs:annotation>
12+
<xs:restriction base="xs:string">
13+
<xs:enumeration value="ContactPerson" />
14+
<xs:enumeration value="DataCollector" />
15+
<xs:enumeration value="DataCurator" />
16+
<xs:enumeration value="DataManager" />
17+
<xs:enumeration value="Distributor" />
18+
<xs:enumeration value="Editor" />
19+
<xs:enumeration value="HostingInstitution" />
20+
<xs:enumeration value="Other" />
21+
<xs:enumeration value="Producer" />
22+
<xs:enumeration value="ProjectLeader" />
23+
<xs:enumeration value="ProjectManager" />
24+
<xs:enumeration value="ProjectMember" />
25+
<xs:enumeration value="RegistrationAgency" />
26+
<xs:enumeration value="RegistrationAuthority" />
27+
<xs:enumeration value="RelatedPerson" />
28+
<xs:enumeration value="ResearchGroup" />
29+
<xs:enumeration value="RightsHolder" />
30+
<xs:enumeration value="Researcher" />
31+
<xs:enumeration value="Sponsor" />
32+
<xs:enumeration value="Supervisor" />
33+
<xs:enumeration value="Translator" />
34+
<xs:enumeration value="WorkPackageLeader" />
35+
</xs:restriction>
36+
</xs:simpleType>
37+
</xs:schema>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany
3+
2013-05 v3.0: Addition of ID to simpleType element; addition of value "Collected"; deleted "StartDate" & "EndDate"
4+
2017-10-23 v4.1: Addition of value "Other"
5+
2019-02-14 v4.2: Addition of value "Withdrawn"
6+
2024-12-05 v4.6: Addition of value "Coverage"-->
7+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-4" targetNamespace="http://datacite.org/schema/kernel-4" elementFormDefault="qualified">
8+
<xs:simpleType name="dateType" id="dateType">
9+
<xs:annotation>
10+
<xs:documentation>The type of date. Use RKMS‐ISO8601 standard for depicting date ranges.To indicate the end of an embargo period, use Available. To indicate the start of an embargo period, use Submitted or Accepted, as appropriate.</xs:documentation>
11+
</xs:annotation>
12+
<xs:restriction base="xs:string">
13+
<xs:enumeration value="Accepted" />
14+
<xs:enumeration value="Available" />
15+
<xs:enumeration value="Collected" />
16+
<xs:enumeration value="Copyrighted" />
17+
<xs:enumeration value="Coverage" />
18+
<xs:enumeration value="Created" />
19+
<xs:enumeration value="Issued" />
20+
<xs:enumeration value="Other" />
21+
<xs:enumeration value="Submitted" />
22+
<xs:enumeration value="Updated" />
23+
<xs:enumeration value="Valid" />
24+
<xs:enumeration value="Withdrawn" />
25+
</xs:restriction>
26+
</xs:simpleType>
27+
</xs:schema>

0 commit comments

Comments
 (0)