cocina-models 0.62.1 → 0.65.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +9 -48
  3. data/.rubocop.yml +116 -1
  4. data/.rubocop_todo.yml +5 -4
  5. data/Gemfile +1 -0
  6. data/README.md +19 -6
  7. data/cocina-models.gemspec +6 -4
  8. data/docs/maps/Collection.json +0 -5
  9. data/docs/maps/DRO.json +0 -5
  10. data/lib/cocina/generator/schema_array.rb +1 -9
  11. data/lib/cocina/generator/schema_value.rb +4 -0
  12. data/lib/cocina/models/admin_policy.rb +3 -0
  13. data/lib/cocina/models/admin_policy_administrative.rb +4 -4
  14. data/lib/cocina/models/administrative.rb +1 -1
  15. data/lib/cocina/models/applies_to.rb +1 -1
  16. data/lib/cocina/models/cocina_version.rb +9 -0
  17. data/lib/cocina/models/collection.rb +3 -0
  18. data/lib/cocina/models/collection_identification.rb +1 -1
  19. data/lib/cocina/models/contributor.rb +5 -5
  20. data/lib/cocina/models/description.rb +12 -12
  21. data/lib/cocina/models/descriptive_access_metadata.rb +6 -6
  22. data/lib/cocina/models/descriptive_admin_metadata.rb +6 -6
  23. data/lib/cocina/models/descriptive_basic_value.rb +5 -5
  24. data/lib/cocina/models/descriptive_geographic_metadata.rb +2 -2
  25. data/lib/cocina/models/descriptive_grouped_value.rb +1 -1
  26. data/lib/cocina/models/descriptive_parallel_contributor.rb +4 -4
  27. data/lib/cocina/models/descriptive_parallel_event.rb +6 -6
  28. data/lib/cocina/models/descriptive_parallel_value.rb +1 -1
  29. data/lib/cocina/models/descriptive_structured_value.rb +1 -1
  30. data/lib/cocina/models/descriptive_value.rb +6 -6
  31. data/lib/cocina/models/descriptive_value_language.rb +1 -1
  32. data/lib/cocina/models/dro.rb +3 -0
  33. data/lib/cocina/models/dro_access.rb +1 -1
  34. data/lib/cocina/models/dro_structural.rb +3 -5
  35. data/lib/cocina/models/event.rb +7 -7
  36. data/lib/cocina/models/file_set_structural.rb +1 -1
  37. data/lib/cocina/models/identification.rb +3 -3
  38. data/lib/cocina/models/language.rb +5 -5
  39. data/lib/cocina/models/related_resource.rb +9 -9
  40. data/lib/cocina/models/request_admin_policy.rb +4 -1
  41. data/lib/cocina/models/request_collection.rb +4 -1
  42. data/lib/cocina/models/request_description.rb +28 -0
  43. data/lib/cocina/models/request_dro.rb +4 -1
  44. data/lib/cocina/models/request_dro_structural.rb +3 -4
  45. data/lib/cocina/models/request_file_set_structural.rb +1 -1
  46. data/lib/cocina/models/request_identification.rb +2 -2
  47. data/lib/cocina/models/sequence.rb +1 -1
  48. data/lib/cocina/models/source.rb +1 -1
  49. data/lib/cocina/models/standard.rb +1 -1
  50. data/lib/cocina/models/title.rb +6 -6
  51. data/lib/cocina/models/validator.rb +21 -1
  52. data/lib/cocina/models/version.rb +1 -1
  53. data/openapi.yml +124 -80
  54. metadata +30 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cec7a3ac1ecbadbdbcb8faaa1311e9c03843af53b4256d3694e23c6834b91bbe
4
- data.tar.gz: 12d1fa927c36ba962b790ef6b2c2d048c7af6251416d286a6392dc6175551164
3
+ metadata.gz: 8067413d8a77fa81852ba259290d705786b6a48cd4a911238b3f807e695084a2
4
+ data.tar.gz: 6a1922fbb79102ca049e6e60cba1095e3959091ea5ee89d1a93c7befd154701b
5
5
  SHA512:
