dor-services 5.15.1 → 5.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dor-services.rb +1 -2
  3. data/lib/dor/config.rb +2 -2
  4. data/lib/dor/datastreams/content_metadata_ds.rb +13 -13
  5. data/lib/dor/datastreams/default_object_rights_ds.rb +5 -5
  6. data/lib/dor/datastreams/embargo_metadata_ds.rb +0 -3
  7. data/lib/dor/datastreams/events_ds.rb +1 -1
  8. data/lib/dor/datastreams/rights_metadata_ds.rb +1 -2
  9. data/lib/dor/datastreams/version_metadata_ds.rb +3 -2
  10. data/lib/dor/models/contentable.rb +1 -1
  11. data/lib/dor/models/describable.rb +9 -55
  12. data/lib/dor/models/editable.rb +3 -3
  13. data/lib/dor/models/embargoable.rb +4 -4
  14. data/lib/dor/models/identifiable.rb +1 -17
  15. data/lib/dor/models/item.rb +0 -1
  16. data/lib/dor/models/preservable.rb +2 -4
  17. data/lib/dor/models/processable.rb +1 -2
  18. data/lib/dor/models/publishable.rb +2 -2
  19. data/lib/dor/models/rightsable.rb +0 -1
  20. data/lib/dor/models/versionable.rb +1 -2
  21. data/lib/dor/services/search_service.rb +8 -8
  22. data/lib/dor/utils/ng_tidy.rb +4 -3
  23. data/lib/dor/utils/solr_doc_helper.rb +4 -10
  24. data/lib/dor/version.rb +1 -1
  25. metadata +11 -15
  26. data/lib/dor/migrations/content_metadata_ds/change_content_type.rb +0 -7
  27. data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +0 -9
  28. data/lib/dor/migrations/identifiable/fix_model_assertions.rb +0 -13
  29. data/lib/dor/migrations/identifiable/record_remediation.rb +0 -18
  30. data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +0 -18
  31. data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +0 -18
  32. data/lib/dor/migrations/processable/unify_workflows.rb +0 -17
  33. data/lib/dor/migrations/versionable/add_missing_version_md.rb +0 -9
  34. data/lib/dor/models/upgradable.rb +0 -73
  35. data/lib/dor/services/tei2dc.xslt +0 -102
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee2e3a30df6e10c8613e8ca4bb85a1b333f3ebe3
4
- data.tar.gz: 09c691788a6ea4638c79043c7bfd8c247d0fde05
3
+ metadata.gz: 6f1d00053e0c4619d64ea02c747efffeae0ba54e
4
+ data.tar.gz: 46e5cc9321777766ac8a0e37766c5737b8d3bbd8
5
5
  SHA512:
6
- metadata.gz: 6353ffe9a29cc00e13aab8cec082809f23f0fab7cf612853b33f7e3004f3847bd24186c5e1a6accf34fd391e99b00a2f2bc972aeb25d4d654724e8ec0ddb1252
7
- data.tar.gz: 897831d91a6a4e283442032263186c5a6eaeb6a18e00b9d398ecb247f674f69619c872350759e4efc24735ee0827e31359072e7752234bbc1d199f5b73fb1075
6
+ metadata.gz: 957be3c6e10cf559b4266d52abb5ef0d2de3457d4ffe7459eb62f3c60a8aee37e47c857e5391d3fd9a97f94f5d06abd74cedd06d4fc66746fe22be7783cea018
7
+ data.tar.gz: 5d2ae7bb68ab836139fafa2120678980edcc7cb1d49e66e2683ac739cb8dddde3b09a7e955dbd2a03f091feae159895953b39ff64f15c4ebe82cfe6e03a8dd07
data/lib/dor-services.rb CHANGED
@@ -40,7 +40,7 @@ module Dor
40
40
  # TODO: restrict fieldlist (fl) for non-:lightweight queries
41
41
  def find_all(query, opts = {})
42
42
  resp = SearchService.query query, opts
43
- resp.docs.collect do |solr_doc|
43
+ resp['response']['docs'].collect do |solr_doc|
44
44
  doc_version = solr_doc[INDEX_VERSION_FIELD].first rescue '0.0.0'
45
45
  doc_version = Gem::Version.new(doc_version)
46
46
  object_type = Array(solr_doc[ActiveFedora::SolrService.solr_name('objectType', :symbol)]).first
@@ -122,7 +122,6 @@ module Dor
122
122
  autoload :Embargoable, 'dor/models/embargoable'
123
123
  autoload :Preservable, 'dor/models/preservable'
124
124
  autoload :Assembleable, 'dor/models/assembleable'
125
- autoload :Upgradable, 'dor/models/upgradable'
126
125
  autoload :Eventable, 'dor/models/eventable'
127
126
  autoload :Versionable, 'dor/models/versionable'
128
127
  autoload :Contentable, 'dor/models/contentable'
data/lib/dor/config.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'confstruct/configuration'
2
- require 'rsolr-ext'
2
+ require 'rsolr'
3
3
  require 'stomp'
4
4
  require 'yaml'
5
5
 
@@ -49,7 +49,7 @@ module Dor
49
49
  opts = Dor::Config.solr.opts.merge(add_opts).merge(
50
50
  :url => Dor::Config.solr.url
51
51
  )
52
- ::RSolr::Ext.connect(opts)
52
+ ::RSolr.connect(opts)
53
53
  end
54
54
 
55
55
  set_callback :initialize, :after do |config|
@@ -1,6 +1,5 @@
1
1
  module Dor
2
2
  class ContentMetadataDS < ActiveFedora::OmDatastream
3
- include Upgradable
4
3
 
5
4
  set_terminology do |t|
6
5
  t.root :path => 'contentMetadata', :index_as => [:not_searchable]
@@ -158,6 +157,8 @@ module Dor
158
157
  def add_file(file, resource_name)
159
158
  resource_nodes = ng_xml.search('//resource[@id=\'' + resource_name + '\']')
160
159
  raise 'resource doesnt exist.' if resource_nodes.length == 0
160
+ self.ng_xml_will_change!
161
+
161
162
  node = resource_nodes.first
162
163
  file_node = Nokogiri::XML::Node.new('file', ng_xml)
163
164
  file_node['id'] = file[:name]
@@ -175,7 +176,6 @@ module Dor
175
176
  end
176
177
  file_node['size' ] = file[:size ] if file[:size ]
177
178
  file_node['mimetype'] = file[:mime_type] if file[:mime_type]
178
- self.content = ng_xml.to_s
179
179
  file_node
180
180
  end
181
181
 
@@ -186,6 +186,7 @@ module Dor
186
186
  # @return [Nokogiri::XML::Element] the new resource that was added to the contentMetadata
187
187
  def add_virtual_resource(child_druid, child_resource)
188
188
  # create a virtual resource element with attributes linked to the child and omit label
