cocina-models 0.90.0 → 0.91.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/.circleci/config.yml +1 -1
- data/.rubocop.yml +49 -3
- data/.rubocop_todo.yml +3 -4
- data/Gemfile.lock +43 -35
- data/cocina-models.gemspec +1 -1
- data/lib/cocina/generator/generator.rb +7 -2
- data/lib/cocina/generator/schema.rb +9 -7
- data/lib/cocina/generator/schema_base.rb +4 -3
- data/lib/cocina/models/admin_policy_lite.rb +22 -0
- data/lib/cocina/models/collection_lite.rb +32 -0
- data/lib/cocina/models/dro_lite.rb +44 -0
- data/lib/cocina/models/mapping/from_mods/event.rb +2 -2
- data/lib/cocina/models/mapping/from_mods/geographic.rb +2 -1
- data/lib/cocina/models/mapping/from_mods/name_builder.rb +1 -1
- data/lib/cocina/models/version.rb +1 -1
- data/lib/cocina/models.rb +26 -0
- data/lib/cocina/rspec/factories.rb +15 -0
- metadata +8 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7ef9101cd3e5b9e42625b2afbc651919ba5f8e1617d5372324cb950a8f78b23
|
4
|
+
data.tar.gz: 433c3651004d4f32c380f0cee4b38887fe2ef3bc550436e326af299db01d12b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74cfeeb356d0fd34295010870f2e81c2ef08d9db3c3679ec1b22a8e6f6325bfb62058a23654c024d58a19a59a8b1dd73d611cfec749f2adce2aa6ac938f46c92
|
7
|
+
data.tar.gz: 906583af0a50b81f26f4c487b3288196f918d116f617c253ce10cc72564e7f459bb1ff422bc0af6def4d222571232fa4e1c52609be82e5226eb4d85f92f1c42c
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -298,7 +298,7 @@ RSpec/IdenticalEqualityAssertion: # new in 2.4
|
|
298
298
|
Enabled: true
|
299
299
|
RSpec/SubjectDeclaration: # new in 2.5
|
300
300
|
Enabled: true
|
301
|
-
|
301
|
+
FactoryBot/SyntaxMethods: # new in 2.7
|
302
302
|
Enabled: true
|
303
303
|
RSpec/Rails/AvoidSetupHook: # new in 2.4
|
304
304
|
Enabled: true
|
@@ -387,9 +387,9 @@ RSpec/PendingWithoutReason: # new in 2.16
|
|
387
387
|
Enabled: true
|
388
388
|
RSpec/SortMetadata: # new in 2.14
|
389
389
|
Enabled: true
|
390
|
-
|
390
|
+
FactoryBot/ConsistentParenthesesStyle: # new in 2.14
|
391
391
|
Enabled: true
|
392
|
-
|
392
|
+
FactoryBot/FactoryNameStyle: # new in 2.16
|
393
393
|
Enabled: true
|
394
394
|
RSpec/Rails/InferredSpecType: # new in 2.14
|
395
395
|
Enabled: true
|
@@ -410,3 +410,49 @@ RSpec/SkipBlockInsideExample: # new in 2.19
|
|
410
410
|
Enabled: true
|
411
411
|
RSpec/Rails/TravelAround: # new in 2.19
|
412
412
|
Enabled: true
|
413
|
+
|
414
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
415
|
+
Enabled: true
|
416
|
+
Style/DataInheritance: # new in 1.49
|
417
|
+
Enabled: true
|
418
|
+
Style/ExactRegexpMatch: # new in 1.51
|
419
|
+
Enabled: true
|
420
|
+
Style/RedundantArrayConstructor: # new in 1.52
|
421
|
+
Enabled: true
|
422
|
+
Style/RedundantFilterChain: # new in 1.52
|
423
|
+
Enabled: true
|
424
|
+
Style/RedundantLineContinuation: # new in 1.49
|
425
|
+
Enabled: true
|
426
|
+
Style/RedundantRegexpConstructor: # new in 1.52
|
427
|
+
Enabled: true
|
428
|
+
FactoryBot/AssociationStyle: # new in 2.23
|
429
|
+
Enabled: true
|
430
|
+
FactoryBot/FactoryAssociationWithStrategy: # new in 2.23
|
431
|
+
Enabled: true
|
432
|
+
FactoryBot/RedundantFactoryOption: # new in 2.23
|
433
|
+
Enabled: true
|
434
|
+
RSpec/BeEmpty: # new in 2.20
|
435
|
+
Enabled: true
|
436
|
+
RSpec/ContainExactly: # new in 2.19
|
437
|
+
Enabled: true
|
438
|
+
RSpec/IndexedLet: # new in 2.20
|
439
|
+
Enabled: true
|
440
|
+
RSpec/MatchArray: # new in 2.19
|
441
|
+
Enabled: true
|
442
|
+
|
443
|
+
Lint/MixedCaseRange: # new in 1.53
|
444
|
+
Enabled: true
|
445
|
+
Lint/RedundantRegexpQuantifiers: # new in 1.53
|
446
|
+
Enabled: true
|
447
|
+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
|
448
|
+
Enabled: true
|
449
|
+
Style/RedundantRegexpArgument: # new in 1.53
|
450
|
+
Enabled: true
|
451
|
+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
|
452
|
+
Enabled: true
|
453
|
+
Style/YAMLFileRead: # new in 1.53
|
454
|
+
Enabled: true
|
455
|
+
RSpec/ReceiveMessages: # new in 2.23
|
456
|
+
Enabled: true
|
457
|
+
RSpec/Rails/NegationBeValid: # new in 2.23
|
458
|
+
Enabled: true
|
data/.rubocop_todo.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --auto-gen-only-exclude`
|
3
|
-
# on 2023-
|
3
|
+
# on 2023-06-20 05:46:00 UTC using RuboCop version 1.52.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 8
|
10
10
|
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
|
11
11
|
# SupportedStyles: Gemfile, gems.rb, gemspec
|
12
12
|
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
|
@@ -69,12 +69,11 @@ RSpec/NestedGroups:
|
|
69
69
|
- 'spec/cocina/models/mapping/normalizers/mods/origin_info_normalizer_spec.rb'
|
70
70
|
- 'spec/cocina/models/validators/date_time_validator_spec.rb'
|
71
71
|
|
72
|
-
# Offense count:
|
72
|
+
# Offense count: 19
|
73
73
|
RSpec/PendingWithoutReason:
|
74
74
|
Exclude:
|
75
75
|
- 'spec/cocina/models/mapping/descriptive/mods/name_spec.rb'
|
76
76
|
- 'spec/cocina/models/mapping/descriptive/mods/origin_info_place_spec.rb'
|
77
|
-
- 'spec/cocina/models/mapping/descriptive/mods/part_spec.rb'
|
78
77
|
- 'spec/cocina/models/mapping/descriptive/mods/physical_description_spec.rb'
|
79
78
|
- 'spec/cocina/models/mapping/descriptive/mods/record_info_spec.rb'
|
80
79
|
- 'spec/cocina/models/mapping/descriptive/mods/subject_classification_spec.rb'
|
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.91.0)
|
5
5
|
activesupport
|
6
6
|
deprecation
|
7
7
|
dry-struct (~> 1.0)
|
@@ -11,7 +11,7 @@ PATH
|
|
11
11
|
jsonpath
|
12
12
|
nokogiri
|
13
13
|
openapi3_parser
|
14
|
-
openapi_parser (
|
14
|
+
openapi_parser (~> 1.0)
|
15
15
|
rss
|
16
16
|
super_diff
|
17
17
|
thor
|
@@ -20,25 +20,26 @@ PATH
|
|
20
20
|
GEM
|
21
21
|
remote: https://rubygems.org/
|
22
22
|
specs:
|
23
|
-
activesupport (7.0.
|
23
|
+
activesupport (7.0.8)
|
24
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
25
|
i18n (>= 1.6, < 2)
|
26
26
|
minitest (>= 5.1)
|
27
27
|
tzinfo (~> 2.0)
|
28
28
|
ast (2.4.2)
|
29
29
|
attr_extras (7.1.0)
|
30
|
+
base64 (0.1.1)
|
30
31
|
byebug (11.1.3)
|
31
|
-
committee (
|
32
|
+
committee (5.0.0)
|
32
33
|
json_schema (~> 0.14, >= 0.14.3)
|
33
|
-
openapi_parser (
|
34
|
+
openapi_parser (~> 1.0)
|
34
35
|
rack (>= 1.5)
|
35
|
-
commonmarker (0.23.
|
36
|
+
commonmarker (0.23.10)
|
36
37
|
concurrent-ruby (1.2.2)
|
37
38
|
deprecation (1.1.0)
|
38
39
|
activesupport
|
39
40
|
diff-lcs (1.5.0)
|
40
41
|
docile (1.4.0)
|
41
|
-
dry-core (1.0.
|
42
|
+
dry-core (1.0.1)
|
42
43
|
concurrent-ruby (~> 1.0)
|
43
44
|
zeitwerk (~> 2.6)
|
44
45
|
dry-inflector (1.0.0)
|
@@ -61,70 +62,77 @@ GEM
|
|
61
62
|
activesupport (>= 3.0, < 8.0)
|
62
63
|
equivalent-xml (0.6.0)
|
63
64
|
nokogiri (>= 1.4.3)
|
64
|
-
i18n (1.
|
65
|
+
i18n (1.14.1)
|
65
66
|
concurrent-ruby (~> 1.0)
|
66
67
|
ice_nine (0.11.2)
|
67
68
|
json (2.6.3)
|
68
69
|
json_schema (0.21.0)
|
69
|
-
jsonpath (1.1.
|
70
|
+
jsonpath (1.1.3)
|
70
71
|
multi_json
|
71
|
-
|
72
|
-
|
72
|
+
language_server-protocol (3.17.0.3)
|
73
|
+
mini_portile2 (2.8.4)
|
74
|
+
minitest (5.20.0)
|
73
75
|
multi_json (1.15.0)
|
74
|
-
nokogiri (1.
|
75
|
-
mini_portile2 (~> 2.8.
|
76
|
+
nokogiri (1.15.4)
|
77
|
+
mini_portile2 (~> 2.8.2)
|
76
78
|
racc (~> 1.4)
|
77
79
|
openapi3_parser (0.9.2)
|
78
80
|
commonmarker (~> 0.17)
|
79
|
-
openapi_parser (0.
|
80
|
-
optimist (3.0
|
81
|
-
parallel (1.
|
82
|
-
parser (3.2.
|
81
|
+
openapi_parser (1.0.0)
|
82
|
+
optimist (3.1.0)
|
83
|
+
parallel (1.23.0)
|
84
|
+
parser (3.2.2.3)
|
83
85
|
ast (~> 2.4.1)
|
86
|
+
racc
|
84
87
|
patience_diff (1.2.0)
|
85
88
|
optimist (~> 3.0)
|
86
|
-
racc (1.
|
87
|
-
rack (3.0.
|
89
|
+
racc (1.7.1)
|
90
|
+
rack (3.0.8)
|
88
91
|
rainbow (3.1.1)
|
89
92
|
rake (13.0.6)
|
90
|
-
regexp_parser (2.
|
91
|
-
rexml (3.2.
|
93
|
+
regexp_parser (2.8.1)
|
94
|
+
rexml (3.2.6)
|
92
95
|
rspec (3.12.0)
|
93
96
|
rspec-core (~> 3.12.0)
|
94
97
|
rspec-expectations (~> 3.12.0)
|
95
98
|
rspec-mocks (~> 3.12.0)
|
96
|
-
rspec-core (3.12.
|
99
|
+
rspec-core (3.12.2)
|
97
100
|
rspec-support (~> 3.12.0)
|
98
|
-
rspec-expectations (3.12.
|
101
|
+
rspec-expectations (3.12.3)
|
99
102
|
diff-lcs (>= 1.2.0, < 2.0)
|
100
103
|
rspec-support (~> 3.12.0)
|
101
|
-
rspec-mocks (3.12.
|
104
|
+
rspec-mocks (3.12.6)
|
102
105
|
diff-lcs (>= 1.2.0, < 2.0)
|
103
106
|
rspec-support (~> 3.12.0)
|
104
|
-
rspec-support (3.12.
|
107
|
+
rspec-support (3.12.1)
|
105
108
|
rspec_junit_formatter (0.6.0)
|
106
109
|
rspec-core (>= 2, < 4, != 2.12.0)
|
107
|
-
rss (0.
|
110
|
+
rss (0.3.0)
|
108
111
|
rexml
|
109
|
-
rubocop (1.
|
112
|
+
rubocop (1.56.3)
|
113
|
+
base64 (~> 0.1.1)
|
110
114
|
json (~> 2.3)
|
115
|
+
language_server-protocol (>= 3.17.0)
|
111
116
|
parallel (~> 1.10)
|
112
|
-
parser (>= 3.2.
|
117
|
+
parser (>= 3.2.2.3)
|
113
118
|
rainbow (>= 2.2.2, < 4.0)
|
114
119
|
regexp_parser (>= 1.8, < 3.0)
|
115
120
|
rexml (>= 3.2.5, < 4.0)
|
116
|
-
rubocop-ast (>= 1.
|
121
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
117
122
|
ruby-progressbar (~> 1.7)
|
118
123
|
unicode-display_width (>= 2.4.0, < 3.0)
|
119
|
-
rubocop-ast (1.
|
124
|
+
rubocop-ast (1.29.0)
|
120
125
|
parser (>= 3.2.1.0)
|
121
|
-
rubocop-capybara (2.
|
126
|
+
rubocop-capybara (2.18.0)
|
122
127
|
rubocop (~> 1.41)
|
128
|
+
rubocop-factory_bot (2.23.1)
|
129
|
+
rubocop (~> 1.33)
|
123
130
|
rubocop-rake (0.6.0)
|
124
131
|
rubocop (~> 1.0)
|
125
|
-
rubocop-rspec (2.
|
132
|
+
rubocop-rspec (2.24.0)
|
126
133
|
rubocop (~> 1.33)
|
127
134
|
rubocop-capybara (~> 2.17)
|
135
|
+
rubocop-factory_bot (~> 2.22)
|
128
136
|
ruby-progressbar (1.13.0)
|
129
137
|
simplecov (0.22.0)
|
130
138
|
docile (~> 1.1)
|
@@ -136,11 +144,11 @@ GEM
|
|
136
144
|
attr_extras (>= 6.2.4)
|
137
145
|
diff-lcs
|
138
146
|
patience_diff
|
139
|
-
thor (1.2.
|
147
|
+
thor (1.2.2)
|
140
148
|
tzinfo (2.0.6)
|
141
149
|
concurrent-ruby (~> 1.0)
|
142
150
|
unicode-display_width (2.4.2)
|
143
|
-
zeitwerk (2.6.
|
151
|
+
zeitwerk (2.6.11)
|
144
152
|
|
145
153
|
PLATFORMS
|
146
154
|
ruby
|
@@ -159,4 +167,4 @@ DEPENDENCIES
|
|
159
167
|
simplecov
|
160
168
|
|
161
169
|
BUNDLED WITH
|
162
|
-
2.
|
170
|
+
2.4.13
|
data/cocina-models.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency 'openapi3_parser' # Parsing openapi doc
|
36
36
|
# Match these version requirements to what committee wants,
|
37
37
|
# so that our client (non-committee) users have the same dependencies.
|
38
|
-
spec.add_dependency 'openapi_parser', '
|
38
|
+
spec.add_dependency 'openapi_parser', '~> 1.0'
|
39
39
|
spec.add_dependency 'rss' # used for date/time validation
|
40
40
|
spec.add_dependency 'super_diff'
|
41
41
|
spec.add_dependency 'thor'
|
@@ -24,6 +24,11 @@ module Cocina
|
|
24
24
|
generate_for(schema) if schema
|
25
25
|
end
|
26
26
|
|
27
|
+
%w[DRO Collection AdminPolicy].each do |schema_name|
|
28
|
+
schema = schema_for(schema_name, lite: true)
|
29
|
+
filepaths << generate_for(schema)
|
30
|
+
end
|
31
|
+
|
27
32
|
auto_format(filepaths)
|
28
33
|
generate_vocab
|
29
34
|
generate_descriptive_docs
|
@@ -94,13 +99,13 @@ module Cocina
|
|
94
99
|
@schemas ||= Openapi3Parser.load_file(options[:openapi]).components.schemas
|
95
100
|
end
|
96
101
|
|
97
|
-
def schema_for(schema_name)
|
102
|
+
def schema_for(schema_name, lite: false)
|
98
103
|
schema_doc = schemas[schema_name]
|
99
104
|
return nil if schema_doc.nil?
|
100
105
|
|
101
106
|
case schema_doc.type
|
102
107
|
when 'object'
|
103
|
-
Schema.new(schema_doc, schemas: schemas.keys)
|
108
|
+
Schema.new(schema_doc, schemas: schemas.keys, lite: lite)
|
104
109
|
when 'string'
|
105
110
|
Datatype.new(schema_doc, schemas: schemas.keys)
|
106
111
|
when NilClass
|
@@ -71,7 +71,7 @@ module Cocina
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def validatable?
|
74
|
-
!schema_doc.node_context.document.paths["/validate/#{schema_doc.name}"].nil?
|
74
|
+
!schema_doc.node_context.document.paths["/validate/#{schema_doc.name}"].nil? && !lite
|
75
75
|
end
|
76
76
|
|
77
77
|
def properties
|
@@ -119,12 +119,14 @@ module Cocina
|
|
119
119
|
|
120
120
|
def schema_properties_for(doc)
|
121
121
|
doc.properties.map do |key, properties_doc|
|
122
|
-
property_class_for(properties_doc)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
clazz = property_class_for(properties_doc)
|
123
|
+
clazz.new(properties_doc,
|
124
|
+
key: key,
|
125
|
+
required: doc.requires?(key),
|
126
|
+
relaxed: lite && clazz != SchemaValue,
|
127
|
+
nullable: properties_doc.nullable?,
|
128
|
+
parent: self,
|
129
|
+
schemas: schemas)
|
128
130
|
end
|
129
131
|
end
|
130
132
|
end
|
@@ -4,9 +4,9 @@ module Cocina
|
|
4
4
|
module Generator
|
5
5
|
# Base class for generating from openapi
|
6
6
|
class SchemaBase
|
7
|
-
attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas
|
7
|
+
attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas, :lite
|
8
8
|
|
9
|
-
def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [])
|
9
|
+
def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [], lite: false)
|
10
10
|
@schema_doc = schema_doc
|
11
11
|
@key = key
|
12
12
|
@required = required
|
@@ -14,6 +14,7 @@ module Cocina
|
|
14
14
|
@parent = parent
|
15
15
|
@relaxed = relaxed
|
16
16
|
@schemas = schemas
|
17
|
+
@lite = lite
|
17
18
|
end
|
18
19
|
|
19
20
|
def filename
|
@@ -21,7 +22,7 @@ module Cocina
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def name
|
24
|
-
key || schema_doc.name
|
25
|
+
"#{key || schema_doc.name}#{lite ? 'Lite' : ''}"
|
25
26
|
end
|
26
27
|
|
27
28
|
# Allows nullable values to be set to nil. This is useful when doing an
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
class AdminPolicyLite < Struct
|
6
|
+
include Checkable
|
7
|
+
|
8
|
+
TYPES = ['https://cocina.sul.stanford.edu/models/admin_policy'].freeze
|
9
|
+
|
10
|
+
# The version of Cocina with which this object conforms.
|
11
|
+
# example: 1.2.3
|
12
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
13
|
+
attribute :type, Types::Strict::String.enum(*AdminPolicyLite::TYPES)
|
14
|
+
# example: druid:bc123df4567
|
15
|
+
attribute :externalIdentifier, Druid
|
16
|
+
attribute :label, Types::Strict::String
|
17
|
+
attribute :version, Types::Strict::Integer
|
18
|
+
attribute? :administrative, AdminPolicyAdministrative.optional
|
19
|
+
attribute? :description, Description.optional
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
# A group of Digital Repository Objects that indicate some type of conceptual grouping within the domain that is worth reusing across the system.
|
6
|
+
class CollectionLite < Struct
|
7
|
+
include Checkable
|
8
|
+
|
9
|
+
TYPES = ['https://cocina.sul.stanford.edu/models/collection',
|
10
|
+
'https://cocina.sul.stanford.edu/models/curated-collection',
|
11
|
+
'https://cocina.sul.stanford.edu/models/user-collection',
|
12
|
+
'https://cocina.sul.stanford.edu/models/exhibit',
|
13
|
+
'https://cocina.sul.stanford.edu/models/series'].freeze
|
14
|
+
|
15
|
+
# The version of Cocina with which this object conforms.
|
16
|
+
# example: 1.2.3
|
17
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
18
|
+
# The content type of the Collection. Selected from an established set of values.
|
19
|
+
attribute :type, Types::Strict::String.enum(*CollectionLite::TYPES)
|
20
|
+
# example: druid:bc123df4567
|
21
|
+
attribute :externalIdentifier, Druid
|
22
|
+
# Primary processing label (can be same as title) for a Collection.
|
23
|
+
attribute :label, Types::Strict::String
|
24
|
+
# Version for the Collection within SDR.
|
25
|
+
attribute :version, Types::Strict::Integer
|
26
|
+
attribute? :access, CollectionAccess.optional
|
27
|
+
attribute? :administrative, Administrative.optional
|
28
|
+
attribute? :description, Description.optional
|
29
|
+
attribute? :identification, CollectionIdentification.optional
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
# Domain-defined abstraction of a 'work'. Digital Repository Objects' abstraction is describable for our domain’s purposes, i.e. for management needs within our system.
|
6
|
+
class DROLite < Struct
|
7
|
+
include Checkable
|
8
|
+
|
9
|
+
TYPES = ['https://cocina.sul.stanford.edu/models/object',
|
10
|
+
'https://cocina.sul.stanford.edu/models/3d',
|
11
|
+
'https://cocina.sul.stanford.edu/models/agreement',
|
12
|
+
'https://cocina.sul.stanford.edu/models/book',
|
13
|
+
'https://cocina.sul.stanford.edu/models/document',
|
14
|
+
'https://cocina.sul.stanford.edu/models/geo',
|
15
|
+
'https://cocina.sul.stanford.edu/models/image',
|
16
|
+
'https://cocina.sul.stanford.edu/models/page',
|
17
|
+
'https://cocina.sul.stanford.edu/models/photograph',
|
18
|
+
'https://cocina.sul.stanford.edu/models/manuscript',
|
19
|
+
'https://cocina.sul.stanford.edu/models/map',
|
20
|
+
'https://cocina.sul.stanford.edu/models/media',
|
21
|
+
'https://cocina.sul.stanford.edu/models/track',
|
22
|
+
'https://cocina.sul.stanford.edu/models/webarchive-binary',
|
23
|
+
'https://cocina.sul.stanford.edu/models/webarchive-seed'].freeze
|
24
|
+
|
25
|
+
# The version of Cocina with which this object conforms.
|
26
|
+
# example: 1.2.3
|
27
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
28
|
+
# The content type of the DRO. Selected from an established set of values.
|
29
|
+
attribute :type, Types::Strict::String.enum(*DROLite::TYPES)
|
30
|
+
# example: druid:bc123df4567
|
31
|
+
attribute :externalIdentifier, Druid
|
32
|
+
# Primary processing label (can be same as title) for a DRO.
|
33
|
+
attribute :label, Types::Strict::String
|
34
|
+
# Version for the DRO within SDR.
|
35
|
+
attribute :version, Types::Strict::Integer
|
36
|
+
attribute? :access, DROAccess.optional
|
37
|
+
attribute? :administrative, Administrative.optional
|
38
|
+
attribute? :description, Description.optional
|
39
|
+
attribute? :identification, Identification.optional
|
40
|
+
attribute? :structural, DROStructural.optional
|
41
|
+
attribute? :geographic, Geographic.optional
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -145,7 +145,7 @@ module Cocina
|
|
145
145
|
return if raw_type.blank?
|
146
146
|
|
147
147
|
first_event_type = event_type(origin_info_nodes.first)
|
148
|
-
|
148
|
+
first_event_type if origin_info_nodes.all? { |node| event_type(node) == first_event_type }
|
149
149
|
end
|
150
150
|
|
151
151
|
# @return String displayLabel for the cocina event if it is the same for all the origin_info_nodes, o.w. nil
|
@@ -154,7 +154,7 @@ module Cocina
|
|
154
154
|
return if raw_label.blank?
|
155
155
|
|
156
156
|
first_label = display_label(origin_info_nodes.first)
|
157
|
-
|
157
|
+
first_label if origin_info_nodes.all? { |node| display_label(node) == first_label }
|
158
158
|
end
|
159
159
|
|
160
160
|
def add_info_to_event(event, origin_info_node)
|
@@ -93,7 +93,8 @@ module Cocina
|
|
93
93
|
|
94
94
|
def build_subject
|
95
95
|
return [build_subject_for_center_point] unless centerpoint.empty?
|
96
|
-
|
96
|
+
|
97
|
+
build_subject_for_bounding_box unless envelope.empty?
|
97
98
|
end
|
98
99
|
|
99
100
|
def build_subject_for_center_point
|
@@ -235,7 +235,7 @@ module Cocina
|
|
235
235
|
cocina_roles = role_nodes.filter_map { |role_node| role_for(role_node) }.presence
|
236
236
|
return if cocina_roles.blank?
|
237
237
|
|
238
|
-
|
238
|
+
'event' if cocina_roles.first[:value] == 'event'
|
239
239
|
end
|
240
240
|
|
241
241
|
def activity_date?(name_part_node)
|
data/lib/cocina/models.rb
CHANGED
@@ -23,6 +23,7 @@ class CocinaModelsInflector < Zeitwerk::Inflector
|
|
23
23
|
'dro' => 'DRO',
|
24
24
|
'request_dro' => 'RequestDRO',
|
25
25
|
'dro_access' => 'DROAccess',
|
26
|
+
'dro_lite' => 'DROLite',
|
26
27
|
'dro_structural' => 'DROStructural',
|
27
28
|
'dro_with_metadata' => 'DROWithMetadata',
|
28
29
|
'request_dro_structural' => 'RequestDROStructural',
|
@@ -117,6 +118,31 @@ module Cocina
|
|
117
118
|
clazz.new(dyn, false, validate)
|
118
119
|
end
|
119
120
|
|
121
|
+
# Build "lite" versions of DROs, Collections, and AdminPolicies.
|
122
|
+
# Lite versions do not require attributes that are required in the normal versions.
|
123
|
+
# For example, "description" is required for a DRO, but optional for a DROLite.
|
124
|
+
# Lite versions also are not validated / validatable.
|
125
|
+
# Lite versions are useful for instantiating partially populated cocina objects similar to an
|
126
|
+
# ActiveRecord instantiated using .select (See https://guides.rubyonrails.org/active_record_querying.html#selecting-specific-fields)
|
127
|
+
# @param [Hash] dyn a ruby hash representation of the JSON serialization of a Collection, DRO, or AdminPolicy
|
128
|
+
# @return [DROLite,CollectionLite,AdminPolicyLite]
|
129
|
+
# @raises [UnknownTypeError] if a valid type is not found in the data
|
130
|
+
# @raises [ValidationError] if a type field cannot be found in the data
|
131
|
+
def self.build_lite(dyn)
|
132
|
+
clazz = case type_for(dyn)
|
133
|
+
when *DRO::TYPES
|
134
|
+
DROLite
|
135
|
+
when *Collection::TYPES
|
136
|
+
CollectionLite
|
137
|
+
when *AdminPolicy::TYPES
|
138
|
+
AdminPolicyLite
|
139
|
+
else
|
140
|
+
raise UnknownTypeError, "Unknown type: '#{dyn.with_indifferent_access.fetch('type')}'"
|
141
|
+
end
|
142
|
+
# dyn for lite may contain extra keys
|
143
|
+
clazz.new(dyn.with_indifferent_access.slice(*clazz.attribute_names))
|
144
|
+
end
|
145
|
+
|
120
146
|
# Coerces DROWithMetadata, CollectionWithMetadata, AdminPolicyWithMetadata to DRO, Collection, AdminPolicy
|
121
147
|
# @param [DROWithMetadata,CollectionWithMetadata,AdminPolicyWithMetadata] cocina_object
|
122
148
|
# @return [DRO,Collection,AdminPolicy]
|
@@ -15,10 +15,13 @@ module Cocina
|
|
15
15
|
SUPPORTED_TYPES = %i[
|
16
16
|
admin_policy
|
17
17
|
admin_policy_with_metadata
|
18
|
+
admin_policy_lite
|
18
19
|
collection
|
19
20
|
collection_with_metadata
|
21
|
+
collection_lite
|
20
22
|
dro
|
21
23
|
dro_with_metadata
|
24
|
+
dro_lite
|
22
25
|
request_admin_policy
|
23
26
|
request_collection
|
24
27
|
request_dro
|
@@ -88,6 +91,10 @@ module Cocina
|
|
88
91
|
Cocina::Models.build(build_dro_properties(**DRO_DEFAULTS.merge(attributes)))
|
89
92
|
end
|
90
93
|
|
94
|
+
def self.build_dro_lite(attributes)
|
95
|
+
Cocina::Models.build_lite(build_dro_properties(**DRO_DEFAULTS.merge(attributes)))
|
96
|
+
end
|
97
|
+
|
91
98
|
# rubocop:disable Metrics/ParameterLists
|
92
99
|
def self.build_request_dro_properties(type:, version:, label:, title:, source_id:, admin_policy_id:,
|
93
100
|
barcode: nil, catkeys: [], folio_instance_hrids: [], collection_ids: [])
|
@@ -166,6 +173,10 @@ module Cocina
|
|
166
173
|
Cocina::Models.build(build_collection_properties(**COLLECTION_DEFAULTS.merge(attributes)))
|
167
174
|
end
|
168
175
|
|
176
|
+
def self.build_collection_lite(attributes)
|
177
|
+
Cocina::Models.build_lite(build_collection_properties(**COLLECTION_DEFAULTS.merge(attributes)))
|
178
|
+
end
|
179
|
+
|
169
180
|
def self.build_request_collection(attributes)
|
170
181
|
Cocina::Models.build_request(build_request_collection_properties(**REQUEST_COLLECTION_DEFAULTS.merge(attributes)))
|
171
182
|
end
|
@@ -174,6 +185,10 @@ module Cocina
|
|
174
185
|
Cocina::Models.build(build_admin_policy_properties(**ADMIN_POLICY_DEFAULTS.merge(attributes)))
|
175
186
|
end
|
176
187
|
|
188
|
+
def self.build_admin_policy_lite(attributes)
|
189
|
+
Cocina::Models.build_lite(build_admin_policy_properties(**ADMIN_POLICY_DEFAULTS.merge(attributes)))
|
190
|
+
end
|
191
|
+
|
177
192
|
def self.build_request_admin_policy(attributes)
|
178
193
|
Cocina::Models.build_request(build_request_admin_policy_properties(**REQUEST_ADMIN_POLICY_DEFAULTS.merge(attributes)))
|
179
194
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocina-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.91.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -140,20 +140,14 @@ dependencies:
|
|
140
140
|
name: openapi_parser
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.11.1
|
146
|
-
- - "<"
|
143
|
+
- - "~>"
|
147
144
|
- !ruby/object:Gem::Version
|
148
145
|
version: '1.0'
|
149
146
|
type: :runtime
|
150
147
|
prerelease: false
|
151
148
|
version_requirements: !ruby/object:Gem::Requirement
|
152
149
|
requirements:
|
153
|
-
- - "
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
version: 0.11.1
|
156
|
-
- - "<"
|
150
|
+
- - "~>"
|
157
151
|
- !ruby/object:Gem::Version
|
158
152
|
version: '1.0'
|
159
153
|
- !ruby/object:Gem::Dependency
|
@@ -367,6 +361,7 @@ files:
|
|
367
361
|
- lib/cocina/models/admin_policy.rb
|
368
362
|
- lib/cocina/models/admin_policy_access_template.rb
|
369
363
|
- lib/cocina/models/admin_policy_administrative.rb
|
364
|
+
- lib/cocina/models/admin_policy_lite.rb
|
370
365
|
- lib/cocina/models/admin_policy_with_metadata.rb
|
371
366
|
- lib/cocina/models/administrative.rb
|
372
367
|
- lib/cocina/models/applies_to.rb
|
@@ -384,6 +379,7 @@ files:
|
|
384
379
|
- lib/cocina/models/collection.rb
|
385
380
|
- lib/cocina/models/collection_access.rb
|
386
381
|
- lib/cocina/models/collection_identification.rb
|
382
|
+
- lib/cocina/models/collection_lite.rb
|
387
383
|
- lib/cocina/models/collection_with_metadata.rb
|
388
384
|
- lib/cocina/models/contributor.rb
|
389
385
|
- lib/cocina/models/controlled_digital_lending_access.rb
|
@@ -407,6 +403,7 @@ files:
|
|
407
403
|
- lib/cocina/models/doi_pattern.rb
|
408
404
|
- lib/cocina/models/dro.rb
|
409
405
|
- lib/cocina/models/dro_access.rb
|
406
|
+
- lib/cocina/models/dro_lite.rb
|
410
407
|
- lib/cocina/models/dro_structural.rb
|
411
408
|
- lib/cocina/models/dro_with_metadata.rb
|
412
409
|
- lib/cocina/models/druid.rb
|
@@ -548,7 +545,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
548
545
|
- !ruby/object:Gem::Version
|
549
546
|
version: '0'
|
550
547
|
requirements: []
|
551
|
-
rubygems_version: 3.
|
548
|
+
rubygems_version: 3.3.7
|
552
549
|
signing_key:
|
553
550
|
specification_version: 4
|
554
551
|
summary: Data models for the SDR
|