6
- metadata.gz: 10aed08575f11ceb53cebd61603448de768690b10cd06b64bfc6964f4b23fb0827546e18e1a25a5e14c338cc60e0147ad608dbdccb92cd7993dc9c6c2a6c8e86
7
- data.tar.gz: 6fb48b45f9c87fbb8f517ca523d58c22884f3b1e2dc1b428718083e4463fb59909d02306373bfa999a1cc66237d857dc3cc7c56353666883517325cf718628c0
6
+ metadata.gz: ba8463f12ef7fb60ba49bbd91a1537b80488044c734baf059ae255f866f57a857e3270defedc2dd038683bf6438e78c575855a68617d9f5d3153c8be3ec217dc
7
+ data.tar.gz: f53a8118686874d73832f3a5b3f55c7f2cba725f0ea459f2b06f4b01e3c148b7de31fe2c31206e99d4fc39b100776f0fa5d5dd51e96cee8fc8e5bab3e3be6fba
data/.circleci/config.yml CHANGED
@@ -1,51 +1,12 @@
1
1
  version: 2.1
2
- executors:
3
- docker-publisher:
4
- docker:
5
- - image: circleci/buildpack-deps:stretch
6
- jobs:
7
- test:
8
- docker:
9
- - image: circleci/ruby:2.7.0-node
10
- steps:
11
- - checkout
12
- - run:
13
- name: install bundler
14
- command: gem install bundler -v 2.1.4
15
- - run:
16
- name: Install gem dependencies
17
- command: bundle check || bundle install
18
- - run:
19
- name: Lint using rubocop
20
- command: bundle exec rubocop
21
- - run:
22
- name: Setup Code Climate test-reporter
23
- command: |
24
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25
- chmod +x ./cc-test-reporter
26
- ./cc-test-reporter before-build
27
- - run:
28
- name: Run RSpec test suite
29
- command: bundle exec rspec
30
- - run:
31
- name: upload test coverage report to Code Climate
32
- command: ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
33
- - run:
34
- name: Validate API specification
35
- command: |
36
- sudo npm install -g openapi-enforcer-cli
37
- result=$(openapi-enforcer validate openapi.yml)
38
- [[ $result =~ "Document is valid" ]] && {
39
- echo "Validation good"
40
- exit 0
41
- } || {
42
- echo $result
43
- exit 1
44
- }
45
-
2
+ orbs:
3
+ ruby-rails: sul-dlss/ruby-rails@2.0.0
46
4
  workflows:
47
- version: 2
48
-
49
- test:
5
+ build:
50
6
  jobs:
51
- - test
7
+ - ruby-rails/validate-api:
8
+ name: validate
9
+ - ruby-rails/lint:
10
+ name: lint
11
+ - ruby-rails/test-gem:
12
+ name: test
data/.rubocop.yml CHANGED
@@ -3,9 +3,11 @@
3
3
  inherit_from: .rubocop_todo.yml
4
4
  require:
5
5
  - rubocop-rspec
6
+ - rubocop-rake
6
7
 
7
8
  AllCops:
8
- TargetRubyVersion: 2.5
9
+ # dor-services-app is stuck at ruby 2 until we get off Fedora3
10
+ TargetRubyVersion: 2.7
9
11
 
10
12
  # ----- Layout ------
11
13
 
@@ -154,3 +156,116 @@ Style/SoleNestedConditional: # (new in 0.89)
154
156
  Enabled: true
155
157
  Style/StringConcatenation:
156
158
  Enabled: true