189
+ self.ng_xml_will_change!
189
190
  sequence_max = ng_xml.search('//resource').map { |node| node[:sequence].to_i }.max
190
191
  resource = Nokogiri::XML::Element.new('resource', ng_xml)
191
192
  resource[:sequence] = sequence_max + 1
@@ -200,7 +201,6 @@ module Dor
200
201
 
201
202
  # attach the virtual resource as a sibling and return
202
203
  ng_xml.root << resource
203
- self.content = ng_xml.to_s
204
204
  resource
205
205
  end
206
206
 
@@ -211,6 +211,7 @@ module Dor
211
211
  # @return [Nokogiri::XML::Node] the new resource that was added to the contentMetadata
212
212
  def add_resource(files, resource_name, position, type = 'file')
213
213
  raise "resource #{resource_name} already exists" if ng_xml.search('//resource[@id=\'' + resource_name + '\']').length > 0
214
+ self.ng_xml_will_change!
214
215
  max = ng_xml.search('//resource').map { |node| node['sequence'].to_i }.max
215
216
  # renumber all of the resources that will come after the newly added one
216
217
  while max > position
@@ -238,12 +239,12 @@ module Dor
238
239
  file_node['size'] = file[:size] if file[:size]
239
240
  end
240
241
  ng_xml.search('//contentMetadata').first.add_child(node)
241
- self.content = ng_xml.to_s
242
242
  node
243
243
  end
244
244
 
245
245
  # @param [String] resource_name ID of the resource
246
246
  def remove_resource(resource_name)
247
+ self.ng_xml_will_change!
247
248
  node = singular_node('//resource[@id=\'' + resource_name + '\']')
248
249
  position = node['sequence'].to_i + 1
249
250
  node.remove
@@ -253,13 +254,12 @@ module Dor
253
254
  res['sequence'] = position.to_s
254
255
  position += 1
255
256
  end
256
- self.content = ng_xml.to_s
257
257
  end
258
258
 
259
259
  # @param [String] file_name ID of the file element
260
260
  def remove_file(file_name)
261
+ self.ng_xml_will_change!
261
262
  ng_xml.search('//file[@id=\'' + file_name + '\']').each(&:remove)
262
- self.content = ng_xml.to_s
263
263
  end
264
264
 
265
265
  # @param [String] file_name ID of the file element
@@ -267,16 +267,17 @@ module Dor
267
267
  # @param [String] shelve
268
268
  # @param [String] preserve
269
269
  def update_attributes(file_name, publish, shelve, preserve)
270
+ self.ng_xml_will_change!
270
271
  file_node = ng_xml.search('//file[@id=\'' + file_name + '\']').first
271
272
  file_node['publish' ] = publish
272
273
  file_node['shelve' ] = shelve
273
274
  file_node['preserve'] = preserve
274
- self.content = ng_xml.to_s
275
275
  end
276
276
 
277
277
  # @param file [Object] some hash-like file
278
278
  # @param old_file_id [String] unique id attribute of the file element
279
279
  def update_file(file, old_file_id)
280
+ self.ng_xml_will_change!
280
281
  file_node = ng_xml.search('//file[@id=\'' + old_file_id + '\']').first
281
282
  file_node['id'] = file[:name]
