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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +9 -48
- data/.rubocop.yml +116 -1
- data/.rubocop_todo.yml +5 -4
- data/Gemfile +1 -0
- data/README.md +19 -6
- data/cocina-models.gemspec +6 -4
- data/docs/maps/Collection.json +0 -5
- data/docs/maps/DRO.json +0 -5
- data/lib/cocina/generator/schema_array.rb +1 -9
- data/lib/cocina/generator/schema_value.rb +4 -0
- data/lib/cocina/models/admin_policy.rb +3 -0
- data/lib/cocina/models/admin_policy_administrative.rb +4 -4
- data/lib/cocina/models/administrative.rb +1 -1
- data/lib/cocina/models/applies_to.rb +1 -1
- data/lib/cocina/models/cocina_version.rb +9 -0
- data/lib/cocina/models/collection.rb +3 -0
- data/lib/cocina/models/collection_identification.rb +1 -1
- data/lib/cocina/models/contributor.rb +5 -5
- data/lib/cocina/models/description.rb +12 -12
- data/lib/cocina/models/descriptive_access_metadata.rb +6 -6
- data/lib/cocina/models/descriptive_admin_metadata.rb +6 -6
- data/lib/cocina/models/descriptive_basic_value.rb +5 -5
- data/lib/cocina/models/descriptive_geographic_metadata.rb +2 -2
- data/lib/cocina/models/descriptive_grouped_value.rb +1 -1
- data/lib/cocina/models/descriptive_parallel_contributor.rb +4 -4
- data/lib/cocina/models/descriptive_parallel_event.rb +6 -6
- data/lib/cocina/models/descriptive_parallel_value.rb +1 -1
- data/lib/cocina/models/descriptive_structured_value.rb +1 -1
- data/lib/cocina/models/descriptive_value.rb +6 -6
- data/lib/cocina/models/descriptive_value_language.rb +1 -1
- data/lib/cocina/models/dro.rb +3 -0
- data/lib/cocina/models/dro_access.rb +1 -1
- data/lib/cocina/models/dro_structural.rb +3 -5
- data/lib/cocina/models/event.rb +7 -7
- data/lib/cocina/models/file_set_structural.rb +1 -1
- data/lib/cocina/models/identification.rb +3 -3
- data/lib/cocina/models/language.rb +5 -5
- data/lib/cocina/models/related_resource.rb +9 -9
- data/lib/cocina/models/request_admin_policy.rb +4 -1
- data/lib/cocina/models/request_collection.rb +4 -1
- data/lib/cocina/models/request_description.rb +28 -0
- data/lib/cocina/models/request_dro.rb +4 -1
- data/lib/cocina/models/request_dro_structural.rb +3 -4
- data/lib/cocina/models/request_file_set_structural.rb +1 -1
- data/lib/cocina/models/request_identification.rb +2 -2
- data/lib/cocina/models/sequence.rb +1 -1
- data/lib/cocina/models/source.rb +1 -1
- data/lib/cocina/models/standard.rb +1 -1
- data/lib/cocina/models/title.rb +6 -6
- data/lib/cocina/models/validator.rb +21 -1
- data/lib/cocina/models/version.rb +1 -1
- data/openapi.yml +124 -80
- metadata +30 -13
@@ -3,16 +3,16 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class DescriptiveParallelEvent < Struct
|
6
|
-
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).
|
6
|
+
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
7
7
|
# Description of the event (creation, publication, etc.).
|
8
8
|
attribute :type, Types::Strict::String.meta(omittable: true)
|
9
9
|
# The preferred display label to use for the event in access systems.
|
10
10
|
attribute :displayLabel, Types::Strict::String.meta(omittable: true)
|
11
|
-
attribute :date, Types::Strict::Array.of(DescriptiveValue).
|
12
|
-
attribute :contributor, Types::Strict::Array.of(Contributor).
|
13
|
-
attribute :location, Types::Strict::Array.of(DescriptiveValue).
|
14
|
-
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).
|
15
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
11
|
+
attribute :date, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
12
|
+
attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
|
13
|
+
attribute :location, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
14
|
+
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
15
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
16
16
|
attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
|
17
17
|
end
|
18
18
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class DescriptiveParallelValue < Struct
|
6
|
-
attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).
|
6
|
+
attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class DescriptiveStructuredValue < Struct
|
6
|
-
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).
|
6
|
+
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class DescriptiveValue < Struct
|
6
|
-
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).
|
7
|
-
attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).
|
8
|
-
attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).
|
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,17 +18,17 @@ 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).
|
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).
|
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)
|
31
|
-
attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).
|
31
|
+
attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -9,7 +9,7 @@ module Cocina
|
|
9
9
|
attribute :uri, Types::Strict::String.meta(omittable: true)
|
10
10
|
# String describing the standard or encoding.
|
11
11
|
attribute :value, Types::Strict::String.meta(omittable: true)
|
12
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
12
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
13
13
|
# The version of the standard or encoding.
|
14
14
|
attribute :version, Types::Strict::String.meta(omittable: true)
|
15
15
|
attribute :source, Source.optional.meta(omittable: true)
|
data/lib/cocina/models/dro.rb
CHANGED
@@ -21,6 +21,9 @@ module Cocina
|
|
21
21
|
'http://cocina.sul.stanford.edu/models/webarchive-binary.jsonld',
|
22
22
|
'http://cocina.sul.stanford.edu/models/webarchive-seed.jsonld'].freeze
|
23
23
|
|
24
|
+
# The version of Cocina with which this object conforms.
|
25
|
+
# example: 1.2.3
|
26
|
+
attribute :cocinaVersion, Types::Strict::String.default(Cocina::Models::VERSION)
|
24
27
|
# The content type of the DRO. Selected from an established set of values.
|
25
28
|
attribute :type, Types::Strict::String.enum(*DRO::TYPES)
|
26
29
|
# example: druid:bc123df4567
|
@@ -22,7 +22,7 @@ module Cocina
|
|
22
22
|
# example: Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Public Services Librarian of the Dept. of Special Collections (http://library.stanford.edu/spc).
|
23
23
|
attribute :useAndReproductionStatement, Types::Strict::String.meta(omittable: true)
|
24
24
|
# The license governing reuse of the DRO. Should be an IRI for known licenses (i.e. CC, RightsStatement.org URI, etc.).
|
25
|
-
attribute :license, Types::Strict::String.enum('https://www.gnu.org/licenses/agpl.txt', 'https://www.apache.org/licenses/LICENSE-2.0', 'https://opensource.org/licenses/BSD-2-Clause', 'https://opensource.org/licenses/BSD-3-Clause', 'https://creativecommons.org/licenses/by/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode', 'https://creativecommons.org/licenses/by-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-sa/4.0/legalcode', 'https://creativecommons.org/publicdomain/zero/1.0/legalcode', 'https://opensource.org/licenses/cddl1', 'https://www.eclipse.org/legal/epl-2.0', 'https://www.gnu.org/licenses/gpl-3.0-standalone.html', 'https://www.isc.org/downloads/software-support-policy/isc-license/', 'https://www.gnu.org/licenses/lgpl-3.0-standalone.html', 'https://opensource.org/licenses/MIT', 'https://www.mozilla.org/MPL/2.0/', 'https://opendatacommons.org/licenses/by/1-0/', 'http://opendatacommons.org/licenses/odbl/1.0/', 'https://opendatacommons.org/licenses/odbl/1-0/', 'https://creativecommons.org/publicdomain/mark/1.0/', 'https://opendatacommons.org/licenses/pddl/1-0/', 'https://creativecommons.org/licenses/by/3.0/legalcode', 'https://creativecommons.org/licenses/by-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nd/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode', 'http://cocina.sul.stanford.edu/licenses/none').meta(omittable: true)
|
25
|
+
attribute :license, Types::Strict::String.optional.enum('https://www.gnu.org/licenses/agpl.txt', 'https://www.apache.org/licenses/LICENSE-2.0', 'https://opensource.org/licenses/BSD-2-Clause', 'https://opensource.org/licenses/BSD-3-Clause', 'https://creativecommons.org/licenses/by/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode', 'https://creativecommons.org/licenses/by-nd/4.0/legalcode', 'https://creativecommons.org/licenses/by-sa/4.0/legalcode', 'https://creativecommons.org/publicdomain/zero/1.0/legalcode', 'https://opensource.org/licenses/cddl1', 'https://www.eclipse.org/legal/epl-2.0', 'https://www.gnu.org/licenses/gpl-3.0-standalone.html', 'https://www.isc.org/downloads/software-support-policy/isc-license/', 'https://www.gnu.org/licenses/lgpl-3.0-standalone.html', 'https://opensource.org/licenses/MIT', 'https://www.mozilla.org/MPL/2.0/', 'https://opendatacommons.org/licenses/by/1-0/', 'http://opendatacommons.org/licenses/odbl/1.0/', 'https://opendatacommons.org/licenses/odbl/1-0/', 'https://creativecommons.org/publicdomain/mark/1.0/', 'https://opendatacommons.org/licenses/pddl/1-0/', 'https://creativecommons.org/licenses/by/3.0/legalcode', 'https://creativecommons.org/licenses/by-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nd/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode', 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode', 'http://cocina.sul.stanford.edu/licenses/none').meta(omittable: true)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -3,11 +3,9 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class DROStructural < Struct
|
6
|
-
attribute :contains, Types::Strict::Array.of(FileSet).
|
7
|
-
attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).
|
8
|
-
attribute :isMemberOf, Types::Strict::Array.of(Druid).
|
9
|
-
# Agreement that covers the deposit of the DRO into SDR.
|
10
|
-
attribute :hasAgreement, Types::Strict::String.meta(omittable: true)
|
6
|
+
attribute :contains, Types::Strict::Array.of(FileSet).default([].freeze)
|
7
|
+
attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).default([].freeze)
|
8
|
+
attribute :isMemberOf, Types::Strict::Array.of(Druid).default([].freeze)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
data/lib/cocina/models/event.rb
CHANGED
@@ -3,18 +3,18 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class Event < Struct
|
6
|
-
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).
|
6
|
+
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
7
7
|
# Description of the event (creation, publication, etc.).
|
8
8
|
attribute :type, Types::Strict::String.meta(omittable: true)
|
9
9
|
# The preferred display label to use for the event in access systems.
|
10
10
|
attribute :displayLabel, Types::Strict::String.meta(omittable: true)
|
11
|
-
attribute :date, Types::Strict::Array.of(DescriptiveValue).
|
12
|
-
attribute :contributor, Types::Strict::Array.of(Contributor).
|
13
|
-
attribute :location, Types::Strict::Array.of(DescriptiveValue).
|
14
|
-
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).
|
15
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
11
|
+
attribute :date, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
12
|
+
attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
|
13
|
+
attribute :location, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
14
|
+
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
15
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
16
16
|
attribute :valueLanguage, DescriptiveValueLanguage.optional.meta(omittable: true)
|
17
|
-
attribute :parallelEvent, Types::Strict::Array.of(DescriptiveParallelEvent).
|
17
|
+
attribute :parallelEvent, Types::Strict::Array.of(DescriptiveParallelEvent).default([].freeze)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -4,10 +4,10 @@ module Cocina
|
|
4
4
|
module Models
|
5
5
|
class Identification < Struct
|
6
6
|
# A barcode
|
7
|
-
attribute :barcode, Types::Nominal::Any.meta(omittable: true)
|
8
|
-
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).
|
7
|
+
attribute :barcode, Types::Nominal::Any.optional.meta(omittable: true)
|
8
|
+
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
9
9
|
# Digital Object Identifier (https://www.doi.org)
|
10
|
-
# example: 10.25740/
|
10
|
+
# example: 10.25740/bc123df4567
|
11
11
|
attribute :doi, Types::Strict::String.meta(omittable: true)
|
12
12
|
# 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"
|
13
13
|
|
@@ -3,15 +3,15 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class Language < Struct
|
6
|
-
attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).
|
6
|
+
attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
|
7
7
|
# Code value of the descriptive element.
|
8
8
|
attribute :code, Types::Strict::String.meta(omittable: true)
|
9
9
|
# The preferred display label to use for the descriptive element in access systems.
|
10
10
|
attribute :displayLabel, Types::Strict::String.meta(omittable: true)
|
11
11
|
attribute :encoding, Standard.optional.meta(omittable: true)
|
12
|
-
attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).
|
13
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
14
|
-
attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).
|
12
|
+
attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
13
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
14
|
+
attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
15
15
|
# present for mapping to additional schemas in the future and for consistency but not otherwise used
|
16
16
|
attribute :qualifier, Types::Strict::String.meta(omittable: true)
|
17
17
|
attribute :script, DescriptiveValue.optional.meta(omittable: true)
|
@@ -19,7 +19,7 @@ module Cocina
|
|
19
19
|
# Status of the language relative to other parallel language elements (e.g. the primary language)
|
20
20
|
attribute :status, Types::Strict::String.enum('primary').meta(omittable: true)
|
21
21
|
attribute :standard, Standard.optional.meta(omittable: true)
|
22
|
-
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).
|
22
|
+
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
23
23
|
# URI value of the descriptive element.
|
24
24
|
attribute :uri, Types::Strict::String.meta(omittable: true)
|
25
25
|
# Value of the descriptive element.
|
@@ -9,19 +9,19 @@ module Cocina
|
|
9
9
|
attribute :status, Types::Strict::String.meta(omittable: true)
|
10
10
|
# The preferred display label to use for the related resource in access systems.
|
11
11
|
attribute :displayLabel, Types::Strict::String.meta(omittable: true)
|
12
|
-
attribute :title, Types::Strict::Array.of(DescriptiveValue).
|
13
|
-
attribute :contributor, Types::Strict::Array.of(Contributor).
|
14
|
-
attribute :event, Types::Strict::Array.of(Event).
|
15
|
-
attribute :form, Types::Strict::Array.of(DescriptiveValue).
|
16
|
-
attribute :language, Types::Strict::Array.of(Language).
|
17
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
18
|
-
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).
|
12
|
+
attribute :title, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
13
|
+
attribute :contributor, Types::Strict::Array.of(Contributor).default([].freeze)
|
14
|
+
attribute :event, Types::Strict::Array.of(Event).default([].freeze)
|
15
|
+
attribute :form, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
16
|
+
attribute :language, Types::Strict::Array.of(Language).default([].freeze)
|
17
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
18
|
+
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
19
19
|
attribute :standard, Standard.optional.meta(omittable: true)
|
20
|
-
attribute :subject, Types::Strict::Array.of(DescriptiveValue).
|
20
|
+
attribute :subject, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
21
21
|
# Stanford persistent URL associated with the related resource. Note this is http, not https.
|
22
22
|
attribute :purl, Types::Strict::String.meta(omittable: true)
|
23
23
|
attribute :access, DescriptiveAccessMetadata.optional.meta(omittable: true)
|
24
|
-
attribute :relatedResource, Types::Strict::Array.of(RelatedResource).
|
24
|
+
attribute :relatedResource, Types::Strict::Array.of(RelatedResource).default([].freeze)
|
25
25
|
attribute :adminMetadata, DescriptiveAdminMetadata.optional.meta(omittable: true)
|
26
26
|
# The version of the related resource.
|
27
27
|
attribute :version, Types::Strict::String.meta(omittable: true)
|
@@ -7,11 +7,14 @@ 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(*RequestAdminPolicy::TYPES)
|
11
14
|
attribute :label, Types::Strict::String
|
12
15
|
attribute :version, Types::Strict::Integer
|
13
16
|
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
|
14
|
-
attribute :description,
|
17
|
+
attribute :description, RequestDescription.optional.meta(omittable: true)
|
15
18
|
|
16
19
|
def self.new(attributes = default_attributes, safe = false, validate = true, &block)
|
17
20
|
Validator.validate(self, attributes.with_indifferent_access) if validate && name
|
@@ -11,12 +11,15 @@ 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
|
attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
|
15
18
|
attribute :label, Types::Strict::String
|
16
19
|
attribute :version, Types::Strict::Integer
|
17
20
|
attribute(:access, CollectionAccess.default { CollectionAccess.new })
|
18
21
|
attribute(:administrative, Administrative.default { Administrative.new })
|
19
|
-
attribute :description,
|
22
|
+
attribute :description, RequestDescription.optional.meta(omittable: true)
|
20
23
|
attribute :identification, CollectionIdentification.optional.meta(omittable: true)
|
21
24
|
|
22
25
|
def self.new(attributes = default_attributes, safe = false, validate = true, &block)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
class RequestDescription < Struct
|
6
|
+
attribute :title, Types::Strict::Array.of(Title).default([].freeze)
|
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)
|
15
|
+
attribute :access, DescriptiveAccessMetadata.optional.meta(omittable: true)
|
16
|
+
attribute :relatedResource, Types::Strict::Array.of(RelatedResource).default([].freeze)
|
17
|
+
attribute :marcEncodedData, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
18
|
+
attribute :adminMetadata, DescriptiveAdminMetadata.optional.meta(omittable: true)
|
19
|
+
# URL or other pointer to the location of the resource description.
|
20
|
+
attribute :valueAt, Types::Strict::String.meta(omittable: true)
|
21
|
+
|
22
|
+
def self.new(attributes = default_attributes, safe = false, validate = true, &block)
|
23
|
+
Validator.validate(self, attributes.with_indifferent_access) if validate && name
|
24
|
+
super(attributes, safe, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -21,12 +21,15 @@ module Cocina
|
|
21
21
|
'http://cocina.sul.stanford.edu/models/webarchive-binary.jsonld',
|
22
22
|
'http://cocina.sul.stanford.edu/models/webarchive-seed.jsonld'].freeze
|
23
23
|
|
24
|
+
# The version of Cocina with which this object conforms.
|
25
|
+
# example: 1.2.3
|
26
|
+
attribute :cocinaVersion, Types::Strict::String.default(Cocina::Models::VERSION)
|
24
27
|
attribute :type, Types::Strict::String.enum(*RequestDRO::TYPES)
|
25
28
|
attribute :label, Types::Strict::String
|
26
29
|
attribute :version, Types::Strict::Integer
|
27
30
|
attribute :access, DROAccess.optional.meta(omittable: true)
|
28
31
|
attribute(:administrative, Administrative.default { Administrative.new })
|
29
|
-
attribute :description,
|
32
|
+
attribute :description, RequestDescription.optional.meta(omittable: true)
|
30
33
|
attribute(:identification, RequestIdentification.default { RequestIdentification.new })
|
31
34
|
attribute :structural, RequestDROStructural.optional.meta(omittable: true)
|
32
35
|
attribute :geographic, Geographic.optional.meta(omittable: true)
|
@@ -3,10 +3,9 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class RequestDROStructural < Struct
|
6
|
-
attribute :contains, Types::Strict::Array.of(RequestFileSet).
|
7
|
-
attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).
|
8
|
-
attribute :isMemberOf, Types::Strict::Array.of(Druid).
|
9
|
-
attribute :hasAgreement, Types::Strict::String.meta(omittable: true)
|
6
|
+
attribute :contains, Types::Strict::Array.of(RequestFileSet).default([].freeze)
|
7
|
+
attribute :hasMemberOrders, Types::Strict::Array.of(Sequence).default([].freeze)
|
8
|
+
attribute :isMemberOf, Types::Strict::Array.of(Druid).default([].freeze)
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
@@ -4,8 +4,8 @@ module Cocina
|
|
4
4
|
module Models
|
5
5
|
class RequestIdentification < Struct
|
6
6
|
# A barcode
|
7
|
-
attribute :barcode, Types::Nominal::Any.meta(omittable: true)
|
8
|
-
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).
|
7
|
+
attribute :barcode, Types::Nominal::Any.optional.meta(omittable: true)
|
8
|
+
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
9
9
|
# 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"
|
10
10
|
|
11
11
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class Sequence < Struct
|
6
|
-
attribute :members, Types::Strict::Array.of(Types::Strict::String).
|
6
|
+
attribute :members, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
|
7
7
|
# The direction that a sequence of canvases should be displayed to the user
|
8
8
|
attribute :viewingDirection, Types::Strict::String.enum('right-to-left', 'left-to-right').meta(omittable: true)
|
9
9
|
end
|
data/lib/cocina/models/source.rb
CHANGED
@@ -9,7 +9,7 @@ module Cocina
|
|
9
9
|
attribute :uri, Types::Strict::String.meta(omittable: true)
|
10
10
|
# String describing the value source.
|
11
11
|
attribute :value, Types::Strict::String.meta(omittable: true)
|
12
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
12
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
13
13
|
# The version of the value source.
|
14
14
|
attribute :version, Types::Strict::String.meta(omittable: true)
|
15
15
|
end
|
@@ -9,7 +9,7 @@ module Cocina
|
|
9
9
|
attribute :uri, Types::Strict::String.meta(omittable: true)
|
10
10
|
# String describing the standard or encoding.
|
11
11
|
attribute :value, Types::Strict::String.meta(omittable: true)
|
12
|
-
attribute :note, Types::Strict::Array.of(DescriptiveValue).
|
12
|
+
attribute :note, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
13
13
|
# The version of the standard or encoding.
|
14
14
|
attribute :version, Types::Strict::String.meta(omittable: true)
|
15
15
|
attribute :source, Source.optional.meta(omittable: true)
|
data/lib/cocina/models/title.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
class Title < Struct
|
6
|
-
attribute :structuredValue, Types::Strict::Array.of(DescriptiveValue).
|
7
|
-
attribute :parallelValue, Types::Strict::Array.of(DescriptiveValue).
|
8
|
-
attribute :groupedValue, Types::Strict::Array.of(DescriptiveValue).
|
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,17 +18,17 @@ 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).
|
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).
|
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)
|
31
|
-
attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).
|
31
|
+
attribute :appliesTo, Types::Strict::Array.of(DescriptiveBasicValue).default([].freeze)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -7,12 +7,32 @@ module Cocina
|
|
7
7
|
def self.validate(clazz, attributes)
|
8
8
|
method_name = clazz.name.split('::').last
|
9
9
|
request_operation = root.request_operation(:post, "/validate/#{method_name}")
|
10
|
+
|
10
11
|
# JSON.parse forces serialization of objects like DateTime.
|
11
|
-
|
12
|
+
json_attributes = JSON.parse(attributes.to_json)
|
13
|
+
# Inject cocinaVersion if needed and not present.
|
14
|
+
if operation_has_cocina_version?(request_operation) && !json_attributes.include?('cocinaVersion')
|
15
|
+
json_attributes['cocinaVersion'] = Cocina::Models::VERSION
|
16
|
+
end
|
17
|
+
|
18
|
+
request_operation.validate_request_body('application/json', json_attributes)
|
12
19
|
rescue OpenAPIParser::OpenAPIError => e
|
13
20
|
raise ValidationError, e.message
|
14
21
|
end
|
15
22
|
|
23
|
+
# rubocop:disable Metrics/AbcSize
|
24
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
25
|
+
def self.operation_has_cocina_version?(request_operation)
|
26
|
+
schema = request_operation.operation_object.request_body.content['application/json'].schema
|
27
|
+
all_of_properties = Array(schema.all_of&.flat_map { |all_of| all_of.properties&.keys }).compact
|
28
|
+
one_of_properties = Array(schema.one_of&.flat_map { |one_of| one_of.properties&.keys }).compact
|
29
|
+
properties = Array(schema.properties&.keys)
|
30
|
+
(properties + all_of_properties + one_of_properties).include?('cocinaVersion')
|
31
|
+
end
|
32
|
+
# rubocop:enable Metrics/AbcSize
|
33
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
34
|
+
private_class_method :operation_has_cocina_version?
|
35
|
+
|
16
36
|
# rubocop:disable Style/ClassVars
|
17
37
|
def self.root
|
18
38
|
@@root ||= OpenAPIParser.parse(YAML.load_file(openapi_path))
|