159
+
160
+ Gemspec/DateAssignment: # new in 1.10
161
+ Enabled: true
162
+ Gemspec/RequireMFA: # new in 1.23
163
+ Enabled: true
164
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
165
+ Enabled: true
166
+ Layout/SpaceBeforeBrackets: # new in 1.7
167
+ Enabled: true
168
+ Lint/AmbiguousAssignment: # new in 1.7
169
+ Enabled: true
170
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
171
+ Enabled: true
172
+ Lint/AmbiguousRange: # new in 1.19
173
+ Enabled: true
174
+ Lint/DeprecatedConstants: # new in 1.8
175
+ Enabled: true
176
+ Lint/DuplicateBranch: # new in 1.3
177
+ Enabled: true
178
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
179
+ Enabled: true
180
+ Lint/EmptyBlock: # new in 1.1
181
+ Enabled: true
182
+ Lint/EmptyClass: # new in 1.3
183
+ Enabled: true
184
+ Lint/EmptyInPattern: # new in 1.16
185
+ Enabled: true
186
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
187
+ Enabled: true
188
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
189
+ Enabled: true
190
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
191
+ Enabled: true
192
+ Lint/NumberedParameterAssignment: # new in 1.9
193
+ Enabled: true
194
+ Lint/OrAssignmentToConstant: # new in 1.9
195
+ Enabled: true
196
+ Lint/RedundantDirGlobSort: # new in 1.8
197
+ Enabled: true
198
+ Lint/RequireRelativeSelfPath: # new in 1.22
199
+ Enabled: true
200
+ Lint/SymbolConversion: # new in 1.9
201
+ Enabled: true
202
+ Lint/ToEnumArguments: # new in 1.1
203
+ Enabled: true
204
+ Lint/TripleQuotes: # new in 1.9
205
+ Enabled: true
206
+ Lint/UnexpectedBlockArity: # new in 1.5
207
+ Enabled: true
208
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
209
+ Enabled: true
210
+ Lint/UselessRuby2Keywords: # new in 1.23
211
+ Enabled: true
212
+ Naming/BlockForwarding: # new in 1.24
213
+ Enabled: true
214
+ Security/IoMethods: # new in 1.22
215
+ Enabled: true
216
+ Style/ArgumentsForwarding: # new in 1.1
217
+ Enabled: true
218
+ Style/CollectionCompact: # new in 1.2
219
+ Enabled: true
220
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
221
+ Enabled: true
222
+ Style/EndlessMethod: # new in 1.8
223
+ Enabled: true
224
+ Style/FileRead: # new in 1.24
225
+ Enabled: true
226
+ Style/FileWrite: # new in 1.24
227
+ Enabled: true
228
+ Style/HashConversion: # new in 1.10
229
+ Enabled: true
230
+ Style/HashExcept: # new in 1.7
231
+ Enabled: true
232
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
233
+ Enabled: true
234
+ Style/InPatternThen: # new in 1.16
235
+ Enabled: true
236
+ Style/MapToHash: # new in 1.24
237
+ Enabled: true
238
+ Style/MultilineInPatternThen: # new in 1.16
239
+ Enabled: true
240
+ Style/NegatedIfElseCondition: # new in 1.2
241
+ Enabled: true
242
+ Style/NilLambda: # new in 1.3
243
+ Enabled: true
244
+ Style/NumberedParameters: # new in 1.22
245
+ Enabled: true
246
+ Style/NumberedParametersLimit: # new in 1.22
247
+ Enabled: true
248
+ Style/OpenStructUse: # new in 1.23
249
+ Enabled: true
250
+ Style/QuotedSymbols: # new in 1.16
251
+ Enabled: true
252
+ Style/RedundantArgument: # new in 1.4
253
+ Enabled: true
254
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
255
+ Enabled: true
256
+ Style/SelectByRegexp: # new in 1.22
257
+ Enabled: true
258
+ Style/StringChars: # new in 1.12
259
+ Enabled: true
260
+ Style/SwapValues: # new in 1.1
261
+ Enabled: true
262
+ RSpec/ExcessiveDocstringSpacing: # new in 2.5
263
+ Enabled: true
264
+ RSpec/IdenticalEqualityAssertion: # new in 2.4
265
+ Enabled: true
266
+ RSpec/SubjectDeclaration: # new in 2.5
267
+ Enabled: true
268
+ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
269
+ Enabled: true
270
+ RSpec/Rails/AvoidSetupHook: # new in 2.4
271
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2021-04-16 17:25:55 UTC using RuboCop version 0.93.1.
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
+ # on 2022-01-14 00:32:36 UTC using RuboCop version 1.24.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
@@ -14,9 +14,10 @@ Lint/SafeNavigationChain:
14
14
  - 'lib/cocina/generator/schema_base.rb'
15
15
 
16
16
  # Offense count: 1
17
- # Configuration parameters: CountKeywordArgs.
17
+ # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters.
18
18
  Metrics/ParameterLists:
19
- Max: 6
19
+ Exclude:
20
+ - 'lib/cocina/generator/schema_base.rb'
20
21
 
21
22
  # Offense count: 1
22
23
  # Configuration parameters: MinBodyLength.
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  gem 'byebug'
9
+ gem 'rspec_junit_formatter' # For CircleCI
data/README.md CHANGED
@@ -65,17 +65,30 @@ At the same, we have found it convenient to use these PRs to also bump the versi
65
65
 