282
283
  [:md5, :sha1].each { |algo|
@@ -293,16 +294,15 @@ module Dor
293
294
  [:size, :shelve, :preserve, :publish].each { |x|
294
295
  file_node[x.to_s] = file[x] if file[x]
295
296
  }
296
- self.content = ng_xml.to_s
297
297
  end
298
298
 
299
299
  # @param old_name [String] unique id attribute of the file element
300
300
  # @param new_name [String] new unique id value being assigned
301
301
  # @return [Nokogiri::XML::Element] the file node
302
302
  def rename_file(old_name, new_name)
303
+ self.ng_xml_will_change!
303
304
  file_node = ng_xml.search('//file[@id=\'' + old_name + '\']').first
304
305
  file_node['id'] = new_name
305
- self.content = ng_xml.to_s
306
306
  file_node
307
307
  end
308
308
 
@@ -311,6 +311,7 @@ module Dor
311
311
  # @param new_label [String] label value being assigned
312
312
  # @return [Nokogiri::XML::Element] the resource node
313
313
  def update_resource_label(resource_name, new_label)
314
+ self.ng_xml_will_change!
314
315
  node = singular_node('//resource[@id=\'' + resource_name + '\']')
315
316
  labels = node.xpath('./label')
316
317
  if labels.length == 0
@@ -320,15 +321,14 @@ module Dor
320
321
  else
321
322
  labels.first.content = new_label
322
323
  end
323
- self.content = ng_xml.to_s
324
324
  node
325
325
  end
326
326
 
327
327
  # @param resource_name [String] unique id attribute of the resource
328
328
  # @param new_type [String] type value being assigned
329
329
  def update_resource_type(resource_name, new_type)
330
+ self.ng_xml_will_change!
330
331
  singular_node('//resource[@id=\'' + resource_name + '\']')['type'] = new_type
331
- self.content = ng_xml.to_s
332
332
  end
333
333
 
334
334
  # You just *had* to have ordered lists in XML, didn't you?
@@ -337,6 +337,7 @@ module Dor
337
337
  # @param new_position [Integer, String] new sequence number of the resource, or a string that looks like one
338
338
  # @return [Nokogiri::XML::Element] the resource node
339
339
  def move_resource(resource_name, new_position)
340
+ self.ng_xml_will_change!
340
341
  node = singular_node('//resource[@id=\'' + resource_name + '\']')
341
342
  position = node['sequence'].to_i
342
343
  new_position = new_position.to_i # tolerate strings as a Legacy behavior
@@ -349,7 +350,6 @@ module Dor
349
350
  item['sequence'] = (up ? i - 1 : i + 1).to_s # if you're going up, everything else comes down and vice versa
350
351
  end
351
352
  node['sequence'] = new_position.to_s # set the node we already had last, so we don't hit it twice!
352
- self.content = ng_xml.to_s
353
353
  node
354
354
  end
355
355
 
@@ -359,13 +359,13 @@ module Dor
359
359
  # @param [String] new_type the new content type
360
360
  # @param [String] new_resource_type the new type for all resources
361
361
  def set_content_type(old_type, old_resource_type, new_type, new_resource_type)
362
+ self.ng_xml_will_change!
362
363
  ng_xml.search('/contentMetadata[@type=\'' + old_type + '\']').each do |node|
363
364
  node['type'] = new_type
364
365
  ng_xml.search('//resource[@type=\'' + old_resource_type + '\']').each do |resource|
365
366
  resource['type'] = new_resource_type
366
367
  end
367
368
  end
368
- self.content = ng_xml.to_s
369
369
  end
370
370
 
371
371
  # maintain AF < 8 indexing behavior
@@ -1,5 +1,9 @@
1
1
  module Dor
2
2
  class DefaultObjectRightsDS < ActiveFedora::OmDatastream
3
+ # Note that the XSL file was taken from the (apparently defunct) nokogiri-pretty project:
4
+ # https://github.com/tobym/nokogiri-pretty/blob/master/lib/indent.xsl
5
+ # The only modification made was to declare UTF-8 to be the encoding, instead of ISO-8859-1.
6
+ HUMAN_XSLT = Nokogiri::XSLT(File.read(File.expand_path('../human.xslt', __FILE__)))
3
7
 
4
8
  set_terminology do |t|
5
9
  t.root :path => 'rightsMetadata', :index_as => [:not_searchable]
@@ -131,12 +135,8 @@ module Dor
131
135
  end
132
136
 
133
137
  # Returns a nicely indented XML document.
134
- # Note that the XSL file was taken from the (apparently defunct) nokogiri-pretty project:
135
- # https://github.com/tobym/nokogiri-pretty/blob/master/lib/indent.xsl
136
- # The only modification made was to declare UTF-8 to be the encoding, instead of ISO-8859-1.
137
138
  def prettify(xml_doc)
138
- template = Nokogiri::XSLT(File.read(File.expand_path('../human.xslt', __FILE__)))
139
- template.apply_to(xml_doc)
139
+ HUMAN_XSLT.apply_to(xml_doc)
140
140
  end
141
141
 
142
142
  # maintain AF < 8 indexing behavior
@@ -58,7 +58,6 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
58
58
  # @param [Time] rd the release date object
59
59
  def release_date=(rd = Time.now.utc)
60
60
  update_values([:release_date] => rd.utc.xmlschema)
61
- self.content = ng_xml.to_s
62
61
  end
63
62
 
64
63
  # Current releaseDate value
@@ -70,7 +69,6 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
70
69
 
71
70
  def twenty_pct_status=(new_status)
72
71
  update_values([:twenty_pct_status] => new_status)
73
- content_will_change!
74
72
  end
75
73
 
76
74
  def twenty_pct_status
@@ -81,7 +79,6 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
81
79
  # @param [Time] rd A Time object represeting the release date. By default, it is set to now
82
80
  def twenty_pct_release_date=(rd = Time.now.utc)
83
81
  update_values([:twenty_pct_release_date] => rd.beginning_of_day.utc.xmlschema)
84
- content_will_change!
85
82
  end
86
83
 
87
84
  # Current twentyPctVisibilityReleaseDate value
@@ -29,10 +29,10 @@ class EventsDS < ActiveFedora::OmDatastream
29
29
  # @param [String] who who is responsible for this event. Sets the who attribute for the event
30
30
  # @param [String] message what happened. Sets the content of the event with this message
31
31
  def add_event(type, who, message)
32
+ ng_xml_will_change!
32
33
  ev = ng_xml.create_element 'event', message,
33
34
  :type => type, :who => who, :when => Time.now.utc.xmlschema
34
35
  ng_xml.root.add_child(ev)
35
- ng_xml_will_change!
36
36
  end
37
37
 
38
38
  # Finds events with the desired type attribute
@@ -128,11 +128,10 @@ module Dor
128
128
  raise('The rights metadata stream doesnt contain an entry for machine read permissions. Consider populating it from the APO before trying to change it.')
129
129
  end
130
130
 
131
+ ng_xml_will_change!
131
132
  RightsMetadataDS.upd_rights_xml_for_rights_type(rights_xml, rights)
132
133
 
133
134
  self.dra_object = nil # until TODO complete, we'll expect to have to reparse after modification
134
- self.content = rights_xml.to_xml
135
- content_will_change!
136
135
  end
137
136
 
138
137
  def to_solr(solr_doc = {}, *args)
@@ -78,7 +78,8 @@ module Dor
78
78
  # @param [Symbol] significance optional which part of the version tag to increment
79
79
  # :major, :minor, :admin (see VersionTag#increment)
80
80
  def increment_version(description = nil, significance = nil)
81
- if find_by_terms(:version).size == 0
81
+ ng_xml_will_change!
82
+ if find_by_terms(:version).size == 0
82
83
  v = ng_xml.create_element 'version',
83
84
  :versionId => '1', :tag => '1.0.0'
84
85
  d = ng_xml.create_element 'description', 'Initial Version'
@@ -122,6 +123,7 @@ module Dor
122
123
  ng_xml.root['objectId'] = pid
123
124
  return if find_by_terms(:version).size == 1
124
125
  return if opts.empty?
126
+ ng_xml_will_change!
125
127
  current = current_version_node
126
128
  if opts.include? :description
127
129
  d = current.at_xpath('description')
@@ -145,7 +147,6 @@ module Dor
145
147
  end
146
148
 
147
149
  end
148
- self.content = ng_xml.to_s
149
150
  end
150
151
 
151
152
  # @return [Boolean] returns true if the current version has a tag and a description, false otherwise
@@ -157,6 +157,7 @@ module Dor
157
157
  # @param [Array<String>] source_obj_pids ids of the secondary objects that will get their contentMetadata merged into this one
158
158
  def copy_file_resources(source_obj_pids)
159
159
  primary_cm = contentMetadata.ng_xml
160
+ contentMetadata.ng_xml_will_change!
160
161
  base_id = primary_cm.at_xpath('/contentMetadata/@objectId').value
161
162
  max_sequence = primary_cm.at_xpath('/contentMetadata/resource[last()]/@sequence').value.to_i
162
163
 
@@ -198,7 +199,6 @@ module Dor
198
199
  resource_copy.first_element_child.add_previous_sibling attr_node
199
200
  end
200
201
  end
201
- contentMetadata.content_will_change!
202
202
  end
203
203
 
204
204
  def new_secondary_file_name(old_name, sequence_num)
@@ -2,10 +2,8 @@ module Dor
2
2
  module Describable
3
3
  extend ActiveSupport::Concern
4
4
 
5
- DESC_MD_FORMATS = {
6
- 'http://www.tei-c.org/ns/1.0' => 'tei',
7
- 'http://www.loc.gov/mods/v3' => 'mods'
8
- }.freeze
5
+ MODS_TO_DC_XSLT = Nokogiri::XSLT(File.new(File.expand_path(File.dirname(__FILE__) + "/mods2dc.xslt")))
6
+
9
7
  class CrosswalkError < Exception; end
10
8
 
11
9
  included do
@@ -43,12 +41,10 @@ module Dor
43
41
  # Should not be used for the Fedora DC datastream
44
42
  # @raise [CrosswalkError] Raises an Exception if the generated DC is empty or has no children
45
43
  # @return [Nokogiri::Doc] the DublinCore XML document object
46
- def generate_dublin_core
47
- raise CrosswalkError, "Unknown descMetadata namespace: #{metadata_namespace.inspect}" if metadata_format.nil?
48
- xslt = Nokogiri::XSLT(File.new(File.expand_path(File.dirname(__FILE__) + "/#{metadata_format}2dc.xslt")) )
44
+ def generate_dublin_core(include_collection_as_related_item: true)
49
45
  desc_md = descMetadata.ng_xml.dup(1)
50
- add_collection_reference(desc_md)
51
- dc_doc = xslt.transform(desc_md)
46
+ add_collection_reference(desc_md) if include_collection_as_related_item
47
+ dc_doc = MODS_TO_DC_XSLT.transform(desc_md)
52
48
  dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]').remove # Remove empty nodes
