This repository has been archived by the owner on May 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
dor-services.rb
193 lines (170 loc) · 5.1 KB
/
dor-services.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# frozen_string_literal: true
require 'active_fedora'
require 'active_fedora/version'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/object/blank'
require 'dor/utils/sdr_client'
module Dor
extend ActiveSupport::Autoload
@@registered_classes = {}
mattr_reader :registered_classes
INDEX_VERSION_FIELD = 'dor_services_version_ssi'
class << self
def configure(*args, &block)
Dor::Config.configure *args, &block
end
# Load an object and inspect its identityMetadata to figure out what class
# to adapt it to. This is necessary when the object is not indexed, or the
# index is missing the objectType property.
# @param [String] pid The object's PID
def load_instance(pid)
Dor::Abstract.find pid, cast: true
end
# Get objectType information from solr and load the correct class the first time,
# saving the overhead of using ActiveFedora::Base#adapt_to. It falls back to
# Dor.load_instance() if the item is not in the index, or is improperly indexed.
# @param [String] pid The object's PID
# @return [Object] the ActiveFedora-modeled object
def find(pid, _opts = {})
load_instance(pid)
end
# TODO: return enumerable and lazy load_instance
# TODO: restrict fieldlist (fl) for non-:lightweight queries
def find_all(query, opts = {})
ActiveSupport::Deprecation.warn 'Dor.find_all is deprecated; use activefedora finders instead'
resp = SearchService.query query, opts
resp['response']['docs'].collect do |solr_doc|
find solr_doc['id']
end
end
# @deprecated
def ensure_models_loaded!
ActiveSupport::Deprecation.warn 'Dor.ensure_models_loaded! is unnecessary and has been deprecated.'
eager_load!
end
def root
File.dirname(__FILE__)
end
def logger
require 'logger'
@logger ||= if defined?(::Rails) && ::Rails.respond_to?(:logger)
Rails.logger
else
Logger.new(STDOUT)
end
end
end
def logger
Dor.logger
end
require 'dor/version'
require 'dor/config'
require 'dor/exceptions'
# patches, utilities and helpers
require 'dor/utils/ng_tidy'
require 'dor/utils/solr_doc_helper'
require 'dor/utils/predicate_patch'
require 'dor/datastreams/datastream_spec_solrizer'
require 'druid-tools'
autoload_under 'indexers' do
autoload :CompositeIndexer
autoload :DataIndexer
autoload :DescribableIndexer
autoload :EditableIndexer
autoload :IdentifiableIndexer
autoload :ProcessableIndexer
autoload :ReleasableIndexer
end
# datastreams
autoload_under 'datastreams' do
autoload :AdministrativeMetadataDS
autoload :ContentMetadataDS
autoload :DefaultObjectRightsDS
autoload :DescMetadataDS
autoload :EmbargoMetadataDS
autoload :EventsDS
autoload :GeoMetadataDS
autoload :IdentityMetadataDS
autoload :ProvenanceMetadataDS
autoload :RightsMetadataDS
autoload :RoleMetadataDS
autoload :SimpleDublinCoreDs
autoload :TechnicalMetadataDS
autoload :VersionMetadataDS
autoload :WorkflowDefinitionDs
autoload :WorkflowDs
end
# DOR Concerns
autoload_under 'models/concerns' do
autoload :Identifiable
autoload :Itemizable
autoload :Processable
autoload :Governable
autoload :Describable
autoload :Publishable
autoload :Shelvable
autoload :Embargoable
autoload :Preservable
autoload :Assembleable
autoload :Eventable
autoload :Versionable
autoload :Contentable
autoload :Editable
autoload :Discoverable
autoload :Geoable
autoload :Releaseable
autoload :Rightsable
end
eager_autoload do
# ActiveFedora Classes
autoload_under 'models' do
autoload :Abstract
autoload :Agreement
autoload :Item
autoload :Set
autoload :Collection
autoload :AdminPolicyObject
autoload :WorkflowObject
end
end
# Services
autoload_under 'services' do
autoload :CleanupResetService
autoload :CleanupService
autoload :CreativeCommonsLicenseService
autoload :DatastreamBuilder
autoload :DigitalStacksService
autoload :FileMetadataMergeService
autoload :IndexingService
autoload :MetadataService
autoload :MergeService
autoload :Ontology
autoload :OpenDataLicenseService
autoload :ProvenanceMetadataService
autoload :PublicDescMetadataService
autoload :PublicXmlService
autoload :PublishMetadataService
autoload :RegistrationService
autoload :ReleaseTagService
autoload :ResetWorkspaceService
autoload :SdrIngestService
autoload :SearchService
autoload :SecondaryFileNameService
autoload :ShelvingService
autoload :StatusService
autoload :SuriService
autoload :TagService
autoload :TechnicalMetadataService
autoload :ThumbnailService
autoload :VersionService
autoload :WorkflowService
end
# Workflow Classes
module Workflow
extend ActiveSupport::Autoload
autoload :Process
autoload :Document
end
eager_load!
require 'dor/utils/hydrus_shims'
end