dor-services 6.0.5 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dor-services.rb +27 -12
  3. data/lib/dor/config.rb +45 -42
  4. data/lib/dor/datastreams/administrative_metadata_ds.rb +137 -44
  5. data/lib/dor/datastreams/content_metadata_ds.rb +42 -42
  6. data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
  7. data/lib/dor/datastreams/default_object_rights_ds.rb +185 -44
  8. data/lib/dor/datastreams/desc_metadata_ds.rb +36 -28
  9. data/lib/dor/datastreams/embargo_metadata_ds.rb +12 -14
  10. data/lib/dor/datastreams/events_ds.rb +10 -10
  11. data/lib/dor/datastreams/geo_metadata_ds.rb +4 -5
  12. data/lib/dor/datastreams/identity_metadata_ds.rb +14 -14
  13. data/lib/dor/datastreams/rights_metadata_ds.rb +23 -23
  14. data/lib/dor/datastreams/role_metadata_ds.rb +61 -15
  15. data/lib/dor/datastreams/simple_dublin_core_ds.rb +8 -8
  16. data/lib/dor/datastreams/version_metadata_ds.rb +10 -12
  17. data/lib/dor/datastreams/workflow_definition_ds.rb +6 -6
  18. data/lib/dor/datastreams/workflow_ds.rb +13 -13
  19. data/lib/dor/exceptions.rb +2 -2
  20. data/lib/dor/indexers/data_indexer.rb +1 -7
  21. data/lib/dor/indexers/describable_indexer.rb +1 -1
  22. data/lib/dor/indexers/identifiable_indexer.rb +0 -2
  23. data/lib/dor/indexers/processable_indexer.rb +55 -28
  24. data/lib/dor/indexers/releasable_indexer.rb +2 -2
  25. data/lib/dor/models/admin_policy_object.rb +4 -4
  26. data/lib/dor/models/concerns/assembleable.rb +4 -0
  27. data/lib/dor/models/concerns/contentable.rb +27 -69
  28. data/lib/dor/models/concerns/describable.rb +14 -29
  29. data/lib/dor/models/concerns/editable.rb +20 -334
  30. data/lib/dor/models/concerns/embargoable.rb +7 -11
  31. data/lib/dor/models/concerns/eventable.rb +5 -1
  32. data/lib/dor/models/concerns/geoable.rb +4 -4
  33. data/lib/dor/models/concerns/governable.rb +18 -87
  34. data/lib/dor/models/concerns/identifiable.rb +15 -75
  35. data/lib/dor/models/concerns/itemizable.rb +9 -11
  36. data/lib/dor/models/concerns/preservable.rb +4 -0
  37. data/lib/dor/models/concerns/processable.rb +30 -129
  38. data/lib/dor/models/concerns/publishable.rb +6 -55
  39. data/lib/dor/models/concerns/releaseable.rb +14 -227
  40. data/lib/dor/models/concerns/rightsable.rb +3 -3
  41. data/lib/dor/models/concerns/shelvable.rb +4 -49
  42. data/lib/dor/models/concerns/versionable.rb +21 -44
  43. data/lib/dor/models/set.rb +1 -1
  44. data/lib/dor/models/workflow_object.rb +2 -2
  45. data/lib/dor/services/ability.rb +77 -0
  46. data/lib/dor/services/cleanup_reset_service.rb +1 -3
  47. data/lib/dor/services/create_workflow_service.rb +51 -0
  48. data/lib/dor/services/creative_commons_license_service.rb +31 -0
  49. data/lib/dor/services/datastream_builder.rb +90 -0
  50. data/lib/dor/services/digital_stacks_service.rb +3 -21
  51. data/lib/dor/services/dublin_core_service.rb +40 -0
  52. data/lib/dor/services/file_metadata_merge_service.rb +67 -0
  53. data/lib/dor/services/indexing_service.rb +8 -4
  54. data/lib/dor/services/merge_service.rb +5 -5
  55. data/lib/dor/services/metadata_handlers/catalog_handler.rb +1 -1
  56. data/lib/dor/services/metadata_service.rb +6 -8
  57. data/lib/dor/{models/concerns → services}/mods2dc.xslt +0 -0
  58. data/lib/dor/services/ontology.rb +35 -0
  59. data/lib/dor/services/open_data_license_service.rb +20 -0
  60. data/lib/dor/services/public_desc_metadata_service.rb +21 -14
  61. data/lib/dor/services/public_xml_service.rb +6 -6
  62. data/lib/dor/services/publish_metadata_service.rb +100 -0
  63. data/lib/dor/services/registration_service.rb +43 -46
  64. data/lib/dor/services/release_tag_service.rb +251 -0
  65. data/lib/dor/services/reset_workspace_service.rb +1 -3
  66. data/lib/dor/services/sdr_ingest_service.rb +5 -7
  67. data/lib/dor/services/search_service.rb +10 -10
  68. data/lib/dor/services/secondary_file_name_service.rb +10 -0
  69. data/lib/dor/services/shelving_service.rb +67 -0
  70. data/lib/dor/services/status_service.rb +121 -0
  71. data/lib/dor/services/suri_service.rb +3 -5
  72. data/lib/dor/services/tag_service.rb +100 -0
  73. data/lib/dor/services/technical_metadata_service.rb +5 -4
  74. data/lib/dor/services/version_service.rb +84 -0
  75. data/lib/dor/utils/ng_tidy.rb +1 -1
  76. data/lib/dor/utils/sdr_client.rb +25 -9
  77. data/lib/dor/version.rb +1 -1
  78. data/lib/dor/workflow/document.rb +13 -13
  79. data/lib/dor/workflow/process.rb +71 -26
  80. data/lib/tasks/rdoc.rake +1 -1
  81. metadata +77 -51
  82. data/config/certs/robots-dor-dev.crt +0 -29
  83. data/config/certs/robots-dor-dev.key +0 -27
  84. data/config/dev_console_env.rb +0 -80
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34400d0eac69c0ceb30ae0f68bab89c9f9a88e568b7c174495838a1b7cdad52e
4
- data.tar.gz: 92b08f85258d8f85a743c6a19f1086a6e77b7070cc38f873a2941c401054c83b
3
+ metadata.gz: 26a4905c3d1c7ff07df99e6b7de0ec136d87cb847c30e1e676332f2142fafeac
4
+ data.tar.gz: 476d89693752ff2e17aa58d5efb9e559abc79a610da4c6ea413755df64c57009
5
5
  SHA512:
6
- metadata.gz: 0cbfce9b71dbcfdf16dcf7de39addb71ef888672f94fbb1c04b3da944927235ee098f61a414fcf32db7f6597f34ca8b2e97a263b42008336512e97df79481ad0
7
- data.tar.gz: a61f68d51174b64015a7c45f9beb8bcac73764a46c41550b06c47eb804ac038596b29d87222ec844685f2f2e289539a5dfaf8fd9c4ca5d1e35e15cf782568fae
6
+ metadata.gz: 96957b78cb9f2e13efd0a82f3d20cc19dc9f544243bed791fe9c86cee69a179b88c1386511eaf4a1ac159d15868ecae40ffb1753847359b7b116d69fa7588fa8
7
+ data.tar.gz: f27dd546d898ebae9bae95ef3180296cc434b6fdd8a06e293d92bc8ba6db5fa327758a34f895d21b63f817504ceffc161bc065f6ee86e319d30d75adcbbe4d7d
data/lib/dor-services.rb CHANGED
@@ -30,7 +30,7 @@ module Dor
30
30
  # Dor.load_instance() if the item is not in the index, or is improperly indexed.
31
31
  # @param [String] pid The object's PID
32
32
  # @return [Object] the ActiveFedora-modeled object
33
- def find(pid, opts = {})
33
+ def find(pid, _opts = {})
34
34
  load_instance(pid)
35
35
  end
36
36
 
@@ -149,23 +149,38 @@ module Dor
149
149
 
150
150
  # Services
151
151
  autoload_under 'services' do
152
- autoload :SearchService
152
+ autoload :Ability
153
+ autoload :CleanupResetService
154
+ autoload :CleanupService
155
+ autoload :CreateWorkflowService
156
+ autoload :CreativeCommonsLicenseService
157
+ autoload :DatastreamBuilder
158
+ autoload :DigitalStacksService
159
+ autoload :DublinCoreService
160
+ autoload :FileMetadataMergeService
153
161
  autoload :IndexingService
154
162
  autoload :MetadataService
155
- autoload :RegistrationService
156
- autoload :SuriService
157
- autoload :WorkflowService
158
- autoload :DigitalStacksService
159
- autoload :SdrIngestService
160
- autoload :CleanupService
161
- autoload :ProvenanceMetadataService
162
- autoload :TechnicalMetadataService
163
163
  autoload :MergeService
164
- autoload :ResetWorkspaceService
165
- autoload :CleanupResetService
164
+ autoload :Ontology
165
+ autoload :OpenDataLicenseService
166
+ autoload :ProvenanceMetadataService
166
167
  autoload :PublicDescMetadataService
167
168
  autoload :PublicXmlService