53
49
  raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no root):\n#{dc_doc.to_xml}" if dc_doc.root.nil?
54
50
  raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no children):\n#{dc_doc.to_xml}" if dc_doc.root.children.size == 0
@@ -198,16 +194,6 @@ module Dor
198
194
  end
199
195
  end
200
196
 
201
- def metadata_namespace
202
- desc_md = datastreams['descMetadata'].ng_xml
203
- return nil if desc_md.nil? || desc_md.root.nil? || desc_md.root.namespace.nil?
204
- desc_md.root.namespace.href
205
- end
206
-
207
- def metadata_format
208
- DESC_MD_FORMATS[metadata_namespace]
209
- end
210
-
211
197
  def to_solr(solr_doc = {}, *args)
212
198
  solr_doc = super solr_doc, *args
213
199
  mods_sources = {
@@ -229,9 +215,11 @@ module Dor
229
215
  solr_doc[key] ||= [] # initialize multivalue targts if necessary
230
216
  }
231
217
 
232
- solr_doc['metadata_format_ssim'] << metadata_format
218
+ solr_doc['metadata_format_ssim'] << 'mods'
233
219
  begin
234
- dc_doc = generate_dublin_core
220
+ dc_doc = generate_dublin_core(include_collection_as_related_item: false)
221
+ # we excluding the generated collection relation here; we instead get the collection
222
+ # title from Dor::Identifiable.
235
223
  dc_doc.xpath('/oai_dc:dc/*').each do |node|
236
224
  add_solr_value(solr_doc, "public_dc_#{node.name}", node.text, :string, [:stored_searchable])
237
225
  end
@@ -267,31 +255,6 @@ module Dor
267
255
  solr_doc
268
256
  end
269
257
 
270
- def update_title(new_title)
271
- raise 'Descriptive metadata has no title to update!' unless update_simple_field('mods:mods/mods:titleInfo/mods:title', new_title)
272
- end
273
-
274
- def add_identifier(type, value)
275
- ds_xml = descMetadata.ng_xml
276
- ds_xml.search('//mods:mods', 'mods' => 'http://www.loc.gov/mods/v3').each do |node|
277
- new_node = Nokogiri::XML::Node.new('identifier', ds_xml) # this ends up being mods:identifier without having to specify the namespace
278
- new_node['type'] = type
279
- new_node.content = value
280
- node.add_child(new_node)
281
- end
282
- end
283
-
284
- def delete_identifier(type, value = nil)
285
- ds_xml = descMetadata.ng_xml
286
- ds_xml.search('//mods:identifier', 'mods' => 'http://www.loc.gov/mods/v3').each do |node|
287
- if node.content == value || value.nil?
288
- node.remove
289
- return true
290
- end
291
- end
292
- false
293
- end
294
-
295
258
  # @param [Boolean] force Overwrite existing XML
296
259
  # @return [String] descMetadata.content XML
297
260
  def set_desc_metadata_using_label(force = false)
@@ -325,15 +288,6 @@ module Dor
325
288
 
326
289
  private
327
290
 
328
- # generic updater useful for updating things like title or subtitle which can only have a single occurance and must be present
329
- def update_simple_field(field, new_val)
330
- descMetadata.ng_xml.search('//' + field, 'mods' => 'http://www.loc.gov/mods/v3').each do |node|
331
- node.content = new_val
332
- return true
333
- end
334
- false
335
- end
336
-
337
291
  # Builds case-insensitive xpath translate function call that will match the attribute to a value
338
292
  def ci_compare(attribute, value)
339
293
  "translate(
@@ -60,6 +60,7 @@ module Dor
60
60
  # @param type [Symbol] :workgroup for a group or :person for a person
61
61
  def add_roleplayer(role, entity, type = :workgroup)
62
62
  xml = roleMetadata.ng_xml
63
+ roleMetadata.ng_xml_will_change!
63
64
  group = type == :workgroup ? 'group' : 'person'
64
65
  nodes = xml.search('/roleMetadata/role[@type=\'' + role + '\']')
65
66
  if nodes.length > 0
@@ -80,7 +81,6 @@ module Dor
80
81
  id_node['type'] = type.to_s
81
82
  xml.search('/roleMetadata').first.add_child(node)
82
83
  end
83
- roleMetadata.content = xml.to_s
84
84
  end
85
85
 
86
86
  # remove all people groups and roles from the APO role metadata datastream
@@ -106,6 +106,7 @@ module Dor
106
106
  # @param val [String] pid of the collection, ex. druid:ab123cd4567
107
107
  def add_default_collection(val)
108
108
  xml = administrativeMetadata.ng_xml
109
+ administrativeMetadata.ng_xml_will_change!
109
110
  reg = xml.search('//administrativeMetadata/registration').first
110
111
  unless reg
111
112
  reg = Nokogiri::XML::Node.new('registration', xml)
@@ -114,12 +115,11 @@ module Dor
114
115
  node = Nokogiri::XML::Node.new('collection', xml)
115
116
  node['id'] = val
116
117
  reg.add_child(node)
117
- administrativeMetadata.content = xml.to_s
118
118
  end
119
119
  def remove_default_collection(val)
120
120
  xml = administrativeMetadata.ng_xml
121
+ administrativeMetadata.ng_xml_will_change!
121
122
  xml.search('//administrativeMetadata/registration/collection[@id=\'' + val + '\']').remove
122
- administrativeMetadata.content = xml.to_s
123
123
  end
124
124
 
125
125
  # Get all roles defined in the role metadata, and the people or groups in those roles. Groups are prefixed with 'workgroup:'
@@ -23,6 +23,7 @@ module Dor
23
23
  # Remove all read acces nodes
24
24
  rights_md = datastreams['rightsMetadata']
25
25
  rights_xml = rights_md.ng_xml
26
+ rights_md.ng_xml_will_change!
26
27
  rights_xml.xpath("//rightsMetadata/access[@type='read']").each { |n| n.remove }
27
28
 
28
29
  # Replace rights <access> nodes with those from embargoMetadta
@@ -36,7 +37,6 @@ module Dor
36
37
  end
37
38
  end
38
39
 
39
- rights_md.content = rights_md.ng_xml.to_s
40
40
  datastreams['events'].add_event('embargo', release_agent, 'Embargo released')
