dor-services 5.14.2 → 5.15.0
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 +17 -13
- data/lib/dor/models/agreement.rb +3 -0
- data/lib/dor/models/identifiable.rb +13 -0
- data/lib/dor/services/registration_service.rb +0 -1
- data/lib/dor/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78095de3ddf6f320e3de915092a37794f10f93b3
|
4
|
+
data.tar.gz: e3acad6df212a6c702317a40ee59828add2a68ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65eb517399834470be6daea7a7122dc2a20da5dc8439635f54130012e71c77202cddb42a3739458db1ff19272624b38f87b07c5d6798cf8887066c54dd841d6d
|
7
|
+
data.tar.gz: a26b1d0b4a22d1f3c3417c6b5485713ac64788c8bda10db432dce6b18864792fe82977a4526cc017f90a39221094b954ea9d130eb718ea6794340429a659f129
|
data/lib/dor-services.rb
CHANGED
@@ -4,6 +4,7 @@ require 'modsulator'
|
|
4
4
|
require 'dor/utils/sdr_client'
|
5
5
|
|
6
6
|
module Dor
|
7
|
+
extend ActiveSupport::Autoload
|
7
8
|
@@registered_classes = {}
|
8
9
|
mattr_reader :registered_classes
|
9
10
|
INDEX_VERSION_FIELD = 'dor_services_version_ssi'.freeze
|
@@ -19,12 +20,9 @@ module Dor
|
|
19
20
|
# index is missing the objectType property.
|
20
21
|
# @param [String] pid The object's PID
|
21
22
|
def load_instance(pid)
|
22
|
-
ensure_models_loaded!
|
23
23
|
obj = Dor::Abstract.find pid, cast: false
|
24
24
|
return nil if obj.new_record?
|
25
|
-
|
26
|
-
object_class = registered_classes[object_type] || Dor::Item
|
27
|
-
obj.adapt_to(object_class)
|
25
|
+
obj.adapt_to_cmodel
|
28
26
|
end
|
29
27
|
|
30
28
|
# Get objectType information from solr and load the correct class the first time,
|
@@ -40,7 +38,6 @@ module Dor
|
|
40
38
|
# TODO: return enumerable and lazy load_instance
|
41
39
|
# TODO: restrict fieldlist (fl) for non-:lightweight queries
|
42
40
|
def find_all(query, opts = {})
|
43
|
-
ensure_models_loaded!
|
44
41
|
resp = SearchService.query query, opts
|
45
42
|
resp.docs.collect do |solr_doc|
|
46
43
|
doc_version = solr_doc[INDEX_VERSION_FIELD].first rescue '0.0.0'
|
@@ -60,8 +57,10 @@ module Dor
|
|
60
57
|
end
|
61
58
|
end
|
62
59
|
|
60
|
+
# @deprecated
|
63
61
|
def ensure_models_loaded!
|
64
|
-
|
62
|
+
ActiveSupport::Deprecation.warn 'Dor.ensure_models_loaded! is unnecessary and has been deprecated.'
|
63
|
+
eager_load!
|
65
64
|
end
|
66
65
|
|
67
66
|
def root
|
@@ -132,13 +131,16 @@ module Dor
|
|
132
131
|
autoload :Releaseable, 'dor/models/releaseable'
|
133
132
|
autoload :Rightsable, 'dor/models/rightsable'
|
134
133
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
134
|
+
eager_autoload do
|
135
|
+
# ActiveFedora Classes
|
136
|
+
autoload :Abstract, 'dor/models/item'
|
137
|
+
autoload :Agreement, 'dor/models/agreement'
|
138
|
+
autoload :Item, 'dor/models/item'
|
139
|
+
autoload :Set, 'dor/models/set'
|
140
|
+
autoload :Collection, 'dor/models/collection'
|
141
|
+
autoload :AdminPolicyObject, 'dor/models/admin_policy_object'
|
142
|
+
autoload :WorkflowObject, 'dor/models/workflow_object'
|
143
|
+
end
|
142
144
|
|
143
145
|
# Services
|
144
146
|
autoload :SearchService, 'dor/services/search_service'
|
@@ -167,4 +169,6 @@ module Dor
|
|
167
169
|
autoload :Process, 'dor/workflow/process'
|
168
170
|
autoload :Document, 'dor/workflow/document'
|
169
171
|
end
|
172
|
+
|
173
|
+
eager_load!
|
170
174
|
end
|
@@ -224,6 +224,19 @@ module Dor
|
|
224
224
|
result.nil? ? druid : result[0] # if no matches, return the string passed in, otherwise return the match
|
225
225
|
end
|
226
226
|
|
227
|
+
# Override ActiveFedora::Core#adapt_to_cmodel (used with associations, among other places) to
|
228
|
+
# preferentially use the objectType asserted in the identityMetadata.
|
229
|
+
def adapt_to_cmodel
|
230
|
+
object_type = identityMetadata.objectType.first
|
231
|
+
object_class = Dor.registered_classes[object_type]
|
232
|
+
|
233
|
+
if object_class
|
234
|
+
self.instance_of?(object_class) ? self : self.adapt_to(object_class)
|
235
|
+
else
|
236
|
+
super
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
227
240
|
private
|
228
241
|
|
229
242
|
def solrize_related_obj_titles(solr_doc, relationships, title_hash, union_field_name, nonhydrus_field_name, hydrus_field_name)
|
@@ -46,7 +46,6 @@ module Dor
|
|
46
46
|
# @option params [Array<String>] :initiate_workflow workflow_ids
|
47
47
|
# @option params [Array] :tags
|
48
48
|
def register_object(params = {})
|
49
|
-
Dor.ensure_models_loaded!
|
50
49
|
[:object_type, :label].each do |required_param|
|
51
50
|
raise Dor::ParameterError, "#{required_param.inspect} must be specified in call to #{name}.register_object" unless params[required_param]
|
52
51
|
end
|
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.15.0
|
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-10 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: active-fedora
|
@@ -614,6 +614,7 @@ files:
|
|
614
614
|
- lib/dor/migrations/processable/unify_workflows.rb
|
615
615
|
- lib/dor/migrations/versionable/add_missing_version_md.rb
|
616
616
|
- lib/dor/models/admin_policy_object.rb
|
617
|
+
- lib/dor/models/agreement.rb
|
617
618
|
- lib/dor/models/assembleable.rb
|
618
619
|
- lib/dor/models/collection.rb
|
619
620
|
- lib/dor/models/contentable.rb
|
@@ -682,9 +683,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
682
683
|
version: 1.3.6
|
683
684
|
requirements: []
|
684
685
|
rubyforge_project:
|
685
|
-
rubygems_version: 2.
|
686
|
+
rubygems_version: 2.5.1
|
686
687
|
signing_key:
|
687
688
|
specification_version: 4
|
688
689
|
summary: Ruby implmentation of DOR services used by the SULAIR Digital Library
|
689
690
|
test_files: []
|
690
|
-
has_rdoc:
|