169
+ autoload :PublishMetadataService
170
+ autoload :RegistrationService
171
+ autoload :ReleaseTagService
172
+ autoload :ResetWorkspaceService
173
+ autoload :SdrIngestService
174
+ autoload :SearchService
175
+ autoload :SecondaryFileNameService
176
+ autoload :ShelvingService
177
+ autoload :StatusService
178
+ autoload :SuriService
179
+ autoload :TagService
180
+ autoload :TechnicalMetadataService
168
181
  autoload :ThumbnailService
182
+ autoload :VersionService
183
+ autoload :WorkflowService
169
184
  end
170
185
 
171
186
  # Workflow Classes
data/lib/dor/config.rb CHANGED
@@ -4,6 +4,7 @@ require 'confstruct/configuration'
4
4
  require 'rsolr'
5
5
  require 'yaml'
6
6
  require 'dor/certificate_authenticated_rest_resource_factory'
7
+ require 'dor/services/client'
7
8
 
8
9
  module Dor
9
10
  class Configuration < Confstruct::Configuration
@@ -52,56 +53,58 @@ module Dor
52
53
 
53
54
  def make_solr_connection(add_opts = {})
54
55
  opts = Dor::Config.solr.opts.merge(add_opts).merge(
55
- :url => Dor::Config.solr.url
56
+ url: Dor::Config.solr.url
56
57
  )
57
58
  ::RSolr.connect(opts)
58
59
  end
59
60
 
60
61
  set_callback :initialize, :after do |config|
61
- config.deep_merge!({
62
- :fedora => {
63
- :client => Confstruct.deferred { |c| CertificateAuthenticatedRestResourceFactory.create(:fedora) },
64
- :safeurl => Confstruct.deferred { |c|
65
- begin
66
- fedora_uri = URI.parse(config.fedora.url)
67
- fedora_uri.user = fedora_uri.password = nil
68
- fedora_uri.to_s
69
- rescue URI::InvalidURIError
70
- nil
71
- end
72
- }
73
- },
74
- :dor_services => {
75
- :rest_client => Confstruct.deferred { |c| RestResourceFactory.create(:dor_services) }
76
- },
77
- :purl_services => {
78
- :rest_client => Confstruct.deferred { |c| RestResourceFactory.create(:purl_services) }
79
- },
80
- :sdr => {
81
- :rest_client => Confstruct.deferred { |c| RestResourceFactory.create(:sdr) }
82
- },
83
- :workflow => {
84
- :client => Confstruct.deferred do |c|
85
- Dor::WorkflowService.configure c.url, logger: c.client_logger, timeout: c.timeout, dor_services_url: config.dor_services.url
86
- Dor::WorkflowService
87
- end,
88
- :client_logger => Confstruct.deferred do |c|
89
- if c.logfile && c.shift_age
90
- Logger.new(c.logfile, c.shift_age)
91
- elsif c.logfile
92
- Logger.new(c.logfile)
93
- end
94
- end
95
- }
96
- })
62
+ config.deep_merge!(
63
+ fedora: {
64
+ client: Confstruct.deferred { |_c| CertificateAuthenticatedRestResourceFactory.create(:fedora) },
65
+ safeurl: Confstruct.deferred do |_c|
66
+ begin
67
+ fedora_uri = URI.parse(config.fedora.url)
68
+ fedora_uri.user = fedora_uri.password = nil
69
+ fedora_uri.to_s
70
+ rescue URI::InvalidURIError
71
+ nil
72
+ end
73
+ end
74
+ },
75
+ dor_services: {
76
+ rest_client: Confstruct.deferred { |_c| RestResourceFactory.create(:dor_services) }
77
+ },
78
+ purl_services: {
79
+ rest_client: Confstruct.deferred { |_c| RestResourceFactory.create(:purl_services) }
80
+ },
81
+ sdr: {
82
+ rest_client: Confstruct.deferred { |_c| RestResourceFactory.create(:sdr) }
83
+ },
84
+ workflow: {
85
+ client: Confstruct.deferred do |c|
86
+ Dor::WorkflowService.configure c.url, logger: c.client_logger, timeout: c.timeout, dor_services_url: config.dor_services.url
87
+ Dor::WorkflowService
88
+ end,
89
+ client_logger: Confstruct.deferred do |c|
90
+ if c.logfile && c.shift_age
91
+ Logger.new(c.logfile, c.shift_age)
92
+ elsif c.logfile
93
+ Logger.new(c.logfile)
94
+ end
95
+ end
96
+ }
97
+ )
97
98
  true
98
99
  end
99
100
 
100
101
  set_callback :configure, :after do |config|
102
+ Dor::Services::Client.configure(url: config.dor_services.url) if config.dor_services
103
+
101
104
  if config.solrizer.present?
102
105
  stack = Kernel.caller.dup