41
41
  end
42
42
 
@@ -48,6 +48,7 @@ module Dor
48
48
  # Remove all read acces nodes
49
49
  rights_md = datastreams['rightsMetadata']
50
50
  rights_xml = rights_md.ng_xml
51
+ rights_md.ng_xml_will_change!
51
52
  rights_xml.xpath("//rightsMetadata/access[@type='read']").each { |n| n.remove }
52
53
 
53
54
  # Replace rights <access> nodes with 1 machine/world node
@@ -58,7 +59,6 @@ module Dor
58
59
  rights_xml.root.add_child(world_doc.root.clone)
59
60
  end
60
61
 
61
- rights_md.content = rights_md.ng_xml.to_s
62
62
  datastreams['events'].add_event('embargo', release_agent, '20% Visibility Embargo released')
63
63
  end
64
64
 
@@ -74,13 +74,13 @@ module Dor
74
74
  node.content = new_date.beginning_of_day.utc.xmlschema
75
75
  updated = true
76
76
  end
77
- rightsMetadata.content = rightsMetadata.ng_xml.to_s
77
+ rightsMetadata.ng_xml_will_change!
78
78
  rightsMetadata.save
79
79
  raise 'No release date in rights metadata, cannot proceed!' unless updated
80
80
  embargoMetadata.ng_xml.xpath('//releaseDate').each do |node|
81
81
  node.content = new_date.beginning_of_day.utc.xmlschema
82
82
  end
83
- embargoMetadata.content = embargoMetadata.ng_xml.to_s
83
+ embargoMetadata.ng_xml_will_change!
84
84
  embargoMetadata.save
85
85
  end
86
86
  end
@@ -3,7 +3,6 @@ module Dor
3
3
  extend ActiveSupport::Concern
4
4
  include SolrDocHelper
5
5
  include Eventable
6
- include Upgradable
7
6
 
8
7
  included do
9
8
  has_metadata :name => 'DC', :type => SimpleDublinCoreDs, :label => 'Dublin Core Record for self object'
@@ -36,21 +35,6 @@ module Dor
36
35
  content_tag.size == 1 ? content_tag[0].split(':').last.strip : ''
37
36
  end
38
37
 
39
- # Syntactic sugar for identifying applied DOR Concerns
40
- # e.g., obj.is_identifiable? is the same as obj.is_a?(Dor::Identifiable)
41
- def method_missing(sym, *args)
42
- if sym.to_s =~ /^is_(.+)\?$/
43
- begin
44
- klass = Dor.const_get $1.capitalize.to_sym
45
- return self.is_a?(klass)
46
- rescue NameError
47
- return false
48
- end
49
- else
50
- super
51
- end
52
- end
53
-
54
38
  ## Module-level variables, shared between ALL mixin includers (and ALL *their* includers/extenders)!
55
39
  ## used for caching found values
56
40
  @@collection_hash = {}
@@ -74,7 +58,7 @@ module Dor
74
58
  collections = rels_doc.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection', ns_hash)
75
59
  solrize_related_obj_titles(solr_doc, apos, @@apo_hash, 'apo_title', 'nonhydrus_apo_title', 'hydrus_apo_title')
76
60
  solrize_related_obj_titles(solr_doc, collections, @@collection_hash, 'collection_title', 'nonhydrus_collection_title', 'hydrus_collection_title')
77
-
61
+ solr_doc['public_dc_relation_tesim'] ||= solr_doc['collection_title_tesim'] if solr_doc['collection_title_tesim']
78
62
  solr_doc['metadata_source_ssi'] = identity_metadata_source
79
63
  solr_doc
80
64
  end
@@ -23,7 +23,6 @@ end
23
23
  # Processable = Workflow.
24
24
  # Publishable = Transfer of metadata to discovery and access systems.
25
25
  # Shelvable = Transfer of content to digital stacks.
26
- # Upgradable = Remediation of existing objects when content standards change.
27
26
  # Geoable = Descriptive metadata for GIS in ISO 19139/19110.
28
27
 
29
28
  # Required for all DOR objects:
@@ -11,11 +11,9 @@ module Dor
11
11
 
12
12
  def build_provenanceMetadata_datastream(workflow_id, event_text)
13
13
  workflow_provenance = create_workflow_provenance(workflow_id, event_text)
14
- dsname = 'provenanceMetadata'
15
- ds = datastreams[dsname]
16
- ds.label = 'Provenance Metadata' unless datastreams.keys.include?(dsname)
14
+ ds = datastreams['provenanceMetadata']
15
+ ds.label ||= 'Provenance Metadata'
17
16
  ds.ng_xml = workflow_provenance
18
- ds.content = ds.ng_xml.to_s
19
17
  ds.save
20
18
  end
21
19
 
@@ -4,7 +4,6 @@ module Dor
4
4
  module Processable
5
5
  extend ActiveSupport::Concern
6
6
  include SolrDocHelper
7
- include Upgradable
8
7
 
9
8
  included do
10
9
  has_metadata :name => 'workflows', :type => Dor::WorkflowDs, :label => 'Workflows', :control_group => 'E'
@@ -100,7 +99,7 @@ module Dor
100
99
  end
101
100
 
102
101
  def milestones
103
- Dor::Config.workflow.client.get_milestones('dor', pid)
102
+ @milestones ||= Dor::Config.workflow.client.get_milestones('dor', pid)
104
103
  end
105
104
 
106
105
  # @return [Hash{Symbol => Object}] including :current_version, :status_code and :status_time
@@ -94,7 +94,7 @@ module Dor
94
94
  rels = public_relationships.root
95
95
  pub.add_child(rels.clone) unless rels.nil? # TODO: Should never be nil in practice; working around an ActiveFedora quirk for testing
96
96
  pub.add_child(generate_dublin_core.root.clone)
97
- pub.add_child(Nokogiri::XML(generate_public_desc_md).root.clone) if metadata_format == 'mods'
97
+ pub.add_child(Nokogiri::XML(generate_public_desc_md).root.clone)
98
98
  pub.add_child(Nokogiri(generate_release_xml).root.clone) unless release_xml.children.size == 0 # If there are no release_tags, this prevents an empty <releaseData/> from being added
99
99
  # Note we cannot base this on if an individual object has release tags or not, because the collection may cause one to be generated for an item,
100
100
  # so we need to calculate it and then look at the final result.s
@@ -115,7 +115,7 @@ module Dor
115
115
  DigitalStacksService.transfer_to_document_store(pid, datastreams[stream].to_xml, stream)
116
116
  end
117
117
  DigitalStacksService.transfer_to_document_store(pid, public_xml, 'public')
118
- DigitalStacksService.transfer_to_document_store(pid, generate_public_desc_md, 'mods') if metadata_format == 'mods'
118
+ DigitalStacksService.transfer_to_document_store(pid, generate_public_desc_md, 'mods')
119
119
  publish_notify_on_success