66
66
  ### Step 4: Update other dependent applications
67
67
 
68
- Once the above listed steps have been completed, all the following applications that use cocina-models should be updated and released at the same time:
68
+ Once the above listed steps have been completed, all the following applications that use cocina-models should be updated and released at the same time. "Cocina Level 2" describes this set of updates.
69
69
 
70
- * [sul-dlss/dor_indexing_app](https://github.com/sul-dlss/dor_indexing_app/)
70
+ * [sul-dlss/argo](https://github.com/sul-dlss/argo/)
71
71
  * [sul-dlss/common-accessioning](https://github.com/sul-dlss/common-accessioning/)
72
+ * [sul-dlss/dor_indexing_app](https://github.com/sul-dlss/dor_indexing_app/)
72
73
  * [sul-dlss/google-books](https://github.com/sul-dlss/google-books/)
73
- * [sul-dlss/argo](https://github.com/sul-dlss/argo/)
74
- * [sul-dlss/pre-assembly](https://github.com/sul-dlss/pre-assembly/)
75
- * [sul-dlss/hydra_etd](https://github.com/sul-dlss/hydra_etd/)
76
- * [sul-dlss/hydrus](https://github.com/sul-dlss/hydrus/)
77
74
  * [sul-dlss/happy-heron](https://github.com/sul-dlss/happy-heron/)
75
+ * [sul-dlss/hydra_etd](https://github.com/sul-dlss/hydra_etd/)
78
76
  * [sul-dlss/infrastructure-integration-test](https://github.com/sul-dlss/infrastructure-integration-test/)
77
+ * [sul-dlss/pre-assembly](https://github.com/sul-dlss/pre-assembly/)
78
+
79
+ There are scripts to help with this:
80
+
81
+ #### Step 4A: Create the PRs
82
+
83
+ access-update-scripts repo has a script for this: `cocina_level2_prs.rb`. You will need a github access token with scopes of "read:org" and "repo" (see https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to run it, as noted in the comments at the top of that script.
84
+
85
+ #### Step 4B: Merge the PRs
86
+
87
+ [sul-dlss/access-update-scripts](https://github.com/sul-dlss/access-update-scripts) has a switch in the `merge-all.rb` script for this, as noted in the comments at the top of that script. (`REPOS_PATH=infrastructure GH_ACCESS_TOKEN=abc123 COCINA_LEVEL2= ./merge-all.rb`)
88
+
89
+ ### Step 5: Deploy all affected applications together
90
+
91
+ [sul-dlss/sdr-deploy](https://github.com/sul-dlss/sdr-deploy) has a flag in the deploy script to limit deploys to cocina dependent applications. Refer to instructions in the [sdr-deploy/README](https://github.com/sul-dlss/sdr-deploy/blob/main/README.md#only-deploy-repos-related-to-cocina-models-update).
79
92
 
80
93
  ## Usage conventions
81
94
 
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = 'exe'
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
- spec.required_ruby_version = '>= 2.5'
25
+ spec.required_ruby_version = '>= 2.7'
26
26
 
27
27
  spec.add_dependency 'activesupport'
28
28
  spec.add_dependency 'dry-struct', '~> 1.0'
@@ -36,7 +36,9 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'committee'
37
37
  spec.add_development_dependency 'rake', '~> 13.0'
38
38
  spec.add_development_dependency 'rspec', '~> 3.0'
39
- spec.add_development_dependency 'rubocop', '~> 0.93'
40
- spec.add_development_dependency 'rubocop-rspec', '~> 1.44'
41
- spec.add_development_dependency 'simplecov', '~> 0.17.0'
39
+ spec.add_development_dependency 'rubocop', '~> 1.24'
40
+ spec.add_development_dependency 'rubocop-rake'
41
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.1'
42
+ spec.add_development_dependency 'simplecov'
43
+ spec.metadata['rubygems_mfa_required'] = 'true'
42
44
  end
@@ -215,12 +215,7 @@
215
215
  "structural": {
216
216
  "description": "Structural metadata for the Collection.",
217
217
  "type": "object",
218
- "required": ["hasAgreement"],
219
218
  "properties": {
220
- "hasAgreement": {
221
- "description": "Agreement that covers the deposit of the Collection into SDR.",
222
- "type": "string"
223
- },
224
219
  "hasMember": {
225
220
  "description": "Component digital repository objects or collections that are a part of this collection.",
226
221
  "type": "array",
data/docs/maps/DRO.json CHANGED
@@ -277,7 +277,6 @@
277
277
  "structural": {
278
278
  "description": "Structural metadata for the DRO.",
279
279
  "type": "object",
280
- "required": ["hasAgreement"],
281
280
  "properties": {
282
281
  "contains": {
283
282
  "description": "Filesets that contain the digital representations (Files) of the DRO.",
@@ -286,10 +285,6 @@
286
285
  "$ref": "/Fileset"
287
286
  }
288
287
  },
289
- "hasAgreement": {
290
- "description": "Agreement that covers the deposit of the DRO into SDR.",
291
- "type": "string"
292
- },
293
288
  "hasMember": {
294
289
  "description": "Component or 'children' digital repository objects that are a part or portion of this 'parent' or aggregate DRO.",
295
290
  "type": "array",
@@ -5,15 +5,7 @@ module Cocina
5
5
  # Class for generating from an openapi array
6
6
  class SchemaArray < SchemaBase
7
7
  def generate
8
- "attribute :#{name.camelize(:lower)}, Types::Strict::Array.of(#{array_of_type})#{omittable}"
9
- end
10
-
11
- def omittable
12
- if required && !relaxed
13
- '.default([].freeze)'
14
- else
15
- '.meta(omittable: true)'
16
- end
8
+ "attribute :#{name.camelize(:lower)}, Types::Strict::Array.of(#{array_of_type}).default([].freeze)"
17
9
  end
18
10
 
19
11
  def array_of_type
@@ -26,10 +26,14 @@ module Cocina
26
26
  end
27
27
 
28
28
  def default
29
+ # Provide version as default for cocinaVersion
30
+ return '.default(Cocina::Models::VERSION)' if name == 'cocinaVersion'
31
+
29
32
  # If type is boolean and default is false, erroneously getting a nil.
30
33
  # Assuming that if required, then default is false.
31
34
  default = schema_doc.default
32
35
  default = false if default.nil? && schema_doc.type == 'boolean' && required
36
+
33
37
  return '' if default.nil?
34
38
 
35
39
  ".default(#{quote(default)})"
@@ -7,6 +7,9 @@ module Cocina
7
7
 
8
8
  TYPES = ['http://cocina.sul.stanford.edu/models/admin_policy.jsonld'].freeze
9
9
 
10
+ # The version of Cocina with which this object conforms.
11
+ # example: 1.2.3
12
+ attribute :cocinaVersion, Types::Strict::String.default(Cocina::Models::VERSION)
10
13
  attribute :type, Types::Strict::String.enum(*AdminPolicy::TYPES)
11
14
  # example: druid:bc123df4567
12
15
  attribute :externalIdentifier, Types::Strict::String
@@ -6,16 +6,16 @@ module Cocina
6
6
  # This is an XML expression of the default access (see defaultAccess)
7
7
  attribute :defaultObjectRights, Types::Strict::String.default('<?xml version="1.0" encoding="UTF-8"?><rightsMetadata><access type="discover"><machine><world/></machine></access><access type="read"><machine><world/></machine></access><use><human type="useAndReproduction"/><human type="creativeCommons"/><machine type="creativeCommons" uri=""/><human type="openDataCommons"/><machine type="openDataCommons" uri=""/></use><copyright><human/></copyright></rightsMetadata>').meta(omittable: true)
8
8
  attribute :defaultAccess, AdminPolicyDefaultAccess.optional.meta(omittable: true)
9
- attribute :registrationWorkflow, Types::Strict::Array.of(Types::Strict::String).meta(omittable: true)
9
+ attribute :registrationWorkflow, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
10
10
  # An additional workflow to start for objects managed by this admin policy once the end-accession workflow step is complete
11
11
  # example: wasCrawlPreassemblyWF
12
12
  attribute :disseminationWorkflow, Types::Strict::String.meta(omittable: true)
13
- attribute :collectionsForRegistration, Types::Strict::Array.of(Types::Strict::String).meta(omittable: true)
13
+ attribute :collectionsForRegistration, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
14
14
  # example: druid:bc123df4567
15
15
  attribute :hasAdminPolicy, Types::Strict::String
16
16
  # example: druid:bc123df4567
17
- attribute :referencesAgreement, Types::Strict::String.meta(omittable: true)
18
- attribute :roles, Types::Strict::Array.of(AccessRole).meta(omittable: true)
17
+ attribute :hasAgreement, Types::Strict::String
18
+ attribute :roles, Types::Strict::Array.of(AccessRole).default([].freeze)
19
19
  end
20
20
  end
21
21
  end
@@ -5,7 +5,7 @@ module Cocina
5
5
  class Administrative < Struct
6
6
  # example: druid:bc123df4567
7
7
  attribute :hasAdminPolicy, Types::Strict::String
8
- attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).meta(omittable: true)
8
+ attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).default([].freeze)
9
9
  # Administrative or Internal project this resource is a part of
10
10
  # example: Google Books
11
11
  attribute :partOfProject, Types::Strict::String.meta(omittable: true)
@@ -3,7 +3,7 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class AppliesTo < Struct
6
- attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).meta(omittable: true)
6
+ attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ CocinaVersion = Types::String.constrained(
6
+ format: /^\d+\.\d+\.\d+$/i
7
+ )
8
+ end
9
+ end
@@ -11,6 +11,9 @@ module Cocina
11
11
  'http://cocina.sul.stanford.edu/models/exhibit.jsonld',
12
12
  'http://cocina.sul.stanford.edu/models/series.jsonld'].freeze
13
13
 
14
+ # The version of Cocina with which this object conforms.
15
+ # example: 1.2.3
16
+ attribute :cocinaVersion, Types::Strict::String.default(Cocina::Models::VERSION)
14
17
  # The content type of the Collection. Selected from an established set of values.
15
18
  attribute :type, Types::Strict::String.enum(*Collection::TYPES)
16
19
  # example: druid:bc123df4567
@@ -3,7 +3,7 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class CollectionIdentification < Struct
6
- attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).meta(omittable: true)
6
+ attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
7
7
  # Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
8
8
 
9
9
  # example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
@@ -3,17 +3,17 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class Contributor < Struct
6
- attribute :name, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :name, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
7
  # Entity type of the contributor (person, organization, etc.).
8
8
  attribute :type, Types::Strict::String.meta(omittable: true)
9
9
  # Status of the contributor relative to other parallel contributors (e.g. the primary author among a group of contributors).
10
10
  attribute :status, Types::Strict::String.meta(omittable: true)
11
- attribute :role, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
12
- attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
13
- attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
11
+ attribute :role, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
13
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
14
  # URL or other pointer to the location of the contributor information.
15
15
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
16
- attribute :parallelContributor, Types::Strict::Array.of(DescriptiveParallelContributor).meta(omittable: true)
16
+ attribute :parallelContributor, Types::Strict::Array.of(DescriptiveParallelContributor).default([].freeze)
17
17
  end
18
18
  end
19
19
  end
@@ -4,22 +4,22 @@ module Cocina
4
4
  module Models
5
5
  class Description < Struct
6
6
  attribute :title, Types::Strict::Array.of(Title).default([].freeze)
7
- attribute :contributor, Types::Strict::Array.of(Contributor).meta(omittable: true)
8
- attribute :event, Types::Strict::Array.of(Event).meta(omittable: true)
9
- attribute :form, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
10
- attribute :geographic, Types::Strict::Array.of(DescriptiveGeographicMetadata).meta(omittable: true)
11
- attribute :language, Types::Strict::Array.of(Language).meta(omittable: true)
12
- attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
13
- attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
14
- attribute :subject, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
15
- # Stanford persistent URL associated with the related resource. Note this is http, not https.
16
- attribute :purl, Types::Strict::String.meta(omittable: true)
7
+ attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
8
+ attribute :event, Types::Strict::Array.of(Event).default([].freeze)
9
+ attribute :form, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
10
+ attribute :geographic, Types::Strict::Array.of(DescriptiveGeographicMetadata).default([].freeze)
11
+ attribute :language, Types::Strict::Array.of(Language).default([].freeze)
12
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
13
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
+ attribute :subject, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
17
15
  attribute :access, DescriptiveAccessMetadata.optional.meta(omittable: true)
18
- attribute :relatedResource, Types::Strict::Array.of(RelatedResource).meta(omittable: true)
19
- attribute :marcEncodedData, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
16
+ attribute :relatedResource, Types::Strict::Array.of(RelatedResource).default([].freeze)
17
+ attribute :marcEncodedData, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
20
18
  attribute :adminMetadata, DescriptiveAdminMetadata.optional.meta(omittable: true)
21
19
  # URL or other pointer to the location of the resource description.
22
20
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
21
+ # Stanford persistent URL associated with the related resource. Note this is http, not https.
22
+ attribute :purl, Types::Strict::String
23
23
 
24
24
  def self.new(attributes = default_attributes, safe = false, validate = true, &block)
25
25
  Validator.validate(self, attributes.with_indifferent_access) if validate && name
@@ -3,12 +3,12 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DescriptiveAccessMetadata < Struct
6
- attribute :url, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
7
- attribute :physicalLocation, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
8
- attribute :digitalLocation, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
9
- attribute :accessContact, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
10
- attribute :digitalRepository, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
11
- attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :url, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
+ attribute :physicalLocation, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
+ attribute :digitalLocation, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
9
+ attribute :accessContact, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
10
+ attribute :digitalRepository, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
11
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
12
  end
13
13
  end
14
14
  end
@@ -3,12 +3,12 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DescriptiveAdminMetadata < Struct
6
- attribute :contributor, Types::Strict::Array.of(Contributor).meta(omittable: true)
7
- attribute :event, Types::Strict::Array.of(Event).meta(omittable: true)
8
- attribute :language, Types::Strict::Array.of(Language).meta(omittable: true)
9
- attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
10
- attribute :metadataStandard, Types::Strict::Array.of(Standard).meta(omittable: true)
11
- attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
7
+ attribute :event, Types::Strict::Array.of(Event).default([].freeze)
8
+ attribute :language, Types::Strict::Array.of(Language).default([].freeze)
9
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
10
+ attribute :metadataStandard, Types::Strict::Array.of(Standard).default([].freeze)
11
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
12
  end
13
13
  end
14
14
  end
@@ -3,9 +3,9 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DescriptiveBasicValue < Struct
6
- attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
7
- attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
8
- attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
+ attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
+ attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
9
9
  # String or integer value of the descriptive element.
10
10
  attribute :value, Types::Nominal::Any.meta(omittable: true)
11
11
  # Type of value provided by the descriptive element.
@@ -18,13 +18,13 @@ module Cocina
18
18
  attribute :uri, Types::Strict::String.meta(omittable: true)
19
19
  attribute :standard, Standard.optional.meta(omittable: true)
20
20
  attribute :encoding, Standard.optional.meta(omittable: true)
21
- attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
21
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
22
22
  attribute :source, Source.optional.meta(omittable: true)
23
23
  # The preferred display label to use for the descriptive element in access systems.
24
24
  attribute :displayLabel, Types::Strict::String.meta(omittable: true)
25
25
  # A term providing information about the circumstances of the statement (e.g., approximate dates).
26
26
  attribute :qualifier, Types::Strict::String.meta(omittable: true)
27
- attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
27
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
28
28
  attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
29
29
  # URL or other pointer to the location of the value of the descriptive element.
30
30
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
@@ -3,8 +3,8 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DescriptiveGeographicMetadata < Struct
6
- attribute :form, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
7
- attribute :subject, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :form, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
+ attribute :subject, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
8
8
  end
9
9
  end
10
10
  end
@@ -3,7 +3,7 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DescriptiveGroupedValue < Struct
6
- attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
7
  end
8
8
  end
9
9
  end
@@ -3,14 +3,14 @@
3
3
  module Cocina
4
4
  module Models
5
5
  class DescriptiveParallelContributor < Struct
6
- attribute :name, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
6
+ attribute :name, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
7
7
  # Entity type of the contributor (person, organization, etc.).
8
8
  attribute :type, Types::Strict::String.meta(omittable: true)
9
9
  # Status of the contributor relative to other parallel contributors (e.g. the primary author among a group of contributors).
10
10
  attribute :status, Types::Strict::String.meta(omittable: true)
11
- attribute :role, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
12
- attribute :identifier, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
13
- attribute :note, Types::Strict::Array.of(DescriptiveValue).meta(omittable: true)
11
+ attribute :role, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
12
+ attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
13
+ attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
14
14
  # URL or other pointer to the location of the contributor information.
15
15
  attribute :valueAt, Types::Strict::String.meta(omittable: true)
16
16
  attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)