103
106
  stack.shift while stack[0] =~ %r{(active_support/callbacks|dor/config|dor-services)\.rb}
104
- ActiveSupport::Deprecation.warn "Dor::Config -- solrizer configuration is deprecated. Please use solr instead.", stack
107
+ ActiveSupport::Deprecation.warn 'Dor::Config -- solrizer configuration is deprecated. Please use solr instead.', stack
105
108
 
106
109
  config.solrizer.each do |k, v|
107
110
  config.solr[k] ||= v
@@ -120,7 +123,7 @@ module Dor
120
123
 
121
124
  def fedora_config
122
125
  fedora_uri = URI.parse(fedora.url)
123
- connection_opts = { :url => fedora.safeurl, :user => fedora_uri.user, :password => fedora_uri.password }
126
+ connection_opts = { url: fedora.safeurl, user: fedora_uri.user, password: fedora_uri.password }
124
127
  connection_opts[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(ssl.cert_file)) if ssl.cert_file.present?
125
128
  connection_opts[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(ssl.key_file), ssl.key_pass) if ssl.key_file.present?
126
129
  connection_opts[:ssl_cert_store] = default_ssl_cert_store
@@ -128,11 +131,11 @@ module Dor
128
131
  end
129
132
 
130
133
  def solr_config
131
- { :url => solr.url }
134
+ { url: solr.url }
132
135
  end
133
136
 
134
137
  def predicate_config
135
- YAML.load(File.read(File.expand_path('../../../config/predicate_mappings.yml', __FILE__)))
138
+ YAML.load(File.read(File.expand_path('../../config/predicate_mappings.yml', __dir__)))
136
139
  end
137
140
 
138
141
  def default_ssl_cert_store
@@ -140,6 +143,6 @@ module Dor
140
143
  end
141
144
  end
142
145
 
143
- Config = Configuration.new(YAML.load(File.read(File.expand_path('../../../config/config_defaults.yml', __FILE__))))
146
+ Config = Configuration.new(YAML.load(File.read(File.expand_path('../../config/config_defaults.yml', __dir__))))
144
147
  ActiveFedora.configurator = Config
145
148
  end
@@ -3,90 +3,90 @@
3
3
  module Dor
4
4
  class AdministrativeMetadataDS < ActiveFedora::OmDatastream
5
5
  set_terminology do |t|
6
- t.root :path => 'administrativeMetadata', :index_as => [:not_searchable]
7
- t.metadata_format :path => 'descMetadata/format'
8
- t.admin_metadata_format :path => 'descMetadata/format', :index_as => [:symbol]
9
- t.metadata_source :path => 'descMetadata/source', :index_as => [:symbol]
6
+ t.root path: 'administrativeMetadata', index_as: [:not_searchable]
7
+ t.metadata_format path: 'descMetadata/format'
8
+ t.admin_metadata_format path: 'descMetadata/format', index_as: [:symbol]
9
+ t.metadata_source path: 'descMetadata/source', index_as: [:symbol]
10
10
  t.descMetadata do
11
11
  t.source
12
12
  t.format
13
13
  end
14
14
  # Placeholders for existing defined stanzas to be fleshed out as needed
15
- t.contact :index_as => [:not_searchable]
16
- t.rights :index_as => [:not_searchable]
17
- t.relationships :index_as => [:not_searchable]
18
- t.registration :index_as => [:not_searchable] do
15
+ t.contact index_as: [:not_searchable]
16
+ t.rights index_as: [:not_searchable]
17
+ t.relationships index_as: [:not_searchable]
18
+ t.registration index_as: [:not_searchable] do
19
19
  t.agreementId
20
20
  t.itemTag
21
- t.workflow_id :path => 'workflow/@id', :index_as => [:symbol]
22
- t.default_collection :path => 'collection/@id'
21
+ t.workflow_id path: 'workflow/@id', index_as: [:symbol]
22
+ t.default_collection path: 'collection/@id'
23
23
  end
24
- t.workflow :path => 'registration/workflow'
25
- t.deposit :index_as => [:not_searchable]
24
+ t.workflow path: 'registration/workflow'
25
+ t.deposit index_as: [:not_searchable]
26
26
 
27
- t.accessioning :index_as => [:not_searchable] do
28
- t.workflow_id :path => 'workflow/@id', :index_as => [:symbol]
27
+ t.accessioning index_as: [:not_searchable] do
28
+ t.workflow_id path: 'workflow/@id', index_as: [:symbol]
29
29
  end
30
30
 
31
- t.preservation :index_as => [:not_searchable]
32
- t.dissemination :index_as => [:not_searchable] do
31
+ t.preservation index_as: [:not_searchable]
32
+ t.dissemination index_as: [:not_searchable] do
33
33
  t.harvester