120
120
  else
121
121
  # Clear out the document cache for this item
@@ -10,7 +10,6 @@ module Dor
10
10
  content_ds = admin_policy_object.datastreams['defaultObjectRights']
11
11
  ds.dsLabel = 'Rights Metadata'
12
12
  ds.ng_xml = content_ds.ng_xml.clone
13
- ds.content = ds.ng_xml.to_xml
14
13
  end
15
14
 
16
15
  def world_doc
@@ -1,7 +1,7 @@
1
1
  module Dor
2
2
  module Versionable
3
3
  extend ActiveSupport::Concern
4
- include Processable # implies Upgradable
4
+ include Processable
5
5
 
6
6
  included do
7
7
  has_metadata :name => 'versionMetadata', :type => Dor::VersionMetadataDS, :label => 'Version Metadata', :autocreate => true
@@ -24,7 +24,6 @@ module Dor
24
24
 
25
25
  vmd_ds = datastreams['versionMetadata']
26
26
  vmd_ds.sync_then_increment_version sdr_version
27
- vmd_ds.content = vmd_ds.ng_xml.to_s
28
27
  vmd_ds.save unless self.new_record?
29
28
 
30
29
  k = :create_workflows_ds
@@ -48,14 +48,14 @@ module Dor
48
48
  def query(query, args = {})
49
49
  params = args.merge({ :q => query })
50
50
  params[:start] ||= 0
51
- resp = solr.find params
51
+ resp = solr.get 'select', params: params
52
52
  return resp unless block_given?
53
53
  cont = true
54
- while cont && resp.docs.length > 0
54
+ while cont && resp['response']['docs'].length > 0
55
55
  cont = yield(resp)
56
- params[:rows] ||= resp.docs.length
56
+ params[:rows] ||= resp['response']['docs'].length
57
57
  params[:start] += params[:rows]
58
- resp = solr.find params
58
+ resp = solr.get 'select', params: params
59
59
  end
60
60
  end
61
61
 
@@ -65,10 +65,10 @@ module Dor
65
65
  elsif id.is_a?(Array) # Two values: [ 'google', 'STANFORD_0123456789' ]
66
66
  id = id.join(':')
67
67
  end
68
- q = %(#{Solrizer.solr_name 'identifier', :stored_searchable}:"#{id}")
68
+ q = "{!term f=#{Solrizer.solr_name 'identifier', :symbol}}#{id}"
69
69
  result = []
70
70
  query(q, :fl => 'id', :rows => 1000) do |resp|
71
- result += resp.docs.collect { |doc| doc['id'] }
71
+ result += resp['response']['docs'].collect { |doc| doc['id'] }
72
72
  true
73
73
  end
74
74
  result
@@ -86,10 +86,10 @@ module Dor
86
86
 
87
87
  def find_sdr_graveyard_apo_druid
88
88
  r = Dor::SearchService.query('dc_title_tesim:"SDR Graveyard"', :fl => 'id')
89
- if r.docs.empty?
89
+ if r['response']['docs'].empty?
90
90
  nil
91
91
  else
92
- r.docs.first[:id]
92
+ r['response']['docs'].first[:id]
93
93
  end
94
94
  end
95
95
 
@@ -20,8 +20,7 @@ end
20
20
 
21
21
  class Nokogiri::XML::Document
22
22
 
23
- def prettify
24
- xslt = Nokogiri::XSLT <<-EOC
23
+ PRETTIFY_XSLT = Nokogiri::XSLT <<-EOC
25
24
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
26
25
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
27
26
  <xsl:template match="node()|@*">
@@ -31,7 +30,9 @@ class Nokogiri::XML::Document
31
30
  </xsl:template>
32
31
  </xsl:stylesheet>
33
32
  EOC
34
- xslt.transform(self).to_xml
33
+
34
+ def prettify
35
+ PRETTIFY_XSLT.transform(self).to_xml
35
36
  end
36
37
 
37
38
  end
@@ -1,15 +1,9 @@
1
1
  module SolrDocHelper
2
2
  def add_solr_value(solr_doc, field_name, value, field_type = :default, index_types = [:searchable])
3
- if Solrizer::VERSION > '3'
4
- case field_type
5
- when :symbol
6
- index_types << field_type
7
- end
8
- ::Solrizer.insert_field(solr_doc, field_name, value, *index_types)
9
- else
10
- index_types.each { |index_type|
11
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, ::ActiveFedora::SolrService.solr_name(field_name, field_type, index_type), value)
12
- }
3
+ case field_type
4
+ when :symbol
5
+ index_types << field_type
13
6
  end
7
+ ::Solrizer.insert_field(solr_doc, field_name, value, *index_types)
14
8
  end
15
9
  end
data/lib/dor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dor
2
- VERSION = '5.15.1'.freeze
2
+ VERSION = '5.16.0'.freeze
3
3
  end
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.15.1
4
+ version: 5.16.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-11 00:00:00.000000000 Z
17
+ date: 2016-11-15 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: active-fedora
@@ -181,19 +181,25 @@ dependencies:
181
181
  - !ruby/object:Gem::Version
182
182
  version: '3'
183
183
  - !ruby/object:Gem::Dependency
184
- name: rsolr-ext
184
+ name: rsolr
185
185
  requirement: !ruby/object:Gem::Requirement
186
186
  requirements:
187
- - - "~>"
187
+ - - ">="
188
188
  - !ruby/object:Gem::Version
189
189
  version: 1.0.3
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: '3'
190
193
  type: :runtime
191
194
  prerelease: false
192
195
  version_requirements: !ruby/object:Gem::Requirement
193
196
  requirements:
194
- - - "~>"
197
+ - - ">="
195
198
  - !ruby/object:Gem::Version
196
199
  version: 1.0.3
200
+ - - "<"
201
+ - !ruby/object:Gem::Version
202
+ version: '3'
197
203
  - !ruby/object:Gem::Dependency
198
204
  name: ruby-cache
199
205
  requirement: !ruby/object:Gem::Requirement
@@ -605,14 +611,6 @@ files:
605
611
  - lib/dor/datastreams/workflow_definition_ds.rb
606
612
  - lib/dor/datastreams/workflow_ds.rb
607
613
  - lib/dor/exceptions.rb
608
- - lib/dor/migrations/content_metadata_ds/change_content_type.rb
609
- - lib/dor/migrations/identifiable/assert_adminPolicy.rb
610
- - lib/dor/migrations/identifiable/fix_model_assertions.rb
611
- - lib/dor/migrations/identifiable/record_remediation.rb
612
- - lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb
613
- - lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb
614
- - lib/dor/migrations/processable/unify_workflows.rb
615
- - lib/dor/migrations/versionable/add_missing_version_md.rb
616
614
  - lib/dor/models/abstract.rb
