cocina-models 0.86.0 → 0.87.1
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 +54 -2
- data/.rubocop_todo.yml +49 -15
- data/Gemfile.lock +56 -52
- data/lib/cocina/generator/datatype.rb +1 -1
- data/lib/cocina/generator/generator.rb +19 -12
- data/lib/cocina/generator/schema.rb +4 -2
- data/lib/cocina/generator/schema_array.rb +1 -1
- data/lib/cocina/generator/schema_base.rb +50 -19
- data/lib/cocina/generator/schema_value.rb +3 -3
- data/lib/cocina/generator/union_type.rb +24 -0
- data/lib/cocina/models/admin_policy.rb +2 -2
- data/lib/cocina/models/admin_policy_administrative.rb +2 -2
- data/lib/cocina/models/admin_policy_with_metadata.rb +2 -2
- data/lib/cocina/models/administrative.rb +1 -1
- data/lib/cocina/models/barcode.rb +7 -0
- data/lib/cocina/models/business_barcode.rb +1 -1
- data/lib/cocina/models/catalog_link.rb +1 -10
- data/lib/cocina/models/catkey_barcode.rb +1 -1
- data/lib/cocina/models/cocina_version.rb +1 -1
- data/lib/cocina/models/collection.rb +2 -2
- data/lib/cocina/models/collection_identification.rb +1 -1
- data/lib/cocina/models/collection_with_metadata.rb +2 -2
- data/lib/cocina/models/created_in_folio_identifier.rb +9 -0
- data/lib/cocina/models/description.rb +2 -2
- data/lib/cocina/models/doi.rb +7 -0
- data/lib/cocina/models/doi_exceptions.rb +1 -1
- data/lib/cocina/models/doi_pattern.rb +1 -1
- data/lib/cocina/models/dro.rb +2 -2
- data/lib/cocina/models/dro_with_metadata.rb +2 -2
- data/lib/cocina/models/druid.rb +1 -1
- data/lib/cocina/models/folio_catalog_link.rb +16 -0
- data/lib/cocina/models/identification.rb +3 -3
- data/lib/cocina/models/lane_medical_barcode.rb +1 -1
- data/lib/cocina/models/mapping/from_mods/identifier.rb +1 -1
- data/lib/cocina/models/mapping/from_mods/identifier_builder.rb +1 -1
- data/lib/cocina/models/mapping/normalizers/mods_normalizer.rb +2 -2
- data/lib/cocina/models/migrated_from_symphony_identifier.rb +9 -0
- data/lib/cocina/models/migrated_from_voyager_identifier.rb +9 -0
- data/lib/cocina/models/purl.rb +1 -1
- data/lib/cocina/models/related_resource.rb +2 -2
- data/lib/cocina/models/request_admin_policy.rb +1 -1
- data/lib/cocina/models/request_administrative.rb +1 -1
- data/lib/cocina/models/request_collection.rb +1 -1
- data/lib/cocina/models/request_dro.rb +1 -1
- data/lib/cocina/models/request_identification.rb +2 -2
- data/lib/cocina/models/source_id.rb +1 -1
- data/lib/cocina/models/standard_barcode.rb +1 -1
- data/lib/cocina/models/symphony_catalog_link.rb +17 -0
- data/lib/cocina/models/version.rb +1 -1
- data/lib/cocina/models.rb +7 -3
- data/openapi.yml +366 -317
- metadata +14 -6
@@ -11,10 +11,10 @@ module Cocina
|
|
11
11
|
|
12
12
|
# The version of Cocina with which this object conforms.
|
13
13
|
# example: 1.2.3
|
14
|
-
attribute :cocinaVersion,
|
14
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
15
15
|
attribute :type, Types::Strict::String.enum(*AdminPolicy::TYPES)
|
16
16
|
# example: druid:bc123df4567
|
17
|
-
attribute :externalIdentifier,
|
17
|
+
attribute :externalIdentifier, Druid
|
18
18
|
attribute :label, Types::Strict::String
|
19
19
|
attribute :version, Types::Strict::Integer
|
20
20
|
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
|
@@ -11,9 +11,9 @@ module Cocina
|
|
11
11
|
attribute? :disseminationWorkflow, Types::Strict::String
|
12
12
|
attribute :collectionsForRegistration, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
|
13
13
|
# example: druid:bc123df4567
|
14
|
-
attribute :hasAdminPolicy,
|
14
|
+
attribute :hasAdminPolicy, Druid
|
15
15
|
# example: druid:bc123df4567
|
16
|
-
attribute :hasAgreement,
|
16
|
+
attribute :hasAgreement, Druid
|
17
17
|
attribute :roles, Types::Strict::Array.of(AccessRole).default([].freeze)
|
18
18
|
end
|
19
19
|
end
|
@@ -12,10 +12,10 @@ module Cocina
|
|
12
12
|
|
13
13
|
# The version of Cocina with which this object conforms.
|
14
14
|
# example: 1.2.3
|
15
|
-
attribute :cocinaVersion,
|
15
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
16
16
|
attribute :type, Types::Strict::String.enum(*AdminPolicyWithMetadata::TYPES)
|
17
17
|
# example: druid:bc123df4567
|
18
|
-
attribute :externalIdentifier,
|
18
|
+
attribute :externalIdentifier, Druid
|
19
19
|
attribute :label, Types::Strict::String
|
20
20
|
attribute :version, Types::Strict::Integer
|
21
21
|
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
|
@@ -4,7 +4,7 @@ module Cocina
|
|
4
4
|
module Models
|
5
5
|
class Administrative < Struct
|
6
6
|
# example: druid:bc123df4567
|
7
|
-
attribute :hasAdminPolicy,
|
7
|
+
attribute :hasAdminPolicy, Druid
|
8
8
|
attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).default([].freeze)
|
9
9
|
end
|
10
10
|
end
|
@@ -2,15 +2,6 @@
|
|
2
2
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
|
-
|
6
|
-
# Catalog that is the source of the linked record.
|
7
|
-
# example: symphony
|
8
|
-
attribute :catalog, Types::Strict::String.enum('symphony', 'previous symphony')
|
9
|
-
# Only one of the catkeys should be designated for refreshing. This means that this key is the one used to pull metadata from the catalog if there is more than one key present.
|
10
|
-
attribute :refresh, Types::Strict::Bool.default(false)
|
11
|
-
# Record identifier that is unique within the context of the linked record's catalog.
|
12
|
-
# example: 11403803
|
13
|
-
attribute :catalogRecordId, Types::Strict::String
|
14
|
-
end
|
5
|
+
CatalogLink = FolioCatalogLink | SymphonyCatalogLink
|
15
6
|
end
|
16
7
|
end
|
@@ -16,11 +16,11 @@ module Cocina
|
|
16
16
|
|
17
17
|
# The version of Cocina with which this object conforms.
|
18
18
|
# example: 1.2.3
|
19
|
-
attribute :cocinaVersion,
|
19
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
20
20
|
# The content type of the Collection. Selected from an established set of values.
|
21
21
|
attribute :type, Types::Strict::String.enum(*Collection::TYPES)
|
22
22
|
# example: druid:bc123df4567
|
23
|
-
attribute :externalIdentifier,
|
23
|
+
attribute :externalIdentifier, Druid
|
24
24
|
# Primary processing label (can be same as title) for a Collection.
|
25
25
|
attribute :label, Types::Strict::String
|
26
26
|
# Version for the Collection within SDR.
|
@@ -7,7 +7,7 @@ module Cocina
|
|
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
|
10
|
-
attribute? :sourceId,
|
10
|
+
attribute? :sourceId, SourceId.optional
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -16,11 +16,11 @@ module Cocina
|
|
16
16
|
|
17
17
|
# The version of Cocina with which this object conforms.
|
18
18
|
# example: 1.2.3
|
19
|
-
attribute :cocinaVersion,
|
19
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
20
20
|
# The content type of the Collection. Selected from an established set of values.
|
21
21
|
attribute :type, Types::Strict::String.enum(*CollectionWithMetadata::TYPES)
|
22
22
|
# example: druid:bc123df4567
|
23
|
-
attribute :externalIdentifier,
|
23
|
+
attribute :externalIdentifier, Druid
|
24
24
|
# Primary processing label (can be same as title) for a Collection.
|
25
25
|
attribute :label, Types::Strict::String
|
26
26
|
# Version for the Collection within SDR.
|
@@ -20,8 +20,8 @@ module Cocina
|
|
20
20
|
attribute? :adminMetadata, DescriptiveAdminMetadata.optional
|
21
21
|
# URL or other pointer to the location of the resource description.
|
22
22
|
attribute? :valueAt, Types::Strict::String
|
23
|
-
# Stanford persistent URL associated with the related resource.
|
24
|
-
attribute :purl,
|
23
|
+
# Stanford persistent URL associated with the related resource.
|
24
|
+
attribute :purl, Purl
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
DoiExceptions = Types::String.constrained(
|
6
|
-
format: %r{^10\.(25740/([vV][aA]90-[cC][tT]15|[sS][yY][xX][aA]-[mM]256|12[qQ][fF]-5243|65[jJ]8-6114)|25936/629[tT]-[bB][xX]79)$}
|
6
|
+
format: %r{^10\.(25740/([vV][aA]90-[cC][tT]15|[sS][yY][xX][aA]-[mM]256|12[qQ][fF]-5243|65[jJ]8-6114)|25936/629[tT]-[bB][xX]79)$}
|
7
7
|
)
|
8
8
|
end
|
9
9
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Cocina
|
4
4
|
module Models
|
5
5
|
DoiPattern = Types::String.constrained(
|
6
|
-
format: %r{^10\.(25740|80343)/[b-df-hjkmnp-tv-z]{2}[0-9]{3}[b-df-hjkmnp-tv-z]{2}[0-9]{4}$}
|
6
|
+
format: %r{^10\.(25740|80343)/[b-df-hjkmnp-tv-z]{2}[0-9]{3}[b-df-hjkmnp-tv-z]{2}[0-9]{4}$}
|
7
7
|
)
|
8
8
|
end
|
9
9
|
end
|
data/lib/cocina/models/dro.rb
CHANGED
@@ -26,11 +26,11 @@ module Cocina
|
|
26
26
|
|
27
27
|
# The version of Cocina with which this object conforms.
|
28
28
|
# example: 1.2.3
|
29
|
-
attribute :cocinaVersion,
|
29
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
30
30
|
# The content type of the DRO. Selected from an established set of values.
|
31
31
|
attribute :type, Types::Strict::String.enum(*DRO::TYPES)
|
32
32
|
# example: druid:bc123df4567
|
33
|
-
attribute :externalIdentifier,
|
33
|
+
attribute :externalIdentifier, Druid
|
34
34
|
# Primary processing label (can be same as title) for a DRO.
|
35
35
|
attribute :label, Types::Strict::String
|
36
36
|
# Version for the DRO within SDR.
|
@@ -26,11 +26,11 @@ module Cocina
|
|
26
26
|
|
27
27
|
# The version of Cocina with which this object conforms.
|
28
28
|
# example: 1.2.3
|
29
|
-
attribute :cocinaVersion,
|
29
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
30
30
|
# The content type of the DRO. Selected from an established set of values.
|
31
31
|
attribute :type, Types::Strict::String.enum(*DROWithMetadata::TYPES)
|
32
32
|
# example: druid:bc123df4567
|
33
|
-
attribute :externalIdentifier,
|
33
|
+
attribute :externalIdentifier, Druid
|
34
34
|
# Primary processing label (can be same as title) for a DRO.
|
35
35
|
attribute :label, Types::Strict::String
|
36
36
|
# Version for the DRO within SDR.
|
data/lib/cocina/models/druid.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
# A linkage between an object and a Folio catalog record
|
6
|
+
class FolioCatalogLink < Struct
|
7
|
+
# Catalog that is the source of the linked record.
|
8
|
+
# example: folio
|
9
|
+
attribute :catalog, Types::Strict::String.enum('folio', 'previous folio')
|
10
|
+
# Only one of the catkeys should be designated for refreshing. This means that this key is the one used to pull metadata from the catalog if there is more than one key present.
|
11
|
+
attribute :refresh, Types::Strict::Bool.default(false)
|
12
|
+
# Record identifier that is unique within the context of the linked record's catalog.
|
13
|
+
attribute :catalogRecordId, MigratedFromSymphonyIdentifier | MigratedFromVoyagerIdentifier | CreatedInFolioIdentifier
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -4,14 +4,14 @@ module Cocina
|
|
4
4
|
module Models
|
5
5
|
class Identification < Struct
|
6
6
|
# A barcode
|
7
|
-
attribute? :barcode,
|
7
|
+
attribute? :barcode, Barcode.optional
|
8
8
|
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
9
9
|
# Digital Object Identifier (https://www.doi.org)
|
10
|
-
attribute? :doi,
|
10
|
+
attribute? :doi, DOI.optional
|
11
11
|
# 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"
|
12
12
|
|
13
13
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
14
|
-
attribute :sourceId,
|
14
|
+
attribute :sourceId, SourceId
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -42,7 +42,7 @@ module Cocina
|
|
42
42
|
def identifiers
|
43
43
|
(resource_element.xpath('mods:identifier', mods: Description::DESC_METADATA_NS) +
|
44
44
|
resource_element.xpath('mods:recordIdentifier',
|
45
|
-
mods: Description::DESC_METADATA_NS)).reject { |identifier_node| identifier_node.text.blank? && identifier_node.attributes.
|
45
|
+
mods: Description::DESC_METADATA_NS)).reject { |identifier_node| identifier_node.text.blank? && identifier_node.attributes.empty? }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -31,7 +31,7 @@ module Cocina
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def build
|
34
|
-
return if identifier_element.text.blank? && identifier_element.attributes.
|
34
|
+
return if identifier_element.text.blank? && identifier_element.attributes.empty?
|
35
35
|
|
36
36
|
{
|
37
37
|
displayLabel: identifier_element['displayLabel']
|
@@ -105,9 +105,9 @@ module Cocina
|
|
105
105
|
return unless start_node
|
106
106
|
|
107
107
|
# remove node if there are no element children, there is no text value and there are no attributes
|
108
|
-
if start_node.elements.
|
108
|
+
if start_node.elements.empty? &&
|
109
109
|
start_node.text.blank? &&
|
110
|
-
start_node.attributes.
|
110
|
+
start_node.attributes.empty? &&
|
111
111
|
start_node.name != 'etal'
|
112
112
|
parent = start_node.parent
|
113
113
|
start_node.remove
|
data/lib/cocina/models/purl.rb
CHANGED
@@ -19,8 +19,8 @@ module Cocina
|
|
19
19
|
attribute :identifier, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
20
20
|
attribute? :standard, Standard.optional
|
21
21
|
attribute :subject, Types::Strict::Array.of(DescriptiveValue).default([].freeze)
|
22
|
-
# Stanford persistent URL associated with the related resource.
|
23
|
-
attribute? :purl,
|
22
|
+
# Stanford persistent URL associated with the related resource.
|
23
|
+
attribute? :purl, Purl.optional
|
24
24
|
attribute? :access, DescriptiveAccessMetadata.optional
|
25
25
|
attribute :relatedResource, Types::Strict::Array.of(RelatedResource).default([].freeze)
|
26
26
|
attribute? :adminMetadata, DescriptiveAdminMetadata.optional
|
@@ -12,7 +12,7 @@ module Cocina
|
|
12
12
|
|
13
13
|
# The version of Cocina with which this object conforms.
|
14
14
|
# example: 1.2.3
|
15
|
-
attribute :cocinaVersion,
|
15
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
16
16
|
attribute :type, Types::Strict::String.enum(*RequestAdminPolicy::TYPES)
|
17
17
|
attribute :label, Types::Strict::String
|
18
18
|
attribute :version, Types::Strict::Integer.default(1).enum(1)
|
@@ -4,7 +4,7 @@ module Cocina
|
|
4
4
|
module Models
|
5
5
|
class RequestAdministrative < Struct
|
6
6
|
# example: druid:bc123df4567
|
7
|
-
attribute :hasAdminPolicy,
|
7
|
+
attribute :hasAdminPolicy, Druid
|
8
8
|
attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).default([].freeze)
|
9
9
|
# Internal project this resource is a part of. This governs routing of messages about this object.
|
10
10
|
# example: Google Books
|
@@ -16,7 +16,7 @@ module Cocina
|
|
16
16
|
|
17
17
|
# The version of Cocina with which this object conforms.
|
18
18
|
# example: 1.2.3
|
19
|
-
attribute :cocinaVersion,
|
19
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
20
20
|
attribute :type, Types::Strict::String.enum(*RequestCollection::TYPES)
|
21
21
|
attribute :label, Types::Strict::String
|
22
22
|
attribute :version, Types::Strict::Integer.default(1).enum(1)
|
@@ -26,7 +26,7 @@ module Cocina
|
|
26
26
|
|
27
27
|
# The version of Cocina with which this object conforms.
|
28
28
|
# example: 1.2.3
|
29
|
-
attribute :cocinaVersion,
|
29
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
30
30
|
attribute :type, Types::Strict::String.enum(*RequestDRO::TYPES)
|
31
31
|
attribute :label, Types::Strict::String
|
32
32
|
attribute :version, Types::Strict::Integer.default(1).enum(1)
|
@@ -5,12 +5,12 @@ module Cocina
|
|
5
5
|
# Same as a Identification, but requires a sourceId and doesn't permit a DOI.
|
6
6
|
class RequestIdentification < Struct
|
7
7
|
# A barcode
|
8
|
-
attribute? :barcode,
|
8
|
+
attribute? :barcode, Barcode.optional
|
9
9
|
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).default([].freeze)
|
10
10
|
# 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"
|
11
11
|
|
12
12
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
13
|
-
attribute :sourceId,
|
13
|
+
attribute :sourceId, SourceId
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
# A linkage between an object and a Symphony catalog record
|
6
|
+
class SymphonyCatalogLink < Struct
|
7
|
+
# Catalog that is the source of the linked record.
|
8
|
+
# example: symphony
|
9
|
+
attribute :catalog, Types::Strict::String.enum('symphony', 'previous symphony')
|
10
|
+
# Only one of the catkeys should be designated for refreshing. This means that this key is the one used to pull metadata from the catalog if there is more than one key present.
|
11
|
+
attribute :refresh, Types::Strict::Bool.default(false)
|
12
|
+
# Record identifier that is unique within the context of the linked record's catalog.
|
13
|
+
# example: 11403803
|
14
|
+
attribute :catalogRecordId, Types::Strict::String.constrained(format: /^\d+$/)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/cocina/models.rb
CHANGED
@@ -148,9 +148,13 @@ module Cocina
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def self.type_for(dyn)
|
151
|
-
|
152
|
-
|
153
|
-
|
151
|
+
# Intentionally checking both string- and symbol-type keys in the hash via `#[]`
|
152
|
+
# instead of `#with_indifferent_access` (and/or `#fetch`) in order to be more memory-efficient
|
153
|
+
object_type = dyn[:type] || dyn['type']
|
154
|
+
|
155
|
+
raise(ValidationError, 'Type field not found') unless object_type
|
156
|
+
|
157
|
+
object_type
|
154
158
|
end
|
155
159
|
private_class_method :type_for
|
156
160
|
|