34
34
  t.releaseDelayLimit
35
35
  end
36
36
  t.defaults do
37
- t.initiate_workflow :path => 'initiateWorkflow' do
38
- t.lane :path => { :attribute => 'lane' }
37
+ t.initiate_workflow path: 'initiateWorkflow' do
38
+ t.lane path: { attribute: 'lane' }
39
39
  end
40
- t.shelving :path => 'shelving' do
41
- t.path :path => { :attribute => 'path' }
40
+ t.shelving path: 'shelving' do
41
+ t.path path: { attribute: 'path' }
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
46
  define_template :default_collection do |xml|
47
- xml.administrativeMetadata {
48
- xml.registration {
49
- xml.collection(:id => '')
50
- }
51
- }
47
+ xml.administrativeMetadata do
48
+ xml.registration do
49
+ xml.collection(id: '')
50
+ end
51
+ end
52
52
  end
53
53
 
54
54
  define_template :agreementId do |xml|
55
- xml.administrativeMetadata {
56
- xml.registration {
55
+ xml.administrativeMetadata do
56
+ xml.registration do
57
57
  xml.agreementId
58
- }
59
- }
58
+ end
59
+ end
60
60
  end
61
61
 
62
62
  define_template :metadata_format do |xml|
63
- xml.descMetadata {
63
+ xml.descMetadata do
64
64
  xml.format
65
- }
65
+ end
66
66
  end
67
67
 
68
68
  define_template :metadata_source do |xml|
69
- xml.administrativeMetadata {
70
- xml.descMetadata {
69
+ xml.administrativeMetadata do
70
+ xml.descMetadata do
71
71
  xml.source
72
- }
73
- }
72
+ end
73
+ end
74
74
  end
75
75
 
76
76
  define_template :registration do |xml|
77
- xml.administrativeMetadata {
78
- xml.registration {
79
- xml.workflow(:id => '')
80
- }
81
- }
77
+ xml.administrativeMetadata do
78
+ xml.registration do
79
+ xml.workflow(id: '')
80
+ end
81
+ end
82
82
  end
83
83
 
84
84
  define_template :default_collection do |xml|
85
- xml.administrativeMetadata {
86
- xml.registration {
85
+ xml.administrativeMetadata do
86
+ xml.registration do
87
87
  xml.collection
88
- }
89
- }
88
+ end
89
+ end
90
90
  end
91
91
 
92
92
  def self.xml_template
@@ -116,6 +116,99 @@ module Dor
116
116
  defaults.shelving.path.first
117
117
  end
118
118
 
119
+ # get all collections listed for this APO, used during registration
120
+ # @return [Array] array of pids
121
+ def default_collections
122
+ term_values(:registration, :default_collection)
123
+ end
124
+
125
+ # Add a collection to the listing of collections for items governed by this apo.
126
+ # @param val [String] pid of the collection, ex. druid:ab123cd4567
127
+ def add_default_collection(val)
128
+ xml = ng_xml
129
+ ng_xml_will_change!
130
+ reg = xml.search('//administrativeMetadata/registration').first
131
+ unless reg
132
+ reg = Nokogiri::XML::Node.new('registration', xml)
133
+ xml.search('/administrativeMetadata').first.add_child(reg)
134
+ end
135
+ node = Nokogiri::XML::Node.new('collection', xml)
136
+ node['id'] = val
137
+ reg.add_child(node)
138
+ end
139
+
140
+ def remove_default_collection(val)
141
+ ng_xml_will_change!
142
+ ng_xml.search('//administrativeMetadata/registration/collection[@id=\'' + val + '\']').remove
143
+ end
144
+
145
+ def metadata_source
146
+ super.first
147
+ end
148
+
149
+ def metadata_source=(val)
150
+ if descMetadata.nil?
151
+ ng_xml_will_change!
152
+ add_child_node(administrativeMetadata, :descMetadata)
153
+ end
154
+ update_values(%i[descMetadata source] => val)
155
+ end
156
+
157
+ # List of default workflows, used to provide choices at registration
158
+ # @return [Array] and array of pids, ex ['druid:ab123cd4567']
159
+ def default_workflows
160
+ term_values(:registration, :workflow_id)
161
+ end
162
+
163
+ # set a single default workflow
164
+ # @param wf [String] the name of the workflow, ex. 'digitizationWF'
165
+ def default_workflow=(wf_name)
166
+ raise ArgumentError, 'Must have a valid workflow for default' if wf_name.blank?
167
+
168
+ xml = ng_xml
169
+ ng_xml_will_change!
170
+ nodes = xml.search('//registration/workflow')
171
+ if nodes.first
172
+ nodes.first['id'] = wf_name
173
+ else
174
+ nodes = xml.search('//registration')
175
+ unless nodes.first
176
+ reg_node = Nokogiri::XML::Node.new('registration', xml)
177
+ xml.root.add_child(reg_node)
178
+ end
179
+ nodes = xml.search('//registration')
180
+ wf_node = Nokogiri::XML::Node.new('workflow', xml)
181
+ wf_node['id'] = wf_name
182
+ nodes.first.add_child(wf_node)
183
+ end
184
+ end
185
+
186
+ def desc_metadata_format
187
+ metadata_format.first
188
+ end
189
+
190
+ def desc_metadata_format=(format)
191
+ # create the node if it isnt there already
192
+ unless metadata_format.first
193
+ ng_xml_will_change!
194
+ add_child_node(ng_xml.root, :metadata_format)
195
+ end
196
+ update_values([:metadata_format] => format)
197
+ end
198
+
199
+ def desc_metadata_source
200
+ metadata_source.first
201
+ end
202
+
203
+ def desc_metadata_source=(_source)
204
+ # create the node if it isnt there already
205
+ unless metadata_source.first
206
+ ng_xml_will_change!
207
+ add_child_node(administrativeMetadata.ng_xml.root, :metadata_source)
208
+ end
209
+ update_values([:metadata_source] => format)
210
+ end
211
+
119
212
  # maintain AF < 8 indexing behavior
