cocina-models 0.110.1 → 0.111.0
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 +9 -15
- data/cocina-models.gemspec +0 -1
- data/lib/cocina/models/mapping/from_mods/language_term.rb +1 -1
- data/lib/cocina/models/version.rb +1 -1
- data/lib/cocina/models.rb +0 -2
- metadata +2 -31
- data/lib/cocina/models/mapping/from_marc/access.rb +0 -50
- data/lib/cocina/models/mapping/from_marc/admin_metadata.rb +0 -77
- data/lib/cocina/models/mapping/from_marc/contributor.rb +0 -107
- data/lib/cocina/models/mapping/from_marc/description.rb +0 -38
- data/lib/cocina/models/mapping/from_marc/description_builder.rb +0 -58
- data/lib/cocina/models/mapping/from_marc/event.rb +0 -169
- data/lib/cocina/models/mapping/from_marc/form.rb +0 -135
- data/lib/cocina/models/mapping/from_marc/geographic.rb +0 -45
- data/lib/cocina/models/mapping/from_marc/identifier.rb +0 -101
- data/lib/cocina/models/mapping/from_marc/language.rb +0 -49
- data/lib/cocina/models/mapping/from_marc/marc_relators.rb +0 -321
- data/lib/cocina/models/mapping/from_marc/note.rb +0 -186
- data/lib/cocina/models/mapping/from_marc/related_resource.rb +0 -169
- data/lib/cocina/models/mapping/from_marc/title.rb +0 -132
- data/lib/cocina/models/mapping/from_marc/util.rb +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9413e8b89ec5fb07324b39abda8c6f972805fef2efa4f34f8033822d871805d9
|
|
4
|
+
data.tar.gz: 65e171f1d076c1d8b9d3663afd54d7f7824e01f3a34ac191620749294ca3346d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bbcac9101f211ca947e80c9e8c8ae0549cec2ecee1de138b0d0295525381590bfad717b72fa765fc37e94021b0c9e9ba2e6f65294a933ef7ade7ac64b58d035
|
|
7
|
+
data.tar.gz: 7f7581fe97bf77bc0ac1dce8fbb47fe9ee4689f6f03012b53618df6d891da4c04c4580b7cf141f356b218d6dfcacc4d27f317e059dbf53ed07fa27a6059a4df6
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cocina-models (0.
|
|
4
|
+
cocina-models (0.111.0)
|
|
5
5
|
activesupport
|
|
6
6
|
deprecation
|
|
7
7
|
dry-struct (~> 1.0)
|
|
@@ -11,7 +11,6 @@ PATH
|
|
|
11
11
|
i18n
|
|
12
12
|
json_schemer (~> 2.0)
|
|
13
13
|
jsonpath
|
|
14
|
-
marc (~> 1.3)
|
|
15
14
|
nokogiri
|
|
16
15
|
super_diff
|
|
17
16
|
thor
|
|
@@ -80,8 +79,9 @@ GEM
|
|
|
80
79
|
concurrent-ruby (~> 1.0)
|
|
81
80
|
ice_nine (0.11.2)
|
|
82
81
|
io-console (0.8.2)
|
|
83
|
-
irb (1.
|
|
82
|
+
irb (1.17.0)
|
|
84
83
|
pp (>= 0.6.0)
|
|
84
|
+
prism (>= 1.3.0)
|
|
85
85
|
rdoc (>= 4.0.0)
|
|
86
86
|
reline (>= 0.4.2)
|
|
87
87
|
json (2.18.1)
|
|
@@ -95,9 +95,6 @@ GEM
|
|
|
95
95
|
language_server-protocol (3.17.0.5)
|
|
96
96
|
lint_roller (1.1.0)
|
|
97
97
|
logger (1.7.0)
|
|
98
|
-
marc (1.4.0)
|
|
99
|
-
nokogiri (~> 1.0)
|
|
100
|
-
rexml
|
|
101
98
|
minitest (6.0.1)
|
|
102
99
|
prism (~> 1.5)
|
|
103
100
|
multi_json (1.19.1)
|
|
@@ -122,14 +119,13 @@ GEM
|
|
|
122
119
|
racc (1.8.1)
|
|
123
120
|
rainbow (3.1.1)
|
|
124
121
|
rake (13.3.1)
|
|
125
|
-
rdoc (7.
|
|
122
|
+
rdoc (7.2.0)
|
|
126
123
|
erb
|
|
127
124
|
psych (>= 4.0.0)
|
|
128
125
|
tsort
|
|
129
126
|
regexp_parser (2.11.3)
|
|
130
127
|
reline (0.6.3)
|
|
131
128
|
io-console (~> 0.5)
|
|
132
|
-
rexml (3.4.4)
|
|
133
129
|
rspec (3.13.2)
|
|
134
130
|
rspec-core (~> 3.13.0)
|
|
135
131
|
rspec-expectations (~> 3.13.0)
|
|
@@ -145,7 +141,7 @@ GEM
|
|
|
145
141
|
rspec-support (3.13.7)
|
|
146
142
|
rspec_junit_formatter (0.6.0)
|
|
147
143
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
148
|
-
rubocop (1.84.
|
|
144
|
+
rubocop (1.84.2)
|
|
149
145
|
json (~> 2.3)
|
|
150
146
|
language_server-protocol (~> 3.17.0.2)
|
|
151
147
|
lint_roller (~> 1.1.0)
|
|
@@ -211,7 +207,7 @@ CHECKSUMS
|
|
|
211
207
|
attr_extras (7.1.0) sha256=d96fc9a9dd5d85ba2d37762440a816f840093959ae26bb90da994c2d9f1fc827
|
|
212
208
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
213
209
|
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
|
|
214
|
-
cocina-models (0.
|
|
210
|
+
cocina-models (0.111.0)
|
|
215
211
|
concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
|
|
216
212
|
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
|
|
217
213
|
date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
|
|
@@ -232,14 +228,13 @@ CHECKSUMS
|
|
|
232
228
|
i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
|
|
233
229
|
ice_nine (0.11.2) sha256=5d506a7d2723d5592dc121b9928e4931742730131f22a1a37649df1c1e2e63db
|
|
234
230
|
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
|
|
235
|
-
irb (1.
|
|
231
|
+
irb (1.17.0) sha256=168c4ddb93d8a361a045c41d92b2952c7a118fa73f23fe14e55609eb7a863aae
|
|
236
232
|
json (2.18.1) sha256=fe112755501b8d0466b5ada6cf50c8c3f41e897fa128ac5d263ec09eedc9f986
|
|
237
233
|
json_schemer (2.5.0) sha256=2f01fb4cce721a4e08dd068fc2030cffd0702a7f333f1ea2be6e8991f00ae396
|
|
238
234
|
jsonpath (1.1.5) sha256=29f70467193a2dc93ab864ec3d3326d54267961acc623f487340eb9c34931dbe
|
|
239
235
|
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
240
236
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
241
237
|
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
242
|
-
marc (1.4.0) sha256=89f31a66c21f5a11e8fcf65fe06d207e121fb45ac6b23abef403f9ce912c7d10
|
|
243
238
|
minitest (6.0.1) sha256=7854c74f48e2e975969062833adc4013f249a4b212f5e7b9d5c040bf838d54bb
|
|
244
239
|
multi_json (1.19.1) sha256=7aefeff8f2c854bf739931a238e4aea64592845e0c0395c8a7d2eea7fdd631b7
|
|
245
240
|
nokogiri (1.19.0-arm64-darwin) sha256=0811dfd936d5f6dd3f6d32ef790568bf29b2b7bead9ba68866847b33c9cf5810
|
|
@@ -255,17 +250,16 @@ CHECKSUMS
|
|
|
255
250
|
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
256
251
|
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
257
252
|
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
|
|
258
|
-
rdoc (7.
|
|
253
|
+
rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
|
|
259
254
|
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
260
255
|
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
261
|
-
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
|
|
262
256
|
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
263
257
|
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
264
258
|
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
265
259
|
rspec-mocks (3.13.7) sha256=0979034e64b1d7a838aaaddf12bf065ea4dc40ef3d4c39f01f93ae2c66c62b1c
|
|
266
260
|
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
267
261
|
rspec_junit_formatter (0.6.0) sha256=40dde674e6ae4e6cc0ff560da25497677e34fefd2338cc467a8972f602b62b15
|
|
268
|
-
rubocop (1.84.
|
|
262
|
+
rubocop (1.84.2) sha256=5692cea54168f3dc8cb79a6fe95c5424b7ea893c707ad7a4307b0585e88dbf5f
|
|
269
263
|
rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
|
|
270
264
|
rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
|
|
271
265
|
rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
|
data/cocina-models.gemspec
CHANGED
|
@@ -33,7 +33,6 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.add_dependency 'i18n' # for validating BCP 47 language tags, according to RFC 4646
|
|
34
34
|
spec.add_dependency 'jsonpath' # used for date/time validation
|
|
35
35
|
spec.add_dependency 'json_schemer', '~> 2.0'
|
|
36
|
-
spec.add_dependency 'marc', '~> 1.3'
|
|
37
36
|
spec.add_dependency 'nokogiri'
|
|
38
37
|
spec.add_dependency 'super_diff'
|
|
39
38
|
spec.add_dependency 'thor'
|
data/lib/cocina/models.rb
CHANGED
|
@@ -10,7 +10,6 @@ require 'json_schemer'
|
|
|
10
10
|
require 'active_support'
|
|
11
11
|
require 'active_support/core_ext'
|
|
12
12
|
require 'thor'
|
|
13
|
-
require 'marc'
|
|
14
13
|
|
|
15
14
|
# Help Zeitwerk find some of our classes
|
|
16
15
|
class CocinaModelsInflector < Zeitwerk::Inflector
|
|
@@ -23,7 +22,6 @@ class CocinaModelsInflector < Zeitwerk::Inflector
|
|
|
23
22
|
'dro_structural' => 'DROStructural',
|
|
24
23
|
'dro_with_metadata' => 'DROWithMetadata',
|
|
25
24
|
'libraries_doi' => 'LibrariesDOI',
|
|
26
|
-
'marc_relators' => 'MARC_RELATORS',
|
|
27
25
|
'preregistered_repository_doi' => 'PreregisteredRepositoryDOI',
|
|
28
26
|
'repository_doi' => 'RepositoryDOI',
|
|
29
27
|
'request_dro' => 'RequestDRO',
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocina-models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.111.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Coyne
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-20 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -135,20 +135,6 @@ dependencies:
|
|
|
135
135
|
- - "~>"
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
137
|
version: '2.0'
|
|
138
|
-
- !ruby/object:Gem::Dependency
|
|
139
|
-
name: marc
|
|
140
|
-
requirement: !ruby/object:Gem::Requirement
|
|
141
|
-
requirements:
|
|
142
|
-
- - "~>"
|
|
143
|
-
- !ruby/object:Gem::Version
|
|
144
|
-
version: '1.3'
|
|
145
|
-
type: :runtime
|
|
146
|
-
prerelease: false
|
|
147
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
148
|
-
requirements:
|
|
149
|
-
- - "~>"
|
|
150
|
-
- !ruby/object:Gem::Version
|
|
151
|
-
version: '1.3'
|
|
152
138
|
- !ruby/object:Gem::Dependency
|
|
153
139
|
name: nokogiri
|
|
154
140
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -419,21 +405,6 @@ files:
|
|
|
419
405
|
- lib/cocina/models/location_based_download_access.rb
|
|
420
406
|
- lib/cocina/models/mapping/error_notifier.rb
|
|
421
407
|
- lib/cocina/models/mapping/escape_html.rb
|
|
422
|
-
- lib/cocina/models/mapping/from_marc/access.rb
|
|
423
|
-
- lib/cocina/models/mapping/from_marc/admin_metadata.rb
|
|
424
|
-
- lib/cocina/models/mapping/from_marc/contributor.rb
|
|
425
|
-
- lib/cocina/models/mapping/from_marc/description.rb
|
|
426
|
-
- lib/cocina/models/mapping/from_marc/description_builder.rb
|
|
427
|
-
- lib/cocina/models/mapping/from_marc/event.rb
|
|
428
|
-
- lib/cocina/models/mapping/from_marc/form.rb
|
|
429
|
-
- lib/cocina/models/mapping/from_marc/geographic.rb
|
|
430
|
-
- lib/cocina/models/mapping/from_marc/identifier.rb
|
|
431
|
-
- lib/cocina/models/mapping/from_marc/language.rb
|
|
432
|
-
- lib/cocina/models/mapping/from_marc/marc_relators.rb
|
|
433
|
-
- lib/cocina/models/mapping/from_marc/note.rb
|
|
434
|
-
- lib/cocina/models/mapping/from_marc/related_resource.rb
|
|
435
|
-
- lib/cocina/models/mapping/from_marc/title.rb
|
|
436
|
-
- lib/cocina/models/mapping/from_marc/util.rb
|
|
437
408
|
- lib/cocina/models/mapping/from_mods/access.rb
|
|
438
409
|
- lib/cocina/models/mapping/from_mods/admin_metadata.rb
|
|
439
410
|
- lib/cocina/models/mapping/from_mods/alt_rep_group.rb
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cocina
|
|
4
|
-
module Models
|
|
5
|
-
module Mapping
|
|
6
|
-
module FromMarc
|
|
7
|
-
# Maps Access to the cocina model
|
|
8
|
-
class Access
|
|
9
|
-
# @see #initialize
|
|
10
|
-
# @see #build
|
|
11
|
-
def self.build(...)
|
|
12
|
-
new(...).build
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# @param [MARC::Record] marc MARC record from FOLIO
|
|
16
|
-
def initialize(marc:)
|
|
17
|
-
@marc = marc
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# @return [Hash] a hash that can be mapped to a cocina model
|
|
21
|
-
def build
|
|
22
|
-
{ url:, physicalLocation: physical_location }.compact_blank
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def physical_location
|
|
28
|
-
field = marc['099']
|
|
29
|
-
return unless field
|
|
30
|
-
|
|
31
|
-
[{
|
|
32
|
-
value: field['a'],
|
|
33
|
-
type: 'shelf locator'
|
|
34
|
-
}]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def url
|
|
38
|
-
field = marc['856']
|
|
39
|
-
return unless field
|
|
40
|
-
|
|
41
|
-
notes = field.subfields.select { %(y z).include? it.code }.map { { value: it.value } }
|
|
42
|
-
[{ displayLabel: field['3'], value: field['u'], note: notes }.compact_blank]
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
attr_reader :marc
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cocina
|
|
4
|
-
module Models
|
|
5
|
-
module Mapping
|
|
6
|
-
module FromMarc
|
|
7
|
-
# Maps AdminMetadata to the cocina model
|
|
8
|
-
class AdminMetadata
|
|
9
|
-
# @see #initialize
|
|
10
|
-
# @see #build
|
|
11
|
-
def self.build(...)
|
|
12
|
-
new(...).build
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# @param [MARC::Record] marc MARC record from FOLIO
|
|
16
|
-
def initialize(marc:)
|
|
17
|
-
@marc = marc
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# @return [Hash] a hash that can be mapped to a cocina model
|
|
21
|
-
def build
|
|
22
|
-
{ contributor:, event:, identifier:, note: }.compact_blank
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def contributor
|
|
28
|
-
field = marc['040']
|
|
29
|
-
return unless field
|
|
30
|
-
|
|
31
|
-
[{
|
|
32
|
-
type: 'organization',
|
|
33
|
-
name: [{ code: field['a'], source: { code: 'marcorg' } }]
|
|
34
|
-
}]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def event
|
|
38
|
-
[creation, modification].compact
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def creation
|
|
42
|
-
field = marc['008']
|
|
43
|
-
return unless field
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
type: 'creation',
|
|
47
|
-
date: [{ value: field.value[0..5], encoding: { code: 'marc' } }]
|
|
48
|
-
}
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def modification
|
|
52
|
-
field = marc['005']
|
|
53
|
-
return unless field
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
type: 'modification',
|
|
57
|
-
date: [{ value: field.value[0..7], encoding: { code: 'iso8601' } }]
|
|
58
|
-
}
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def identifier
|
|
62
|
-
field = marc['001']
|
|
63
|
-
return unless field
|
|
64
|
-
|
|
65
|
-
[{ value: field.value, type: 'FOLIO' }]
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def note
|
|
69
|
-
[{ value: "Converted from MARC to Cocina #{Date.today.iso8601}", type: 'record origin' }]
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
attr_reader :marc
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cocina
|
|
4
|
-
module Models
|
|
5
|
-
module Mapping
|
|
6
|
-
module FromMarc
|
|
7
|
-
# Maps contributor information from MARC records to Cocina models.
|
|
8
|
-
class Contributor
|
|
9
|
-
# @see #initialize
|
|
10
|
-
# @see #build
|
|
11
|
-
def self.build(...)
|
|
12
|
-
new(...).build
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# @param [MARC::Record] marc MARC record from FOLIO
|
|
16
|
-
def initialize(marc:)
|
|
17
|
-
@marc = marc
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# @return [Array<Hash>] an array of contributor hashes
|
|
21
|
-
def build
|
|
22
|
-
linked_100_field = Util.linked_field(marc, marc['100']) if marc['100']
|
|
23
|
-
linked_700_field = Util.linked_field(marc, marc['700']) if marc['700']
|
|
24
|
-
|
|
25
|
-
[
|
|
26
|
-
build_personal(marc['100'], primary: true),
|
|
27
|
-
build_personal(linked_100_field),
|
|
28
|
-
build_corporate(marc['110'], primary: true),
|
|
29
|
-
build_event(marc['111'], primary: true),
|
|
30
|
-
build_personal(marc['700']),
|
|
31
|
-
build_personal(linked_700_field),
|
|
32
|
-
build_corporate(marc['710']),
|
|
33
|
-
build_event(marc['711']),
|
|
34
|
-
build_personal(marc['720'])
|
|
35
|
-
|
|
36
|
-
].compact
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
def build_personal(field, primary: false)
|
|
42
|
-
return unless field
|
|
43
|
-
|
|
44
|
-
name_type = case field.indicator1
|
|
45
|
-
when '1', '2'
|
|
46
|
-
'person'
|
|
47
|
-
when '3'
|
|
48
|
-
'family'
|
|
49
|
-
end
|
|
50
|
-
contributor = { type: name_type }.compact
|
|
51
|
-
contributor[:name] = [build_personal_name(field)]
|
|
52
|
-
contributor[:role] = build_roles(field)
|
|
53
|
-
id = build_id(field).first
|
|
54
|
-
contributor[:identifier] = [{ value: id.delete_prefix('https://orcid.org/'), type: 'ORCID' }.compact_blank] if id&.start_with? 'https://orcid.org/'
|
|
55
|
-
contributor[:status] = 'primary' if primary
|
|
56
|
-
contributor.compact_blank
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def build_personal_name(field)
|
|
60
|
-
return unless field
|
|
61
|
-
|
|
62
|
-
name = Util.strip_punctuation(field.subfields.select { |subfield| %w[a c q d].include? subfield.code }.map(&:value).join(' '))
|
|
63
|
-
{ value: name }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def build_id(field)
|
|
67
|
-
field.subfields.select { |subfield| %w[1].include? subfield.code }.map(&:value)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def build_roles(field, code: 'e')
|
|
71
|
-
expanded = field.subfields.select { |sf| sf.code == '4' }.map { |role| { value: MARC_RELATORS[role.value] }.compact_blank }
|
|
72
|
-
|
|
73
|
-
(field.subfields.select { |sf| sf.code == code }.map { |role| { value: role.value.sub(/.$/, '') } } +
|
|
74
|
-
expanded).uniq.compact_blank
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def build_corporate(field, primary: false)
|
|
78
|
-
return unless field
|
|
79
|
-
|
|
80
|
-
contributor = { type: 'organization' }
|
|
81
|
-
name = field.subfields.select { |subfield| %w[a b q d].include? subfield.code }.map(&:value).join(' ')
|
|
82
|
-
contributor[:name] = [{ value: name }]
|
|
83
|
-
id = build_id(field).first
|
|
84
|
-
contributor[:identifier] = [{ uri: id }] if id
|
|
85
|
-
|
|
86
|
-
contributor[:status] = 'primary' if primary
|
|
87
|
-
contributor
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def build_event(field, primary: false)
|
|
91
|
-
return unless field
|
|
92
|
-
|
|
93
|
-
contributor = { type: 'event' }
|
|
94
|
-
name = field.subfields.select { |subfield| %w[a n d c].include? subfield.code }.map(&:value).join(' ')
|
|
95
|
-
contributor[:name] = [{ value: name }]
|
|
96
|
-
roles = build_roles(field, code: 'j')
|
|
97
|
-
contributor[:role] = roles if roles.present?
|
|
98
|
-
contributor[:status] = 'primary' if primary
|
|
99
|
-
contributor
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
attr_reader :marc
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'marc'
|
|
4
|
-
|
|
5
|
-
module Cocina
|
|
6
|
-
module Models
|
|
7
|
-
module Mapping
|
|
8
|
-
module FromMarc
|
|
9
|
-
# Creates Cocina Description objects from MARC record
|
|
10
|
-
class Description
|
|
11
|
-
# @see #initialize
|
|
12
|
-
# @see #props
|
|
13
|
-
def self.props(...)
|
|
14
|
-
new(...).props
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @param [MARC::Record] marc MARC record from FOLIO
|
|
18
|
-
# @param [String] druid
|
|
19
|
-
# @param [Cocina::Models::Mapping::ErrorNotifier] notifier
|
|
20
|
-
def initialize(marc:, druid:, notifier: nil)
|
|
21
|
-
@marc = marc
|
|
22
|
-
@notifier = notifier || ErrorNotifier.new(druid:)
|
|
23
|
-
@purl = Cocina::Models::Mapping::Purl.for(druid:) if druid
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# @return [Hash] a hash that can be mapped to a Cocina Description model
|
|
27
|
-
def props
|
|
28
|
-
DescriptionBuilder.build(marc:, notifier:, purl:) if marc
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
attr_reader :marc, :notifier, :purl
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cocina
|
|
4
|
-
module Models
|
|
5
|
-
module Mapping
|
|
6
|
-
module FromMarc
|
|
7
|
-
# Creates Cocina Description objects from MARC records
|
|
8
|
-
class DescriptionBuilder
|
|
9
|
-
BUILDERS = {
|
|
10
|
-
# TODO: implement these builders for MARC
|
|
11
|
-
title: Title,
|
|
12
|
-
note: Note,
|
|
13
|
-
language: Language,
|
|
14
|
-
contributor: Contributor,
|
|
15
|
-
event: Event,
|
|
16
|
-
# subject: Subject,
|
|
17
|
-
form: Form,
|
|
18
|
-
identifier: Identifier,
|
|
19
|
-
adminMetadata: AdminMetadata,
|
|
20
|
-
relatedResource: RelatedResource,
|
|
21
|
-
geographic: Geographic,
|
|
22
|
-
access: Access
|
|
23
|
-
}.freeze
|
|
24
|
-
|
|
25
|
-
# @param [MARC::Record] marc MARC record from FOLIO
|
|
26
|
-
# @param [Cocina::Models::Mapping::ErrorNotifier] notifier
|
|
27
|
-
# @param [String] purl
|
|
28
|
-
# @return [Hash] a hash that can be mapped to a Cocina Description model
|
|
29
|
-
def self.build(marc:, notifier:, purl: nil)
|
|
30
|
-
new(notifier: notifier).build(marc: marc, purl: purl)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def initialize(notifier:)
|
|
34
|
-
@notifier = notifier
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# @return [Hash, nil] a hash that can be mapped to a Cocina Description model
|
|
38
|
-
def build(marc:, purl: nil)
|
|
39
|
-
BUILDERS.filter_map do |description_property, builder|
|
|
40
|
-
kwargs = { marc: }
|
|
41
|
-
has_notifier = builder.method(:build).parameters.map(&:second).include?(:notifier)
|
|
42
|
-
kwargs.merge!(notifier:) if has_notifier
|
|
43
|
-
|
|
44
|
-
result = builder.build(**kwargs)
|
|
45
|
-
break if result.nil? && has_notifier
|
|
46
|
-
|
|
47
|
-
{ description_property => result } if result.present?
|
|
48
|
-
end&.reduce({ purl: }, :merge)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
|
|
53
|
-
attr_reader :notifier
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|