dor-services 5.16.0 → 5.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/config_defaults.yml +3 -1
- data/lib/dor-services.rb +5 -19
- data/lib/dor/datastreams/content_metadata_ds.rb +1 -1
- data/lib/dor/datastreams/desc_metadata_ds.rb +4 -0
- data/lib/dor/models/abstract.rb +6 -0
- data/lib/dor/models/admin_policy_object.rb +1 -6
- data/lib/dor/models/collection.rb +1 -8
- data/lib/dor/models/describable.rb +18 -14
- data/lib/dor/models/embargoable.rb +0 -1
- data/lib/dor/models/governable.rb +0 -1
- data/lib/dor/models/identifiable.rb +1 -4
- data/lib/dor/models/item.rb +4 -4
- data/lib/dor/models/publishable.rb +0 -5
- data/lib/dor/models/releaseable.rb +1 -2
- data/lib/dor/models/set.rb +1 -6
- data/lib/dor/models/shelvable.rb +0 -1
- data/lib/dor/models/versionable.rb +0 -1
- data/lib/dor/models/workflow_object.rb +1 -3
- data/lib/dor/services/indexing_service.rb +22 -0
- data/lib/dor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64af1946ede8a667403407ffbcc4fb150c9926bc
|
4
|
+
data.tar.gz: cd676eaee2571de373db7e780b1da2e0f5c18892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33733ccfdc025b1ccf0eee580ac4c1f73e3a9a17ecb0e1ecd9ab5755d755609ab02546629723e0831d3d920945338ac1a928608fc9de477a09b313c8f9acab6a
|
7
|
+
data.tar.gz: 8c8f067f129b21bf9cdd3fa59a3110748b9b057408a7f3dc2feb0c1276b1e47037ae53751b29f909c297dbef0c6fe0af910f97c7dfe8e623ac722b2b80d060b2
|
data/config/config_defaults.yml
CHANGED
@@ -47,7 +47,7 @@
|
|
47
47
|
:document_cache_host:
|
48
48
|
:document_cache_user:
|
49
49
|
:local_stacks_root: /stacks
|
50
|
-
:local_document_cache_root: /purl
|
50
|
+
:local_document_cache_root: /purl/document_cache
|
51
51
|
:url:
|
52
52
|
:iiif_profile:
|
53
53
|
:suri:
|
@@ -63,6 +63,8 @@
|
|
63
63
|
:shift_age: weekly
|
64
64
|
:dor_services:
|
65
65
|
:url:
|
66
|
+
:dor_indexing_app:
|
67
|
+
:url:
|
66
68
|
:indexing_svc:
|
67
69
|
:log: 'log/indexing_svc.log'
|
68
70
|
:log_date_format_str: '%Y-%m-%d %H:%M:%S.%L'
|
data/lib/dor-services.rb
CHANGED
@@ -21,9 +21,7 @@ module Dor
|
|
21
21
|
# index is missing the objectType property.
|
22
22
|
# @param [String] pid The object's PID
|
23
23
|
def load_instance(pid)
|
24
|
-
|
25
|
-
return nil if obj.new_record?
|
26
|
-
obj.adapt_to_cmodel
|
24
|
+
Dor::Abstract.find pid, cast: true
|
27
25
|
end
|
28
26
|
|
29
27
|
# Get objectType information from solr and load the correct class the first time,
|
@@ -32,29 +30,17 @@ module Dor
|
|
32
30
|
# @param [String] pid The object's PID
|
33
31
|
# @return [Object] the ActiveFedora-modeled object
|
34
32
|
def find(pid, opts = {})
|
35
|
-
|
36
|
-
find_all(%(id:"#{pid}"), opts).first || load_instance(pid)
|
33
|
+
load_instance(pid)
|
37
34
|
end
|
38
35
|
|
39
36
|
# TODO: return enumerable and lazy load_instance
|
40
37
|
# TODO: restrict fieldlist (fl) for non-:lightweight queries
|
41
38
|
def find_all(query, opts = {})
|
39
|
+
ActiveSupport::Deprecation.warn 'Dor.ensure_models_loaded! is unnecessary and has been deprecated.'
|
40
|
+
|
42
41
|
resp = SearchService.query query, opts
|
43
42
|
resp['response']['docs'].collect do |solr_doc|
|
44
|
-
|
45
|
-
doc_version = Gem::Version.new(doc_version)
|
46
|
-
object_type = Array(solr_doc[ActiveFedora::SolrService.solr_name('objectType', :symbol)]).first
|
47
|
-
object_class = registered_classes[object_type] || ActiveFedora::Base
|
48
|
-
if opts[:lightweight] && doc_version >= Gem::Version.new('3.1.0')
|
49
|
-
begin
|
50
|
-
object_class.load_instance_from_solr solr_doc['id'], solr_doc
|
51
|
-
rescue Exception => e
|
52
|
-
Dor.logger.warn("Exception: '#{e.message}' trying to load #{solr_doc['id']} from solr. Loading from Fedora")
|
53
|
-
load_instance(solr_doc['id'])
|
54
|
-
end
|
55
|
-
else
|
56
|
-
load_instance solr_doc['id']
|
57
|
-
end
|
43
|
+
find solr_doc['id']
|
58
44
|
end
|
59
45
|
end
|
60
46
|
|
@@ -62,7 +62,7 @@ module Dor
|
|
62
62
|
|
63
63
|
# always use title regardless of whether a child label is present
|
64
64
|
src_label = doc.create_element('label')
|
65
|
-
src_label.content = src_item.
|
65
|
+
src_label.content = src_item.full_title
|
66
66
|
|
67
67
|
# add the extracted label and imageData
|
68
68
|
externalFile.add_previous_sibling(src_label)
|
@@ -29,6 +29,10 @@ module Dor
|
|
29
29
|
t.scale :index_as => [:symbol]
|
30
30
|
t.topic :index_as => [:symbol, :stored_searchable]
|
31
31
|
t.abstract :index_as => [:stored_searchable]
|
32
|
+
|
33
|
+
# 'identifier' conflicts with identityMetadata indexing. Explicitly namespace this one value
|
34
|
+
# until we use #prefix to automatically namespace them for us.
|
35
|
+
t.mods_identifier path: 'identifier', :index_as => [:symbol, :stored_searchable]
|
32
36
|
end
|
33
37
|
|
34
38
|
def self.xml_template
|
data/lib/dor/models/abstract.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
module Dor
|
2
|
-
class AdminPolicyObject < ::
|
3
|
-
include Identifiable
|
4
|
-
include Governable
|
2
|
+
class AdminPolicyObject < Dor::Abstract
|
5
3
|
include Editable
|
6
|
-
include Describable
|
7
|
-
include Processable
|
8
|
-
include Versionable
|
9
4
|
|
10
5
|
has_many :things, :property => :is_governed_by, :class_name => 'ActiveFedora::Base'
|
11
6
|
has_object_type 'adminPolicy'
|
@@ -1,14 +1,7 @@
|
|
1
1
|
module Dor
|
2
|
-
class Collection < ::
|
3
|
-
include Identifiable
|
4
|
-
include Processable
|
5
|
-
include Governable
|
6
|
-
include Describable
|
7
|
-
include Publishable
|
8
|
-
include Versionable
|
2
|
+
class Collection < Dor::Set
|
9
3
|
include Releaseable
|
10
4
|
|
11
|
-
has_many :members, :property => :is_member_of_collection, :class_name => 'ActiveFedora::Base'
|
12
5
|
has_object_type 'collection'
|
13
6
|
end
|
14
7
|
end
|
@@ -3,6 +3,8 @@ module Dor
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
MODS_TO_DC_XSLT = Nokogiri::XSLT(File.new(File.expand_path(File.dirname(__FILE__) + "/mods2dc.xslt")))
|
6
|
+
XMLNS_OAI_DC = 'http://www.openarchives.org/OAI/2.0/oai_dc/'.freeze
|
7
|
+
XMLNS_DC = 'http://purl.org/dc/elements/1.1/'.freeze
|
6
8
|
|
7
9
|
class CrosswalkError < Exception; end
|
8
10
|
|
@@ -45,7 +47,7 @@ module Dor
|
|
45
47
|
desc_md = descMetadata.ng_xml.dup(1)
|
46
48
|
add_collection_reference(desc_md) if include_collection_as_related_item
|
47
49
|
dc_doc = MODS_TO_DC_XSLT.transform(desc_md)
|
48
|
-
dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]').remove # Remove empty nodes
|
50
|
+
dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]', oai_dc: XMLNS_OAI_DC).remove # Remove empty nodes
|
49
51
|
raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no root):\n#{dc_doc.to_xml}" if dc_doc.root.nil?
|
50
52
|
raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no children):\n#{dc_doc.to_xml}" if dc_doc.root.children.size == 0
|
51
53
|
dc_doc
|
@@ -178,7 +180,7 @@ module Dor
|
|
178
180
|
# load the title from the parent's DC.title
|
179
181
|
titleInfo = doc.create_element 'titleInfo'
|
180
182
|
title = doc.create_element 'title'
|
181
|
-
title.content = parent_item
|
183
|
+
title.content = Dor::Describable.get_collection_title(parent_item)
|
182
184
|
titleInfo << title
|
183
185
|
relatedItem << titleInfo
|
184
186
|
|
@@ -197,12 +199,18 @@ module Dor
|
|
197
199
|
def to_solr(solr_doc = {}, *args)
|
198
200
|
solr_doc = super solr_doc, *args
|
199
201
|
mods_sources = {
|
202
|
+
'sw_display_title_tesim' => :sw_title_display,
|
203
|
+
'sw_author_ssim' => :main_author_w_date,
|
204
|
+
'sw_author_tesim' => :main_author_w_date,
|
205
|
+
'sw_author_sort_ssi' => :sw_sort_author,
|
200
206
|
'sw_language_ssim' => :sw_language_facet,
|
201
207
|
'sw_language_tesim' => :sw_language_facet,
|
202
208
|
'sw_genre_ssim' => :sw_genre,
|
203
209
|
'sw_genre_tesim' => :sw_genre,
|
204
210
|
'sw_format_ssim' => :format_main, # basically sw_typeOfResource_ssim
|
205
211
|
'sw_format_tesim' => :format_main, # basically sw_typeOfResource_tesim
|
212
|
+
'sw_topic_ssim' => :topic_facet,
|
213
|
+
'sw_topic_tesim' => :topic_facet,
|
206
214
|
'sw_subject_temporal_ssim' => :era_facet,
|
207
215
|
'sw_subject_temporal_tesim' => :era_facet,
|
208
216
|
'sw_subject_geographic_ssim' => :geographic_facet,
|
@@ -220,15 +228,15 @@ module Dor
|
|
220
228
|
dc_doc = generate_dublin_core(include_collection_as_related_item: false)
|
221
229
|
# we excluding the generated collection relation here; we instead get the collection
|
222
230
|
# title from Dor::Identifiable.
|
223
|
-
dc_doc.xpath('/oai_dc:dc/*').each do |node|
|
231
|
+
dc_doc.xpath('/oai_dc:dc/*', oai_dc: XMLNS_OAI_DC).each do |node|
|
224
232
|
add_solr_value(solr_doc, "public_dc_#{node.name}", node.text, :string, [:stored_searchable])
|
225
233
|
end
|
226
234
|
creator = ''
|
227
|
-
dc_doc.xpath('//dc:creator').each do |node|
|
235
|
+
dc_doc.xpath('//dc:creator', dc: XMLNS_DC).each do |node|
|
228
236
|
creator = node.text
|
229
237
|
end
|
230
238
|
title = ''
|
231
|
-
dc_doc.xpath('//dc:title').each do |node|
|
239
|
+
dc_doc.xpath('//dc:title', dc: XMLNS_DC).each do |node|
|
232
240
|
title = node.text
|
233
241
|
end
|
234
242
|
creator_title = creator + title
|
@@ -275,15 +283,11 @@ module Dor
|
|
275
283
|
end
|
276
284
|
|
277
285
|
def self.get_collection_title(obj)
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
subtitle = xml.at_xpath('//mods:mods/mods:titleInfo/mods:subTitle', 'mods' => 'http://www.loc.gov/mods/v3')
|
284
|
-
title += " (#{subtitle.content})" if subtitle
|
285
|
-
end
|
286
|
-
title
|
286
|
+
obj.full_title
|
287
|
+
end
|
288
|
+
|
289
|
+
def full_title
|
290
|
+
stanford_mods.sw_title_display
|
287
291
|
end
|
288
292
|
|
289
293
|
private
|
@@ -2,7 +2,6 @@ module Dor
|
|
2
2
|
module Identifiable
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
include SolrDocHelper
|
5
|
-
include Eventable
|
6
5
|
|
7
6
|
included do
|
8
7
|
has_metadata :name => 'DC', :type => SimpleDublinCoreDs, :label => 'Dublin Core Record for self object'
|
@@ -184,9 +183,7 @@ module Dor
|
|
184
183
|
def get_related_obj_display_title(related_obj, default_title)
|
185
184
|
return default_title unless related_obj
|
186
185
|
|
187
|
-
|
188
|
-
desc_md_ds_title = desc_md_ds ? desc_md_ds.title_info.main_title.first : nil
|
189
|
-
desc_md_ds_title.present? ? desc_md_ds_title : default_title
|
186
|
+
related_obj.full_title || default_title
|
190
187
|
end
|
191
188
|
|
192
189
|
# a regex that can be used to identify the last part of a druid (e.g. oo000oo0001)
|
data/lib/dor/models/item.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Dor
|
2
|
-
class Item < ::
|
3
|
-
include Processable
|
2
|
+
class Item < Dor::Abstract
|
4
3
|
include Shelvable
|
5
|
-
include Embargoable
|
4
|
+
include Embargoable
|
5
|
+
include Publishable
|
6
|
+
include Itemizable
|
6
7
|
include Preservable
|
7
8
|
include Assembleable
|
8
|
-
include Versionable
|
9
9
|
include Contentable
|
10
10
|
include Geoable
|
11
11
|
include Releaseable
|
@@ -4,11 +4,6 @@ require 'fileutils'
|
|
4
4
|
module Dor
|
5
5
|
module Publishable
|
6
6
|
extend ActiveSupport::Concern
|
7
|
-
include Identifiable
|
8
|
-
include Governable
|
9
|
-
include Describable
|
10
|
-
include Itemizable
|
11
|
-
include Rightsable
|
12
7
|
|
13
8
|
# Compute the thumbnail for this object following the rules at https://consul.stanford.edu/display/chimera/The+Rules+of+Thumb
|
14
9
|
# @return [String] the computed thumb filename, with the druid prefix and a slash in front of it, e.g. oo000oo0001/filenamewith space.jp2
|
@@ -4,7 +4,6 @@ require 'retries'
|
|
4
4
|
module Dor
|
5
5
|
module Releaseable
|
6
6
|
extend ActiveSupport::Concern
|
7
|
-
include Itemizable
|
8
7
|
|
9
8
|
# Add release tags to an item and initialize the item release workflow
|
10
9
|
# Each tag should be of the form !{:tag => 'Fitch : Batch2', :what => 'self', :to => 'Searchworks', :who => 'petucket', :release => true}
|
@@ -80,7 +79,7 @@ module Dor
|
|
80
79
|
return_tags = release_nodes || {}
|
81
80
|
collections.each do |collection|
|
82
81
|
next if collection.id == id # recursive, so parents of parents are found, but we need to avoid an infinite loop if the collection references itself (i.e. bad data)
|
83
|
-
return_tags = combine_two_release_tag_hashes(return_tags,
|
82
|
+
return_tags = combine_two_release_tag_hashes(return_tags, collection.get_release_tags_for_item_and_all_governing_sets)
|
84
83
|
end
|
85
84
|
return_tags
|
86
85
|
end
|
data/lib/dor/models/set.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
module Dor
|
2
|
-
class Set < ::
|
3
|
-
include Identifiable
|
4
|
-
include Processable
|
5
|
-
include Governable
|
6
|
-
include Describable
|
2
|
+
class Set < Dor::Abstract
|
7
3
|
include Publishable
|
8
|
-
include Versionable
|
9
4
|
|
10
5
|
has_many :members, :property => :is_member_of_collection, :class_name => 'ActiveFedora::Base'
|
11
6
|
has_object_type 'set'
|
data/lib/dor/models/shelvable.rb
CHANGED
@@ -2,6 +2,8 @@ require 'benchmark'
|
|
2
2
|
|
3
3
|
module Dor
|
4
4
|
class IndexingService
|
5
|
+
class ReindexError < RuntimeError; end
|
6
|
+
|
5
7
|
##
|
6
8
|
# Returns a Logger instance for recording info about indexing attempts
|
7
9
|
# @yield attempt to execute 'entry_id_block' and use the result as an extra identifier for the log
|
@@ -30,6 +32,26 @@ module Dor
|
|
30
32
|
solr_doc
|
31
33
|
end
|
32
34
|
|
35
|
+
# Use the dor-indexing-app service to reindex a pid
|
36
|
+
# @param [String] `pid` the druid
|
37
|
+
# @raise [ReindexError] on failure
|
38
|
+
def self.reindex_pid_remotely(pid)
|
39
|
+
pid = "druid:#{pid}" unless pid =~ /^druid:/
|
40
|
+
realtime = Benchmark.realtime do
|
41
|
+
with_retries(max_tries: 3, rescue: [ RestClient::Exception, Errno::ECONNREFUSED ]) do
|
42
|
+
RestClient.post(URI.join(Config.dor_indexing_app.url, "reindex/#{pid}"), '')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
default_index_logger.info "successfully updated index for #{pid} in #{'%.3f' % realtime}s"
|
46
|
+
rescue RestClient::Exception, Errno::ECONNREFUSED => e
|
47
|
+
msg = "failed to reindex #{pid}: #{e}"
|
48
|
+
default_index_logger.error msg
|
49
|
+
raise ReindexError.new(msg)
|
50
|
+
rescue => e
|
51
|
+
default_index_logger.error "failed to reindex #{pid}: #{e}"
|
52
|
+
raise
|
53
|
+
end
|
54
|
+
|
33
55
|
# retrieves a single Dor object by pid, indexes the object to solr, does some logging
|
34
56
|
# (will use a default logger if one is not provided). doesn't commit automatically.
|
35
57
|
#
|
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: 5.
|
4
|
+
version: 5.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2016-11-
|
17
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: active-fedora
|