120
213
  def prefix
121
214
  ''
@@ -5,34 +5,34 @@ require 'set'
5
5
  module Dor
6
6
  class ContentMetadataDS < ActiveFedora::OmDatastream
7
7
  set_terminology do |t|
8
- t.root :path => 'contentMetadata', :index_as => [:not_searchable]
9
- t.contentType :path => '/contentMetadata/@type', :index_as => [:not_searchable]
10
- t.stacks :path => '/contentMetadata/@stacks', :index_as => [:not_searchable]
11
- t.resource(:index_as => [:not_searchable]) do
12
- t.id_ :path => { :attribute => 'id' }
13
- t.sequence :path => { :attribute => 'sequence' } # , :data_type => :integer
14
- t.type_ :path => { :attribute => 'type' }, :index_as => [:displayable]
15
- t.attribute(:path => 'attr', :index_as => [:not_searchable]) do
16
- t.name :path => { :attribute => 'name' }, :index_as => [:not_searchable]
8
+ t.root path: 'contentMetadata', index_as: [:not_searchable]
9
+ t.contentType path: '/contentMetadata/@type', index_as: [:not_searchable]
10
+ t.stacks path: '/contentMetadata/@stacks', index_as: [:not_searchable]
11
+ t.resource(index_as: [:not_searchable]) do
12
+ t.id_ path: { attribute: 'id' }
13
+ t.sequence path: { attribute: 'sequence' } # , :data_type => :integer
14
+ t.type_ path: { attribute: 'type' }, index_as: [:displayable]
15
+ t.attribute(path: 'attr', index_as: [:not_searchable]) do
16
+ t.name path: { attribute: 'name' }, index_as: [:not_searchable]
17
17
  end
18
- t.file(:index_as => [:not_searchable]) do
19
- t.id_ :path => { :attribute => 'id' }
20
- t.mimeType :path => { :attribute => 'mimeType' }, :index_as => [:displayable]
21
- t.dataType :path => { :attribute => 'dataType' }, :index_as => [:displayable]
22
- t.size :path => { :attribute => 'size' }, :index_as => [:displayable] # , :data_type => :long
23
- t.role :path => { :attribute => 'role' }, :index_as => [:not_searchable]
24
- t.shelve :path => { :attribute => 'shelve' }, :index_as => [:not_searchable] # , :data_type => :boolean
25
- t.publish :path => { :attribute => 'publish' }, :index_as => [:not_searchable] # , :data_type => :boolean
26
- t.preserve :path => { :attribute => 'preserve' }, :index_as => [:not_searchable] # , :data_type => :boolean
18
+ t.file(index_as: [:not_searchable]) do
19
+ t.id_ path: { attribute: 'id' }
20
+ t.mimeType path: { attribute: 'mimeType' }, index_as: [:displayable]
21
+ t.dataType path: { attribute: 'dataType' }, index_as: [:displayable]
22
+ t.size path: { attribute: 'size' }, index_as: [:displayable] # , :data_type => :long
23
+ t.role path: { attribute: 'role' }, index_as: [:not_searchable]
24
+ t.shelve path: { attribute: 'shelve' }, index_as: [:not_searchable] # , :data_type => :boolean
25
+ t.publish path: { attribute: 'publish' }, index_as: [:not_searchable] # , :data_type => :boolean
26
+ t.preserve path: { attribute: 'preserve' }, index_as: [:not_searchable] # , :data_type => :boolean
27
27
  t.checksum do
