dor-services 9.3.0 → 9.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dor-services.rb +1 -1
- data/lib/dor/datastreams/content_metadata_ds.rb +5 -1
- data/lib/dor/datastreams/identity_metadata_ds.rb +20 -31
- data/lib/dor/datastreams/rights_metadata_ds.rb +17 -74
- data/lib/dor/datastreams/version_metadata_ds.rb +3 -3
- data/lib/dor/models/abstract.rb +1 -1
- data/lib/dor/models/admin_policy_object.rb +6 -1
- data/lib/dor/services/search_service.rb +3 -2
- data/lib/dor/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27607925382cdafb02fb70e21d9d9afa3d696b3a01548aec3131f8089dea5914
|
4
|
+
data.tar.gz: 2bdf4105480c43e1e5bcbc2f0d8e0f4b46eeac4e0a3687daf5956844912ea527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecd3ee6afc0c6fcd00f3fbc2f1167bf3fda5fe5bf47ba35b58879bffba1e2bb286d3f9f07cdf959bbe783edd1ea4bfb9dfcbc0512a8c8e6f0d836f4b31e277f4
|
7
|
+
data.tar.gz: 57b365dcfe5b765f6b4ebf6d051f4611af39e58172e8d44bac90512d4526ccdad463c9bca0f6487242e4c6cbbc89b9c5ead2d5e87b41ad0a0c78fa7c12c964d8
|
data/lib/dor-services.rb
CHANGED
@@ -6,7 +6,7 @@ module Dor
|
|
6
6
|
class ContentMetadataDS < ActiveFedora::OmDatastream
|
7
7
|
set_terminology do |t|
|
8
8
|
t.root path: 'contentMetadata', index_as: [:not_searchable]
|
9
|
-
t.contentType path: '
|
9
|
+
t.contentType path: { attribute: 'type' }, index_as: [:not_searchable]
|
10
10
|
t.stacks path: '/contentMetadata/@stacks', index_as: [:not_searchable]
|
11
11
|
t.resource(index_as: [:not_searchable]) do
|
12
12
|
t.id_ path: { attribute: 'id' }
|
@@ -35,6 +35,10 @@ module Dor
|
|
35
35
|
t.shelved_file_id proxy: %i[resource shelved_file id], index_as: %i[displayable stored_searchable]
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.xml_template
|
39
|
+
Nokogiri::XML.parse('<contentMetadata/>')
|
40
|
+
end
|
41
|
+
|
38
42
|
### READ ONLY METHODS
|
39
43
|
|
40
44
|
# Only use this when you want the behavior of raising an exception if anything besides exactly one matching node
|
@@ -8,6 +8,7 @@ module Dor
|
|
8
8
|
# ids for previous and current catkeys
|
9
9
|
CATKEY_TYPE_ID = 'catkey'
|
10
10
|
PREVIOUS_CATKEY_TYPE_ID = 'previous_catkey'
|
11
|
+
BARCODE_TYPE_ID = 'barcode'
|
11
12
|
|
12
13
|
set_terminology do |t|
|
13
14
|
t.root(path: 'identityMetadata')
|
@@ -144,6 +145,25 @@ module Dor
|
|
144
145
|
otherId(PREVIOUS_CATKEY_TYPE_ID)
|
145
146
|
end
|
146
147
|
|
148
|
+
def barcode
|
149
|
+
otherId(BARCODE_TYPE_ID).first
|
150
|
+
end
|
151
|
+
|
152
|
+
# Convenience method to set the barcode
|
153
|
+
# @param [String] val the new barcode
|
154
|
+
# @return [String] same value, as per Ruby assignment convention
|
155
|
+
def barcode=(val)
|
156
|
+
if val.blank? # if we are setting the barcode to blank, remove the node from XML
|
157
|
+
remove_other_Id(BARCODE_TYPE_ID)
|
158
|
+
elsif barcode.blank? # if there is no current barcode, then add it
|
159
|
+
add_other_Id(BARCODE_TYPE_ID, val)
|
160
|
+
else # if there is a current barcode, update the current barcode to the new value
|
161
|
+
update_other_Id(BARCODE_TYPE_ID, val)
|
162
|
+
end
|
163
|
+
|
164
|
+
val
|
165
|
+
end
|
166
|
+
|
147
167
|
# Helper method to get the release tags as a nodeset
|
148
168
|
# @return [Nokogiri::XML::NodeSet] all release tags and their attributes
|
149
169
|
def release_tags
|
@@ -160,37 +180,6 @@ module Dor
|
|
160
180
|
return_hash
|
161
181
|
end
|
162
182
|
|
163
|
-
def to_solr(solr_doc = {}, *args)
|
164
|
-
solr_doc = super(solr_doc, *args)
|
165
|
-
|
166
|
-
if digital_object.respond_to?(:profile)
|
167
|
-
digital_object.profile.each_pair do |property, value|
|
168
|
-
add_solr_value(solr_doc, property.underscore, value, (property =~ /Date/ ? :date : :symbol), [:stored_searchable])
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
if sourceId.present?
|
173
|
-
(name, id) = sourceId.split(/:/, 2)
|
174
|
-
add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
|
175
|
-
add_solr_value(solr_doc, 'identifier', sourceId, :symbol, [:stored_searchable])
|
176
|
-
add_solr_value(solr_doc, 'source_id', sourceId, :symbol, [])
|
177
|
-
end
|
178
|
-
otherId.compact.each do |qid|
|
179
|
-
# this section will solrize barcode and catkey, which live in otherId
|
180
|
-
(name, id) = qid.split(/:/, 2)
|
181
|
-
add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
|
182
|
-
add_solr_value(solr_doc, 'identifier', qid, :symbol, [:stored_searchable])
|
183
|
-
add_solr_value(solr_doc, "#{name}_id", id, :symbol, [])
|
184
|
-
end
|
185
|
-
|
186
|
-
solr_doc
|
187
|
-
end
|
188
|
-
|
189
|
-
# maintain AF < 8 indexing behavior
|
190
|
-
def prefix
|
191
|
-
''
|
192
|
-
end
|
193
|
-
|
194
183
|
private
|
195
184
|
|
196
185
|
# Convert one release element into a Hash
|
@@ -12,12 +12,17 @@ module Dor
|
|
12
12
|
|
13
13
|
set_terminology do |t|
|
14
14
|
t.root path: 'rightsMetadata', index_as: [:not_searchable]
|
15
|
-
t.copyright
|
16
|
-
t.use_statement
|
15
|
+
t.copyright proxy: %i[_copyright human], index_as: [:symbol]
|
16
|
+
t.use_statement proxy: %i[use use_and_reproduction], index_as: [:symbol]
|
17
17
|
|
18
18
|
t.use do
|
19
19
|
t.machine
|
20
20
|
t.human
|
21
|
+
t.use_and_reproduction path: 'human', attributes: { type: 'useAndReproduction' }
|
22
|
+
end
|
23
|
+
|
24
|
+
t._copyright path: 'copyright' do
|
25
|
+
t.human
|
21
26
|
end
|
22
27
|
|
23
28
|
t._read(path: 'access', attributes: { type: 'read' }) do
|
@@ -64,6 +69,7 @@ module Dor
|
|
64
69
|
'world-nd' => 'World (no-download)',
|
65
70
|
'stanford' => 'Stanford',
|
66
71
|
'stanford-nd' => 'Stanford (no-download)',
|
72
|
+
'cdl-stanford-nd' => 'Controlled Digital Lending (no-download)',
|
67
73
|
'loc:spec' => 'Location: Special Collections',
|
68
74
|
'loc:music' => 'Location: Music Library',
|
69
75
|
'loc:ars' => 'Location: Archive of Recorded Sound',
|
@@ -98,12 +104,14 @@ module Dor
|
|
98
104
|
# @param rights_xml [ng_xml] a nokogiri xml (ruby) object that represents the rights xml for a DOR object
|
99
105
|
# @param rights_type [string] a recognized rights type code ('world', 'dark', 'loc:spec', etc)
|
100
106
|
def self.upd_rights_xml_for_rights_type(rights_xml, rights_type)
|
107
|
+
# Note: The discover node is either 'none' for a dark object or 'world' for any other rights option
|
101
108
|
label = rights_type == 'dark' ? 'none' : 'world'
|
102
109
|
rights_xml.search('//rightsMetadata/access[@type=\'discover\']/machine').each do |node|
|
103
110
|
node.children.remove
|
104
111
|
node.add_child Nokogiri::XML::Node.new(label, rights_xml)
|
105
112
|
end
|
106
113
|
|
114
|
+
# The read node varies by rights option
|
107
115
|
rights_xml.search('//rightsMetadata/access[@type=\'read\']').each do |node|
|
108
116
|
node.children.remove
|
109
117
|
machine_node = Nokogiri::XML::Node.new('machine', rights_xml)
|
@@ -121,6 +129,13 @@ module Dor
|
|
121
129
|
loc_node = Nokogiri::XML::Node.new('location', rights_xml)
|
122
130
|
loc_node.content = rights_type.split(':').last
|
123
131
|
machine_node.add_child(loc_node)
|
132
|
+
elsif rights_type.start_with?('cdl')
|
133
|
+
cdl_node = Nokogiri::XML::Node.new('cdl', rights_xml)
|
134
|
+
group_node = Nokogiri::XML::Node.new('group', cdl_node)
|
135
|
+
group_node.content = 'stanford'
|
136
|
+
group_node.set_attribute('rule', 'no-download')
|
137
|
+
cdl_node.add_child(group_node)
|
138
|
+
machine_node.add_child(cdl_node)
|
124
139
|
else # we know it is none or dark by the argument filter (first line)
|
125
140
|
machine_node.add_child Nokogiri::XML::Node.new('none', rights_xml)
|
126
141
|
end
|
@@ -144,73 +159,6 @@ module Dor
|
|
144
159
|
@dra_object = nil # until TODO complete, we'll expect to have to reparse after modification
|
145
160
|
end
|
146
161
|
|
147
|
-
def to_solr(solr_doc = {}, *args)
|
148
|
-
solr_doc = super(solr_doc, *args)
|
149
|
-
dra = dra_object
|
150
|
-
solr_doc['rights_primary_ssi'] = dra.index_elements[:primary]
|
151
|
-
solr_doc['rights_errors_ssim'] = dra.index_elements[:errors] if dra.index_elements[:errors].size > 0
|
152
|
-
solr_doc['rights_characteristics_ssim'] = dra.index_elements[:terms] if dra.index_elements[:terms].size > 0
|
153
|
-
|
154
|
-
solr_doc['rights_descriptions_ssim'] = [
|
155
|
-
dra.index_elements[:primary],
|
156
|
-
|
157
|
-
(dra.index_elements[:obj_locations_qualified] || []).map do |rights_info|
|
158
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
159
|
-
"location: #{rights_info[:location]}#{rule_suffix}"
|
160
|
-
end,
|
161
|
-
(dra.index_elements[:file_locations_qualified] || []).map do |rights_info|
|
162
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
163
|
-
"location: #{rights_info[:location]} (file)#{rule_suffix}"
|
164
|
-
end,
|
165
|
-
|
166
|
-
(dra.index_elements[:obj_agents_qualified] || []).map do |rights_info|
|
167
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
168
|
-
"agent: #{rights_info[:agent]}#{rule_suffix}"
|
169
|
-
end,
|
170
|
-
(dra.index_elements[:file_agents_qualified] || []).map do |rights_info|
|
171
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
172
|
-
"agent: #{rights_info[:agent]} (file)#{rule_suffix}"
|
173
|
-
end,
|
174
|
-
|
175
|
-
(dra.index_elements[:obj_groups_qualified] || []).map do |rights_info|
|
176
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
177
|
-
"#{rights_info[:group]}#{rule_suffix}"
|
178
|
-
end,
|
179
|
-
(dra.index_elements[:file_groups_qualified] || []).map do |rights_info|
|
180
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
181
|
-
"#{rights_info[:group]} (file)#{rule_suffix}"
|
182
|
-
end,
|
183
|
-
|
184
|
-
(dra.index_elements[:obj_world_qualified] || []).map do |rights_info|
|
185
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
186
|
-
"world#{rule_suffix}"
|
187
|
-
end,
|
188
|
-
(dra.index_elements[:file_world_qualified] || []).map do |rights_info|
|
189
|
-
rule_suffix = rights_info[:rule] ? " (#{rights_info[:rule]})" : ''
|
190
|
-
"world (file)#{rule_suffix}"
|
191
|
-
end
|
192
|
-
].flatten.uniq
|
193
|
-
|
194
|
-
# these two values are returned by index_elements[:primary], but are just a less granular version of
|
195
|
-
# what the other more specific fields return, so discard them
|
196
|
-
solr_doc['rights_descriptions_ssim'] -= %w[access_restricted access_restricted_qualified world_qualified]
|
197
|
-
solr_doc['rights_descriptions_ssim'] += ['dark (file)'] if dra.index_elements[:terms].include? 'none_read_file'
|
198
|
-
|
199
|
-
solr_doc['obj_rights_locations_ssim'] = dra.index_elements[:obj_locations] unless dra.index_elements[:obj_locations].blank?
|
200
|
-
solr_doc['file_rights_locations_ssim'] = dra.index_elements[:file_locations] unless dra.index_elements[:file_locations].blank?
|
201
|
-
solr_doc['obj_rights_agents_ssim'] = dra.index_elements[:obj_agents] unless dra.index_elements[:obj_agents].blank?
|
202
|
-
solr_doc['file_rights_agents_ssim'] = dra.index_elements[:file_agents] unless dra.index_elements[:file_agents].blank?
|
203
|
-
|
204
|
-
# suppress empties
|
205
|
-
%w(use_statement_ssim copyright_ssim).each do |key|
|
206
|
-
solr_doc[key] = solr_doc[key].reject(&:blank?).flatten unless solr_doc[key].nil?
|
207
|
-
end
|
208
|
-
add_solr_value(solr_doc, 'use_license_machine', use_license.first, :string, [:stored_sortable])
|
209
|
-
add_solr_value(solr_doc, 'use_licenses_machine', use_license, :symbol, [:stored_searchable])
|
210
|
-
|
211
|
-
solr_doc
|
212
|
-
end
|
213
|
-
|
214
162
|
def use_license
|
215
163
|
use_license = []
|
216
164
|
use_license += Array(creative_commons)
|
@@ -219,11 +167,6 @@ module Dor
|
|
219
167
|
use_license.reject(&:blank?)
|
220
168
|
end
|
221
169
|
|
222
|
-
# maintain AF < 8 indexing behavior
|
223
|
-
def prefix
|
224
|
-
''
|
225
|
-
end
|
226
|
-
|
227
170
|
def rights
|
228
171
|
xml = ng_xml
|
229
172
|
if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
|
@@ -112,7 +112,7 @@ module Dor
|
|
112
112
|
def current_version_id
|
113
113
|
current_version = current_version_node
|
114
114
|
if current_version.nil?
|
115
|
-
|
115
|
+
'1'
|
116
116
|
else
|
117
117
|
current_version[:versionId].to_s
|
118
118
|
end
|
@@ -157,9 +157,9 @@ module Dor
|
|
157
157
|
def current_version_closeable?
|
158
158
|
current = current_version_node
|
159
159
|
if current[:tag] && current.at_xpath('description')
|
160
|
-
|
160
|
+
true
|
161
161
|
else
|
162
|
-
|
162
|
+
false
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
data/lib/dor/models/abstract.rb
CHANGED
@@ -76,7 +76,7 @@ module Dor
|
|
76
76
|
|
77
77
|
delegate :full_title, :stanford_mods, to: :descMetadata
|
78
78
|
delegate :rights, to: :rightsMetadata
|
79
|
-
delegate :catkey, :catkey=, :source_id, :source_id=,
|
79
|
+
delegate :catkey, :catkey=, :source_id, :source_id=, :barcode, :barcode=,
|
80
80
|
:objectId, :objectId=, :objectCreator, :objectCreator=,
|
81
81
|
:objectLabel, :objectLabel=, :objectType, :objectType=,
|
82
82
|
:other_ids=, :otherId, :release_tags, :previous_catkeys,
|
@@ -1,13 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'deprecation'
|
4
|
+
|
3
5
|
module Dor
|
4
6
|
class AdminPolicyObject < Dor::Abstract
|
7
|
+
extend Deprecation
|
5
8
|
has_many :things, property: :is_governed_by, class_name: 'ActiveFedora::Base'
|
6
9
|
has_object_type 'adminPolicy'
|
7
10
|
has_metadata name: 'administrativeMetadata', type: Dor::AdministrativeMetadataDS, label: 'Administrative Metadata'
|
8
11
|
has_metadata name: 'roleMetadata', type: Dor::RoleMetadataDS, label: 'Role Metadata'
|
9
12
|
has_metadata name: 'defaultObjectRights', type: Dor::DefaultObjectRightsDS, label: 'Default Object Rights'
|
10
|
-
belongs_to :agreement_object, property: :referencesAgreement, class_name: 'Dor::
|
13
|
+
belongs_to :agreement_object, property: :referencesAgreement, class_name: 'Dor::Agreement'
|
11
14
|
|
12
15
|
delegate :add_roleplayer, :purge_roles, :roles, to: :roleMetadata
|
13
16
|
delegate :mods_title, :mods_title=, to: :descMetadata
|
@@ -29,11 +32,13 @@ module Dor
|
|
29
32
|
def agreement
|
30
33
|
agreement_object ? agreement_object.pid : ''
|
31
34
|
end
|
35
|
+
deprecation_deprecate agreement: 'use #agreement_object_id instead'
|
32
36
|
|
33
37
|
def agreement=(val)
|
34
38
|
raise ArgumentError, 'agreement must have a valid druid' if val.blank?
|
35
39
|
|
36
40
|
self.agreement_object = Dor.find val.to_s, cast: true
|
37
41
|
end
|
42
|
+
deprecation_deprecate :agreement= => 'use #agreement_object_id= instead'
|
38
43
|
end
|
39
44
|
end
|
@@ -27,9 +27,10 @@ module Dor
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def query_by_id(id)
|
30
|
-
|
30
|
+
case id
|
31
|
+
when Hash # Single valued: { :google => 'STANFORD_0123456789' }
|
31
32
|
id = id.collect { |*v| v.join(':') }.first
|
32
|
-
|
33
|
+
when Array # Two values: [ 'google', 'STANFORD_0123456789' ]
|
33
34
|
id = id.join(':')
|
34
35
|
end
|
35
36
|
q = "{!term f=#{Solrizer.solr_name 'identifier', :symbol}}#{id}"
|
data/lib/dor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein
|
@@ -20,7 +20,7 @@ authors:
|
|
20
20
|
autorequire:
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
|
-
date: 2020-
|
23
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: active-fedora
|
@@ -338,14 +338,14 @@ dependencies:
|
|
338
338
|
requirements:
|
339
339
|
- - "~>"
|
340
340
|
- !ruby/object:Gem::Version
|
341
|
-
version: 0.74
|
341
|
+
version: '0.74'
|
342
342
|
type: :development
|
343
343
|
prerelease: false
|
344
344
|
version_requirements: !ruby/object:Gem::Requirement
|
345
345
|
requirements:
|
346
346
|
- - "~>"
|
347
347
|
- !ruby/object:Gem::Version
|
348
|
-
version: 0.74
|
348
|
+
version: '0.74'
|
349
349
|
- !ruby/object:Gem::Dependency
|
350
350
|
name: rubocop-rspec
|
351
351
|
requirement: !ruby/object:Gem::Requirement
|
@@ -483,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
483
483
|
- !ruby/object:Gem::Version
|
484
484
|
version: 1.3.6
|
485
485
|
requirements: []
|
486
|
-
rubygems_version: 3.
|
486
|
+
rubygems_version: 3.1.2
|
487
487
|
signing_key:
|
488
488
|
specification_version: 4
|
489
489
|
summary: Ruby implmentation of DOR services used by the SULAIR Digital Library
|