617
615
  - lib/dor/models/admin_policy_object.rb
618
616
  - lib/dor/models/agreement.rb
@@ -636,7 +634,6 @@ files:
636
634
  - lib/dor/models/rightsable.rb
637
635
  - lib/dor/models/set.rb
638
636
  - lib/dor/models/shelvable.rb
639
- - lib/dor/models/upgradable.rb
640
637
  - lib/dor/models/versionable.rb
641
638
  - lib/dor/models/workflow_object.rb
642
639
  - lib/dor/services/cleanup_reset_service.rb
@@ -653,7 +650,6 @@ files:
653
650
  - lib/dor/services/search_service.rb
654
651
  - lib/dor/services/suri_service.rb
655
652
  - lib/dor/services/technical_metadata_service.rb
656
- - lib/dor/services/tei2dc.xslt
657
653
  - lib/dor/utils/ng_tidy.rb
658
654
  - lib/dor/utils/predicate_patch.rb
659
655
  - lib/dor/utils/sdr_client.rb
@@ -1,7 +0,0 @@
1
- Dor::ContentMetadataDS.on_upgrade '3.6.0', 'Change contentMetadata type attribute' do |ds|
2
- translations = { 'googleScannedBook' => 'book', 'etd' => 'file', 'eem' => 'file' }
3
- translations.any? do |old_type, new_type|
4
- current_type = ds.contentType.to_ary.first rescue ds.contentType
5
- (current_type == old_type) && (ds.contentType = new_type)
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- Dor::Identifiable.on_upgrade '3.5.0', 'Assert hydra:isGovernedBy' do |obj|
2
- # Assign hydra:isGovernedBy based on identityMetadata/adminPolicy
3
- if obj.admin_policy_object.nil?
4
- apo_id = obj.identityMetadata.adminPolicy.first
5
- apo_id.present? && obj.admin_policy_object = Dor.find(apo_id) unless apo_id.nil?
6
- else
7
- false
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- Dor::Identifiable.on_upgrade '3.6.1', 'Assert correct models' do |obj|
2
- applied = false
3
- if obj.relationships.any? { |r| r.predicate.to_s == 'info:fedora/fedora-system:def/model#hasModel' && r.object.to_s == 'info:fedora/hydra:commonMetadata' }
4
- obj.remove_relationship :has_model, 'info:fedora/hydra:commonMetadata'
5
- applied = true
6
- end
7
-
8
- unless obj.relationships.predicates.any? { |p| p.to_s == 'info:fedora/fedora-system:def/model#hasModel' }
9
- obj.assert_content_model
10
- applied = true
11
- end
12
- applied
13
- end
@@ -1,18 +0,0 @@
1
- Dor::Identifiable.on_upgrade '3.6.1', 'Record Remediation Version' do |obj|
2
- version_tag = obj.identityMetadata.find_by_terms(:tag).find { |e| e.text =~ /Remediated By\s*:\s*(.+)/ }
3
- add_tag = false
4
- if version_tag
5
- current_version = Gem::Version.new($1)
6
- if current_version < Gem::Version.new(Dor::VERSION)
7
- version_tag.remove
8
- add_tag = true
9
- end
10
- else
11
- add_tag = true
12
- end
13
-
14
- if add_tag
15
- obj.identityMetadata.add_value :tag, "Remediated By : #{Dor::VERSION}"
16
- end
17
- add_tag
18
- end
@@ -1,18 +0,0 @@
1
- Dor::Identifiable.on_upgrade '3.14.8', 'Fix up invalid URIs in content-augmented datastreams' do |obj|
2
- bad_content_location_uri = begin
3
- URI.parse(obj.send('content-augmented').dsLocation)
4
- false
5
- rescue URI::InvalidURIError
6
- true
7
- rescue
8
- false
9
- end
10
-
11
- next unless bad_content_location_uri
12
-
13
- parts = obj.send('content-augmented').dsLocation.split('/')
14
- parts[parts.length - 1] = URI.escape(parts.last)
15
- obj.send('content-augmented').dsLocation = parts.join('/')
16
-
17
- obj.send('content-augmented').save
18
- end
@@ -1,18 +0,0 @@
1
- Dor::Identifiable.on_upgrade '3.11.6', 'Fix up invalid URIs in objects' do |obj|
2
- bad_content_location_uri = begin
3
- URI.parse(obj.content.dsLocation)
4
- false
5
- rescue URI::InvalidURIError
6
- true
7
- rescue
8
- false
9
- end
10
-
11
- next unless bad_content_location_uri
12
-
13
- parts = obj.content.dsLocation.split('/')
14
- parts[parts.length - 1] = URI.escape(parts.last)
15
- obj.content.dsLocation = parts.join('/')
16
-
17
- obj.content.save
18
- end
@@ -1,17 +0,0 @@
1
- Dor::Processable.on_upgrade '3.5.0', 'Replace individual *WF datastreams with unified workflows datastream' do |obj|
2
- run = false
3
- # Touch workflows datastream to ensure it gets saved
4
- if obj.workflows.new?
5
- obj.workflows.content
6
- run = true
7
- end
8
-
9
- # Remove individual *WF datastreams
10
- obj.datastreams.each_pair do |dsid, ds|
11
- if ds.controlGroup == 'E' && dsid =~ /WF$/
12
- ds.delete
13
- run = true
14
- end
15
- end
16
- run
17
- end
@@ -1,9 +0,0 @@
1
- Dor::Versionable.on_upgrade '3.12.2', 'Add missing versionMetadata' do |obj|
2
- run = false
3
- vm = obj.datastreams['versionMetadata']
4
- if vm.content.nil? || vm.content.strip == '' || vm.new? # We do not have a versionMetadata ds
5
- vm.content = vm.ng_xml.to_s
6
- run = true
7
- end
8
- run
9
- end
@@ -1,73 +0,0 @@
1
- module Dor
2
- module Upgradable
3
- # The Upgradable mixin is responsible for making sure all DOR objects,
4
- # concerns, and datastreams know how to upgrade themselves to the latest
5
- # Chimera/DOR content standards.
6
- #
7
- # To add a new upgrade:
8
- # 1) include Dor::Upgradable within whatever model, datastream, or mixin
9
- # you want to make upgradable.
10
- # 2) Add a block to the model, datastream, or mixin as follows:
11
- #
12
- # on_upgrade(v) do |obj|
13
- # # Do whatever needs to be done to obj
14
- # end
15
- #
16
- # where v is the first released version of dor-services that will
17
- # include the upgrade.
18
- #
19
- # The block can either be defined on the model itself, or in a file
20
- # in the dor/migrations/[model] directory. See Dor::Identifiable and
21
- # dor/migrations/identifiable/* for an example.
22
-
23
- Callback = Struct.new :module, :version, :description, :block
24
-
25
- mattr_accessor :__upgrade_callbacks
26
- @@__upgrade_callbacks = []
27
- def self.add_upgrade_callback(c, v, d, &b)
28
- @@__upgrade_callbacks << Callback.new(c, Gem::Version.new(v), d, b)
29
- end
30
-
31
- def self.run_upgrade_callbacks(obj, event_handler)
32
- relevant = @@__upgrade_callbacks.select { |c| obj.is_a?(c.module) }.sort_by(&:version)
33
- results = relevant.collect do |c|
34
- result = c.block.call(obj)
35
- if result && event_handler.respond_to?(:add_event)
36
- event_handler.add_event 'remediation', "#{c.module.name} #{c.version}", c.description
37
- end
38
- if result
39
- Dor.logger.info "Applied remediation '#{c.description}' to '#{obj.pid}'"
40
- end
41
- result
42
- end
43
- results.any?
44
- end
45
-
46
- def self.included(base)
47
- base.instance_eval do
48
- def self.on_upgrade(version, desc, &block)
49
- Dor::Upgradable.add_upgrade_callback self, version, desc, &block
50
- end
51
-
52
- Dir[File.join(Dor.root, 'dor', 'migrations', base.name.split(/::/).last.underscore, '*.rb')].each do |migration|
53
- require migration
54
- end
55
- end
56
- end
57
-
58
- def upgrade!
59
- results = [Dor::Upgradable.run_upgrade_callbacks(self, self)]
60
- if self.respond_to?(:datastreams)
61
- datastreams.each_pair do |dsid, ds|
62
- results << Dor::Upgradable.run_upgrade_callbacks(ds, self) unless ds.new?
63
- end
64
- end
65
-
66
- if results.any?
67
- save
68
- else
69
- false
70
- end
71
- end
72
- end
73
- end
@@ -1,102 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
- xmlns:tei="http://www.tei-c.org/ns/1.0"
4
- xmlns:dc="http://purl.org/dc/elements/1.1/"
5
- xmlns:dcterms="http://purl.org/dc/terms/"
6
- xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
7
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8
- exclude-result-prefixes="tei xsl"
9
- version="1.0">
10
-
11
- <xsl:output xml:space="default" indent="yes"/>
12
-
13
- <xsl:template match="/">
14
- <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
15
- <xsl:apply-templates/>
16
- </oai_dc:dc>
17
- </xsl:template>
18
-
19
- <xsl:template match="tei:teiHeader">
20
- <xsl:apply-templates/>
21
- </xsl:template>
22
-
23
- <xsl:template match="tei:fileDesc/tei:titleStmt/tei:title">
24
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:title</xsl:with-param></xsl:call-template>
25
- </xsl:template>
26
-
27
- <xsl:template match="tei:fileDesc/tei:titleStmt/tei:author">
28
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:creator</xsl:with-param></xsl:call-template>
29
- </xsl:template>
30
-
31
- <xsl:template match="tei:profileDesc/tei:textClass/tei:keywords/tei:list/tei:item">
32
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:subject</xsl:with-param></xsl:call-template>
33
- </xsl:template>
34
-
35
- <xsl:template match="tei:encodingDesc/tei:refsDecl|tei:encodingDesc/tei:projectDesc|tei:encodingDesc/tei:editorialDesc">
36
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:description</xsl:with-param></xsl:call-template>
37
- </xsl:template>
38
-
39
- <xsl:template match="tei:fileDesc/tei:publicationStmt/tei:publisher/tei:publisher|tei:fileDesc/tei:publicationStmt/tei:publisher/tei:pubPlace">
40
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:publisher</xsl:with-param></xsl:call-template>
41
- </xsl:template>
42
-
43
- <xsl:template match="tei:fileDesc/tei:titleStmt/tei:editor|tei:fileDesc/tei:titleStmt/tei:funder|tei:fileDesc/tei:titleStmt/tei:sponsor|tei:fileDesc/tei:titleStmt/tei:principle">
44
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:contributor</xsl:with-param></xsl:call-template>
45
- </xsl:template>
46
-
47
- <xsl:template match="tei:fileDesc/tei:publicationStmt/tei:date">
48
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:date</xsl:with-param></xsl:call-template>
49
- </xsl:template>
50
-
51
- <xsl:template match="tei:extent/tei:seg[@type='size']">
52
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dcterms:extent</xsl:with-param></xsl:call-template>
53
- </xsl:template>
54
-
55
- <xsl:template match="tei:fileDesc/tei:publicationStmt/tei:idno[@type='ARK']">
56
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:identifier</xsl:with-param></xsl:call-template>
57
- </xsl:template>
58
-
59
- <xsl:template match="tei:sourceDesc/tei:bibful/tei:publicationStmt/tei:publisher|tei:sourceDesc/tei:bibful/tei:publicationStmt/tei:pubPlace|tei:sourceDesc/tei:bibful/tei:publicationStmt/tei:date|tei:sourceDesc/tei:bibl">
60
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:source</xsl:with-param></xsl:call-template>
61
- </xsl:template>
62
-
63
- <xsl:template match="tei:profileDesc/tei:langUsage/tei:language">
64
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:language</xsl:with-param></xsl:call-template>
65
- </xsl:template>
66
-
67
- <xsl:template match="tei:fileDesc/tei:seriesStmt/tei:title">
68
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dc:relation</xsl:with-param></xsl:call-template>
69
- </xsl:template>
70
-
71
- <xsl:template match="tei:fileDesc/tei:publicationStmt/tei:availability">
72
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dcterms:accessRights</xsl:with-param></xsl:call-template>
73
- </xsl:template>
74
-
75
- <xsl:template match="tei:notesStmt/tei:note[@type='summary']">
76
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dcterms:abstract</xsl:with-param></xsl:call-template>
77
- </xsl:template>
78
-
79
- <!--
80
- <xsl:template match="tei:notesStmt/tei:note[not(@type)]">
81
- <xsl:call-template name="ptext"><xsl:with-param name="element-name">dcterms:note</xsl:with-param></xsl:call-template>
82
- </xsl:template>
83
- -->
84
-
85
- <xsl:template name="ptext">
86
- <xsl:param name="element-name"/>
87
- <xsl:variable name="text">
88
- <xsl:for-each select=".|./tei:p">
89
- <xsl:variable name="t" select="normalize-space(./text())"/>
90
- <xsl:if test="string-length($t) &gt; 0">
91
- <xsl:value-of select="$t"/>
92
- </xsl:if>
93
- </xsl:for-each>
94
- </xsl:variable>
95
- <xsl:if test="string-length($text) &gt; 0">
96
- <xsl:element name="{$element-name}"><xsl:value-of select="$text"/></xsl:element>
97
- </xsl:if>
98
- </xsl:template>
99
-
100
- <xsl:template match="text()|@*"/>
101
-
102
- </xsl:stylesheet>