28
- t.type_ :path => { :attribute => 'type' }
28
+ t.type_ path: { attribute: 'type' }
29
29
  end
30
30
  end
31
- t.shelved_file(:path => 'file', :attributes => { :shelve => 'yes' }, :index_as => [:not_searchable]) do
32
- t.id_ :path => { :attribute => 'id' }, :index_as => [:displayable, :stored_searchable]
31
+ t.shelved_file(path: 'file', attributes: { shelve: 'yes' }, index_as: [:not_searchable]) do
32
+ t.id_ path: { attribute: 'id' }, index_as: %i[displayable stored_searchable]
33
33
  end
34
34
  end
35
- t.shelved_file_id :proxy => [:resource, :shelved_file, :id], :index_as => [:displayable, :stored_searchable]
35
+ t.shelved_file_id proxy: %i[resource shelved_file id], index_as: %i[displayable stored_searchable]
36
36
  end
37
37
 
38
38
  ### READ ONLY METHODS
@@ -80,7 +80,7 @@ module Dor
80
80
  # Terminology-based solrization is going to be painfully slow for large
81
81
  # contentMetadata streams. Just select the relevant elements instead.
82
82
  # TODO: Call super()?
83
- def to_solr(solr_doc = {}, *args)
83
+ def to_solr(solr_doc = {}, *_args)
84
84
  doc = ng_xml
85
85
  return solr_doc unless doc.root['type']
86
86
 
@@ -134,7 +134,7 @@ module Dor
134
134
  resource_nodes = ng_xml.search('//resource[@id=\'' + resource_name + '\']')
135
135
  raise 'resource doesnt exist.' if resource_nodes.length == 0
136
136
 
137
- self.ng_xml_will_change!
137
+ ng_xml_will_change!
138
138
 
139
139
  node = resource_nodes.first
140
140
  file_node = Nokogiri::XML::Node.new('file', ng_xml)
@@ -144,7 +144,7 @@ module Dor
144
144
  file_node['preserve'] = file[:preserve] || ''
145
145
  node.add_child(file_node)
146
146
 
147
- [:md5, :sha1].each do |algo|
147
+ %i[md5 sha1].each do |algo|
148
148
  next unless file[algo]
149
149
 
150
150
  checksum_node = Nokogiri::XML::Node.new('checksum', ng_xml)
@@ -165,7 +165,7 @@ module Dor
165
165
  # @return [Nokogiri::XML::Element] the new resource that was added to the contentMetadata
166
166
  def add_virtual_resource(child_druid, child_resource)
167
167
  # create a virtual resource element with attributes linked to the child and omit label
168
- self.ng_xml_will_change!
168
+ ng_xml_will_change!
169
169
  sequence_max = ng_xml.search('//resource').map { |node| node[:sequence].to_i }.max
170
170
  resource = Nokogiri::XML::Element.new('resource', ng_xml)
171
171
  resource[:sequence] = sequence_max + 1
@@ -191,7 +191,7 @@ module Dor
191
191
  def add_resource(files, resource_name, position, type = 'file')
192
192
  raise "resource #{resource_name} already exists" if ng_xml.search('//resource[@id=\'' + resource_name + '\']').length > 0
193
193
 
194
- self.ng_xml_will_change!
194
+ ng_xml_will_change!
195
195
  max = ng_xml.search('//resource').map { |node| node['sequence'].to_i }.max
196
196
  # renumber all of the resources that will come after the newly added one
197
197
  while max > position
@@ -209,14 +209,14 @@ module Dor
209
209
  file_node['id'] = file[:name]
210
210
  node.add_child(file_node)
211
211
 
212
- [:md5, :sha1].each { |algo|
212
+ %i[md5 sha1].each do |algo|
213
213
  next if file[algo].nil?
214
214
 
215
215
  checksum_node = Nokogiri::XML::Node.new('checksum', ng_xml)
216
216
  checksum_node['type'] = algo.to_s
217
217
  checksum_node.content = file[algo]
218
218
  file_node.add_child(checksum_node)
219
- }
219
+ end
220
220
  file_node['size'] = file[:size] if file[:size]
221
221
  file_node['role'] = file[:role] if file[:role]
222
222
  end
@@ -226,7 +226,7 @@ module Dor
226
226
 
227
227
  # @param [String] resource_name ID of the resource
228
228
  def remove_resource(resource_name)
229
- self.ng_xml_will_change!
229
+ ng_xml_will_change!
230
230
  node = singular_node('//resource[@id=\'' + resource_name + '\']')
