cocina-models 0.70.0 → 0.71.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +11 -0
- data/cocina-models.gemspec +1 -0
- data/lib/cocina/models/identification.rb +1 -1
- data/lib/cocina/models/title_builder.rb +20 -15
- data/lib/cocina/models/version.rb +1 -1
- data/openapi.yml +3 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5058bc2927b8788ad9c04142decbfcc7cf42b7daa3b84665d64dd00b432d8ff4
|
4
|
+
data.tar.gz: 524263003bc679432b5c120690775de4ebc14ef5fa6158337e0beff9c2bfb332
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84f98459177c74cc822a8dee105412c7023c3fda2e953e1f760c482ae3a2967f610207bb53cd33c510e2b0c861834b4cf1998459b70035ac9b22aa55c83b910
|
7
|
+
data.tar.gz: '018baa839ef5774c3969f91acb9545fb04ddf3be652ae3f3fafbc6458ddd7ec1d7c4ae5d5d33a9a8eab36476519cd310a33b61da34e4f934bef35ef490dc83fd'
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -101,6 +101,16 @@ If for some reason the above method does not work, the sul-dlss/access-update-sc
|
|
101
101
|
|
102
102
|
[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).
|
103
103
|
|
104
|
+
Note that running the integration tests is currently the best way we have to check for unintended effects and/or bugs when rolling out cocina-models changes.
|
105
|
+
|
106
|
+
#### Step 5A: Deploy to QA and/or Stage
|
107
|
+
|
108
|
+
#### Step 5B: Run infrastructure_integration_tests
|
109
|
+
|
110
|
+
It is safest to ensure _all_ the integration tests run cleanly. However, patch releases of cocina-models may only warrant running individual tests that exercise the changes.
|
111
|
+
|
112
|
+
#### Step 5C: Deploy to Production
|
113
|
+
|
104
114
|
**[Turn off Google Books](https://sul-gbooks-prod.stanford.edu/features) when deploying to production.** This avoids failed deposit due to a temporary Cocina model mismatch. Unlike other applications, the deposits will fail without retry and require manual remediation.
|
105
115
|
|
106
116
|
## Usage conventions
|
@@ -108,6 +118,7 @@ If for some reason the above method does not work, the sul-dlss/access-update-sc
|
|
108
118
|
The following are the recommended naming conventions for code using Cocina models:
|
109
119
|
|
110
120
|
* `cocina_item`: `Cocina::Models::DRO` instance
|
121
|
+
* `cocina_agreement`: `Cocina::Models::DRO` with type of Cocina::Models::ObjectType.agreement
|
111
122
|
* `cocina_admin_policy`: `Cocina::Models::AdminPolicy` instance
|
112
123
|
* `cocina_collection`: `Cocina::Models::Collection` instance
|
113
124
|
* `cocina_object`: `Cocina::Models::DRO` or `Cocina::Models::AdminPolicy` or `Cocina::Models::Collection` instance
|
data/cocina-models.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.required_ruby_version = '>= 2.7'
|
26
26
|
|
27
27
|
spec.add_dependency 'activesupport'
|
28
|
+
spec.add_dependency 'deprecation'
|
28
29
|
spec.add_dependency 'dry-struct', '~> 1.0'
|
29
30
|
spec.add_dependency 'dry-types', '~> 1.1'
|
30
31
|
spec.add_dependency 'openapi3_parser' # Parsing openapi doc
|
@@ -12,7 +12,7 @@ module Cocina
|
|
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
|
|
14
14
|
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
|
15
|
-
attribute :sourceId, Types::Strict::String
|
15
|
+
attribute :sourceId, Types::Strict::String
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,30 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'deprecation'
|
4
|
+
|
3
5
|
module Cocina
|
4
6
|
module Models
|
5
7
|
# TitleBuilder selects the prefered title from the cocina object for solr indexing
|
6
8
|
# rubocop:disable Metrics/ClassLength
|
7
9
|
class TitleBuilder
|
8
|
-
|
10
|
+
extend Deprecation
|
11
|
+
# @param [[Array<Cocina::Models::Title,Cocina::Models::DescriptiveValue>] titles the titles to consider
|
9
12
|
# @param [Symbol] strategy ":first" is the strategy for selection when primary or display title are missing
|
10
13
|
# @param [Boolean] add_punctuation determines if the title should be formmated with punctuation
|
11
14
|
# @return [String] the title value for Solr
|
12
|
-
def self.build(
|
13
|
-
|
15
|
+
def self.build(titles, strategy: :first, add_punctuation: true)
|
16
|
+
if titles.respond_to?(:description)
|
17
|
+
Deprecation.warn(self, "Calling TitleBuilder.build with a #{titles.class} is deprecated. It must be called with an array of titles")
|
18
|
+
titles = titles.description.title
|
19
|
+
end
|
20
|
+
new(strategy: strategy, add_punctuation: add_punctuation).build(titles)
|
14
21
|
end
|
15
22
|
|
16
|
-
def initialize(
|
17
|
-
@cocina_object = cocina_object
|
23
|
+
def initialize(strategy:, add_punctuation:)
|
18
24
|
@strategy = strategy
|
19
25
|
@add_punctuation = add_punctuation
|
20
26
|
end
|
21
27
|
|
28
|
+
# @param [[Array<Cocina::Models::Title>] titles the titles to consider
|
22
29
|
# @return [String] the title value for Solr
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
cocina_title = primary_title || untyped_title
|
27
|
-
cocina_title = other_title if cocina_title.blank?
|
30
|
+
def build(titles)
|
31
|
+
cocina_title = primary_title(titles) || untyped_title(titles)
|
32
|
+
cocina_title = other_title(titles) if cocina_title.blank?
|
28
33
|
|
29
34
|
if strategy == :first
|
30
35
|
extract_title(cocina_title)
|
@@ -35,7 +40,7 @@ module Cocina
|
|
35
40
|
|
36
41
|
private
|
37
42
|
|
38
|
-
attr_reader :
|
43
|
+
attr_reader :strategy
|
39
44
|
|
40
45
|
def extract_title(cocina_title)
|
41
46
|
result = if cocina_title.value
|
@@ -44,7 +49,7 @@ module Cocina
|
|
44
49
|
title_from_structured_values(cocina_title.structuredValue,
|
45
50
|
non_sorting_char_count(cocina_title))
|
46
51
|
elsif cocina_title.parallelValue.present?
|
47
|
-
return cocina_title.parallelValue
|
52
|
+
return build(cocina_title.parallelValue)
|
48
53
|
end
|
49
54
|
remove_trailing_punctuation(result.strip) if result.present?
|
50
55
|
end
|
@@ -54,7 +59,7 @@ module Cocina
|
|
54
59
|
end
|
55
60
|
|
56
61
|
# @return [Cocina::Models::Title, nil] title that has status=primary
|
57
|
-
def primary_title
|
62
|
+
def primary_title(titles)
|
58
63
|
primary_title = titles.find do |title|
|
59
64
|
title.status == 'primary'
|
60
65
|
end
|
@@ -69,7 +74,7 @@ module Cocina
|
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
72
|
-
def untyped_title
|
77
|
+
def untyped_title(titles)
|
73
78
|
method = strategy == :first ? :find : :select
|
74
79
|
untyped_title_for(titles.public_send(method))
|
75
80
|
end
|
@@ -86,7 +91,7 @@ module Cocina
|
|
86
91
|
end
|
87
92
|
|
88
93
|
# This handles 'main title', 'uniform' or 'translated'
|
89
|
-
def other_title
|
94
|
+
def other_title(titles)
|
90
95
|
if strategy == :first
|
91
96
|
titles.first
|
92
97
|
else
|
data/openapi.yml
CHANGED
@@ -1256,6 +1256,8 @@ components:
|
|
1256
1256
|
$ref: '#/components/schemas/DOI'
|
1257
1257
|
sourceId:
|
1258
1258
|
$ref: '#/components/schemas/SourceId'
|
1259
|
+
required:
|
1260
|
+
- sourceId
|
1259
1261
|
Language:
|
1260
1262
|
description: Languages, scripts, symbolic systems, and notations used in all
|
1261
1263
|
or part of a resource or its descriptive metadata.
|
@@ -1424,7 +1426,7 @@ components:
|
|
1424
1426
|
format: date-time
|
1425
1427
|
lock:
|
1426
1428
|
description: Key for optimistic locking. The contents of the key is not specified.
|
1427
|
-
type: string
|
1429
|
+
type: string
|
1428
1430
|
required:
|
1429
1431
|
- lock
|
1430
1432
|
Presentation:
|
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.71.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: 2022-03-
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: deprecation
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: dry-struct
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -396,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
396
410
|
- !ruby/object:Gem::Version
|
397
411
|
version: '0'
|
398
412
|
requirements: []
|
399
|
-
rubygems_version: 3.
|
413
|
+
rubygems_version: 3.2.32
|
400
414
|
signing_key:
|
401
415
|
specification_version: 4
|
402
416
|
summary: Data models for the SDR
|