231
231
  position = node['sequence'].to_i + 1
232
232
  node.remove
@@ -241,7 +241,7 @@ module Dor
241
241
 
242
242
  # @param [String] file_name ID of the file element
243
243
  def remove_file(file_name)
244
- self.ng_xml_will_change!
244
+ ng_xml_will_change!
245
245
  ng_xml.search('//file[@id=\'' + file_name + '\']').each(&:remove)
246
246
  end
247
247
 
@@ -250,7 +250,7 @@ module Dor
250
250
  # @param [String] shelve
251
251
  # @param [String] preserve
252
252
  def update_attributes(file_name, publish, shelve, preserve, attributes = {})
253
- self.ng_xml_will_change!
253
+ ng_xml_will_change!
254
254
  file_node = ng_xml.search('//file[@id=\'' + file_name + '\']').first
255
255
  file_node['publish'] = publish
256
256
  file_node['shelve'] = shelve
@@ -263,10 +263,10 @@ module Dor
263
263
  # @param file [Object] some hash-like file
264
264
  # @param old_file_id [String] unique id attribute of the file element
265
265
  def update_file(file, old_file_id)
266
- self.ng_xml_will_change!
266
+ ng_xml_will_change!
267
267
  file_node = ng_xml.search('//file[@id=\'' + old_file_id + '\']').first
268
268
  file_node['id'] = file[:name]
269
- [:md5, :sha1].each { |algo|
269
+ %i[md5 sha1].each do |algo|
270
270
  next if file[algo].nil?
271
271
 
272
272
  checksum_node = ng_xml.search('//file[@id=\'' + old_file_id + '\']/checksum[@type=\'' + algo.to_s + '\']').first
@@ -276,18 +276,18 @@ module Dor
276
276
  end
277
277
  checksum_node['type'] = algo.to_s
278
278
  checksum_node.content = file[algo]
279
- }
279
+ end
280
280
 
281
- [:size, :shelve, :preserve, :publish, :role].each { |x|
281
+ %i[size shelve preserve publish role].each do |x|
282
282
  file_node[x.to_s] = file[x] if file[x]
283
- }
283
+ end
284
284
  end
285
285
 
286
286
  # @param old_name [String] unique id attribute of the file element
287
287
  # @param new_name [String] new unique id value being assigned
288
288
  # @return [Nokogiri::XML::Element] the file node
289
289
  def rename_file(old_name, new_name)
290
- self.ng_xml_will_change!
290
+ ng_xml_will_change!
291
291
  file_node = ng_xml.search('//file[@id=\'' + old_name + '\']').first
292
292
  file_node['id'] = new_name
293
293
  file_node
@@ -298,7 +298,7 @@ module Dor
298
298
  # @param new_label [String] label value being assigned
299
299
  # @return [Nokogiri::XML::Element] the resource node
300
300
  def update_resource_label(resource_name, new_label)
301
- self.ng_xml_will_change!
301
+ ng_xml_will_change!
302
302
  node = singular_node('//resource[@id=\'' + resource_name + '\']')
303
303
  labels = node.xpath('./label')
304
304
  if labels.length == 0
@@ -314,7 +314,7 @@ module Dor
314
314
  # @param resource_name [String] unique id attribute of the resource
315
315
  # @param new_type [String] type value being assigned
316
316
  def update_resource_type(resource_name, new_type)
317
- self.ng_xml_will_change!
317
+ ng_xml_will_change!
318
318
  singular_node('//resource[@id=\'' + resource_name + '\']')['type'] = new_type
319
319
  end
320
320
 
@@ -324,7 +324,7 @@ module Dor
324
324
  # @param new_position [Integer, String] new sequence number of the resource, or a string that looks like one
325
325
  # @return [Nokogiri::XML::Element] the resource node
326
326
  def move_resource(resource_name, new_position)
327
- self.ng_xml_will_change!
327
+ ng_xml_will_change!
328
328
  node = singular_node('//resource[@id=\'' + resource_name + '\']')
329
329
  position = node['sequence'].to_i
330
330
  new_position = new_position.to_i # tolerate strings as a Legacy behavior
@@ -347,7 +347,7 @@ module Dor
347
347
  # @param [String] new_type the new content type
348
348
  # @param [String] new_resource_type the new type for all resources
349
349
  def set_content_type(old_type, old_resource_type, new_type, new_resource_type)
350
- self.ng_xml_will_change!
350
+ ng_xml_will_change!
351
351
  ng_xml.search('/contentMetadata[@type=\'' + old_type + '\']').each do |node|
352
352
  node['type'] = new_type
353
353
  ng_xml.search('//resource[@type=\'' + old_resource_type + '\']').each do |resource|