dor-services 4.22.3 → 4.22.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +8 -8
  2. data/bin/dor-indexer +19 -20
  3. data/bin/dor-indexerd +2 -3
  4. data/config/certs/robots-dor-dev.crt +29 -0
  5. data/config/certs/robots-dor-dev.key +27 -0
  6. data/config/dev_console_env.rb +77 -0
  7. data/lib/dor-services.rb +3 -3
  8. data/lib/dor/config.rb +15 -15
  9. data/lib/dor/datastreams/administrative_metadata_ds.rb +5 -5
  10. data/lib/dor/datastreams/content_metadata_ds.rb +181 -225
  11. data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
  12. data/lib/dor/datastreams/default_object_rights_ds.rb +8 -10
  13. data/lib/dor/datastreams/desc_metadata_ds.rb +35 -34
  14. data/lib/dor/datastreams/embargo_metadata_ds.rb +7 -7
  15. data/lib/dor/datastreams/events_ds.rb +11 -11
  16. data/lib/dor/datastreams/geo_metadata_ds.rb +86 -86
  17. data/lib/dor/datastreams/identity_metadata_ds.rb +19 -19
  18. data/lib/dor/datastreams/role_metadata_ds.rb +3 -3
  19. data/lib/dor/datastreams/simple_dublin_core_ds.rb +13 -13
  20. data/lib/dor/datastreams/version_metadata_ds.rb +5 -5
  21. data/lib/dor/datastreams/workflow_definition_ds.rb +21 -21
  22. data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +1 -1
  23. data/lib/dor/migrations/identifiable/fix_model_assertions.rb +1 -1
  24. data/lib/dor/migrations/identifiable/record_remediation.rb +2 -2
  25. data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +1 -1
  26. data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +1 -1
  27. data/lib/dor/migrations/processable/unify_workflows.rb +4 -4
  28. data/lib/dor/migrations/versionable/add_missing_version_md.rb +1 -1
  29. data/lib/dor/models/admin_policy_object.rb +1 -1
  30. data/lib/dor/models/assembleable.rb +5 -5
  31. data/lib/dor/models/contentable.rb +27 -27
  32. data/lib/dor/models/describable.rb +168 -179
  33. data/lib/dor/models/discoverable.rb +13 -13
  34. data/lib/dor/models/editable.rb +55 -55
  35. data/lib/dor/models/embargoable.rb +26 -26
  36. data/lib/dor/models/eventable.rb +3 -3
  37. data/lib/dor/models/geoable.rb +8 -8
  38. data/lib/dor/models/governable.rb +14 -14
  39. data/lib/dor/models/identifiable.rb +117 -143
  40. data/lib/dor/models/item.rb +2 -2
  41. data/lib/dor/models/itemizable.rb +9 -9
  42. data/lib/dor/models/presentable.rb +8 -8
  43. data/lib/dor/models/preservable.rb +4 -4
  44. data/lib/dor/models/processable.rb +22 -23
  45. data/lib/dor/models/releaseable.rb +26 -26
  46. data/lib/dor/models/shelvable.rb +14 -14
  47. data/lib/dor/models/upgradable.rb +13 -13
  48. data/lib/dor/models/versionable.rb +2 -2
  49. data/lib/dor/models/workflow_object.rb +4 -4
  50. data/lib/dor/services/cleanup_reset_service.rb +27 -27
  51. data/lib/dor/services/cleanup_service.rb +4 -7
  52. data/lib/dor/services/digital_stacks_service.rb +10 -10
  53. data/lib/dor/services/merge_service.rb +1 -1
  54. data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +2 -2
  55. data/lib/dor/services/metadata_service.rb +20 -20
  56. data/lib/dor/services/registration_service.rb +27 -27
  57. data/lib/dor/services/reset_workspace_service.rb +15 -15
  58. data/lib/dor/services/sdr_ingest_service.rb +6 -6
  59. data/lib/dor/services/search_service.rb +2 -2
  60. data/lib/dor/services/suri_service.rb +5 -5
  61. data/lib/dor/services/technical_metadata_service.rb +2 -3
  62. data/lib/dor/utils/ng_tidy.rb +9 -9
  63. data/lib/dor/utils/predicate_patch.rb +1 -1
  64. data/lib/dor/utils/solr_doc_helper.rb +2 -2
  65. data/lib/dor/version.rb +1 -1
  66. data/lib/dor/workflow/document.rb +19 -19
  67. data/lib/dor/workflow/graph.rb +36 -36
  68. data/lib/dor/workflow/process.rb +12 -12
  69. data/lib/tasks/dor.rake +1 -1
  70. data/lib/tasks/rdoc.rake +3 -3
  71. metadata +6 -3
@@ -1,67 +1,63 @@
1
1
  module Dor
2
- module Describable
3
- extend ActiveSupport::Concern
2
+ module Describable
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
- }
9
- class CrosswalkError < Exception; end
5
+ DESC_MD_FORMATS = {
6
+ 'http://www.tei-c.org/ns/1.0' => 'tei',
7
+ 'http://www.loc.gov/mods/v3' => 'mods'
8
+ }
9
+ class CrosswalkError < Exception; end
10
10
 
11
- included do
12
- has_metadata :name => "descMetadata", :type => Dor::DescMetadataDS, :label => 'Descriptive Metadata', :control_group => 'M'
13
- end
11
+ included do
12
+ has_metadata :name => 'descMetadata', :type => Dor::DescMetadataDS, :label => 'Descriptive Metadata', :control_group => 'M'
13
+ end
14
14
 
15
- def fetch_descMetadata_datastream
16
- candidates = self.datastreams['identityMetadata'].otherId.collect { |oid| oid.to_s }
17
- metadata_id = Dor::MetadataService.resolvable(candidates).first
18
- unless metadata_id.nil?
19
- return Dor::MetadataService.fetch(metadata_id.to_s)
20
- else
21
- return nil
22
- end
23
- end
15
+ def fetch_descMetadata_datastream
16
+ candidates = datastreams['identityMetadata'].otherId.collect { |oid| oid.to_s }
17
+ metadata_id = Dor::MetadataService.resolvable(candidates).first
18
+ return nil if metadata_id.nil?
19
+ Dor::MetadataService.fetch(metadata_id.to_s)
20
+ end
24
21
 
25
- def build_descMetadata_datastream(ds)
26
- content = fetch_descMetadata_datastream
27
- unless content.nil?
28
- ds.dsLabel = 'Descriptive Metadata'
29
- ds.ng_xml = Nokogiri::XML(content)
30
- ds.ng_xml.normalize_text!
31
- ds.content = ds.ng_xml.to_xml
32
- end
33
- end
22
+ def build_descMetadata_datastream(ds)
23
+ content = fetch_descMetadata_datastream
24
+ unless content.nil?
25
+ ds.dsLabel = 'Descriptive Metadata'
26
+ ds.ng_xml = Nokogiri::XML(content)
27
+ ds.ng_xml.normalize_text!
28
+ ds.content = ds.ng_xml.to_xml
29
+ end
30
+ end
34
31
 
35
- # Generates Dublin Core from the MODS in the descMetadata datastream using the LoC mods2dc stylesheet
36
- # Should not be used for the Fedora DC datastream
37
- # @raise [Exception] Raises an Exception if the generated DC is empty or has no children
38
- def generate_dublin_core
39
- format = self.metadata_format
40
- if format.nil?
41
- raise CrosswalkError, "Unknown descMetadata namespace: #{metadata_namespace.inspect}"
42
- end
43
- xslt = Nokogiri::XSLT(File.new(File.expand_path(File.dirname(__FILE__) + "/#{format}2dc.xslt")) )
44
- desc_md = self.descMetadata.ng_xml.dup(1)
45
- self.add_collection_reference(desc_md)
46
- dc_doc = xslt.transform(desc_md)
47
- # Remove empty nodes
48
- dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]').remove
49
- if(dc_doc.root.nil? || dc_doc.root.children.size == 0)
50
- raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml:\n#{dc_doc.to_xml}"
51
- end
52
- dc_doc
53
- end
32
+ # Generates Dublin Core from the MODS in the descMetadata datastream using the LoC mods2dc stylesheet
33
+ # Should NOT be used for the Fedora DC datastream
34
+ # @raise [Exception] Raises an Exception if the generated DC is empty or has no children
35
+ def generate_dublin_core
36
+ format = metadata_format
37
+ if format.nil?
38
+ raise CrosswalkError, "Unknown descMetadata namespace: #{metadata_namespace.inspect}"
39
+ end
40
+ xslt = Nokogiri::XSLT(File.new(File.expand_path(File.dirname(__FILE__) + "/#{format}2dc.xslt")) )
41
+ desc_md = descMetadata.ng_xml.dup(1)
42
+ add_collection_reference(desc_md)
43
+ dc_doc = xslt.transform(desc_md)
44
+ # Remove empty nodes
45
+ dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]').remove
46
+ if dc_doc.root.nil? || dc_doc.root.children.size == 0
47
+ raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml:\n#{dc_doc.to_xml}"
48
+ end
49
+ dc_doc
50
+ end
54
51
 
55
52
  def generate_public_desc_md
56
- doc = self.descMetadata.ng_xml.dup(1)
53
+ doc = descMetadata.ng_xml.dup(1)
57
54
  add_collection_reference(doc)
58
55
  add_access_conditions(doc)
59
56
  doc.xpath('//comment()').remove
60
-
61
57
  new_doc = Nokogiri::XML(doc.to_xml) { |x| x.noblanks }
62
58
  new_doc.encoding = 'UTF-8'
63
59
  new_doc.to_xml
64
- end
60
+ end
65
61
 
66
62
  # Create MODS accessCondition statements from rightsMetadata
67
63
  # @param [Nokogiri::XML::Document] doc Document representing the descriptiveMetadata of the object
@@ -69,69 +65,67 @@ module Dor
69
65
  def add_access_conditions(doc)
70
66
  # clear out any existing accessConditions
71
67
  doc.xpath('//mods:accessCondition', 'mods' => 'http://www.loc.gov/mods/v3').each {|n| n.remove}
72
- rights = self.datastreams['rightsMetadata'].ng_xml
68
+ rights = datastreams['rightsMetadata'].ng_xml
73
69
 
74
70
  rights.xpath('//use/human[@type="useAndReproduction"]').each do |use|
75
71
  txt = use.text.strip
76
72
  next if txt.empty?
77
- new_use = doc.create_element("accessCondition", use.text.strip, :type => 'useAndReproduction')
73
+ new_use = doc.create_element('accessCondition', use.text.strip, :type => 'useAndReproduction')
78
74
  doc.root.element_children.last.add_next_sibling new_use
79
75
  end
80
76
  rights.xpath('//copyright/human[@type="copyright"]').each do |cr|
81
77
  txt = cr.text.strip
82
78
  next if txt.empty?
83
- new_use = doc.create_element("accessCondition", cr.text.strip, :type => 'copyright')
79
+ new_use = doc.create_element('accessCondition', txt, :type => 'copyright')
84
80
  doc.root.element_children.last.add_next_sibling new_use
85
81
  end
86
82
  rights.xpath("//use/machine[#{ci_compare('type', 'creativecommons')}]").each do |lic_type|
87
83
  next if lic_type.text =~ /none/i
88
84
  lic_text = rights.at_xpath("//use/human[#{ci_compare('type', 'creativecommons')}]").text.strip
89
85
  next if lic_text.empty?
90
- new_text = "CC #{lic_type.text}: #{lic_text}"
91
- new_lic = doc.create_element("accessCondition", new_text, :type => 'license')
86
+ new_lic = doc.create_element('accessCondition', "CC #{lic_type.text}: #{lic_text}", :type => 'license')
92
87
  doc.root.element_children.last.add_next_sibling new_lic
93
88
  end
94
89
  rights.xpath("//use/machine[#{ci_compare('type', 'opendatacommons')}]").each do |lic_type|
95
90
  next if lic_type.text =~ /none/i
96
91
  lic_text = rights.at_xpath("//use/human[#{ci_compare('type', 'opendatacommons')}]").text.strip
97
92
  next if lic_text.empty?
98
- new_text = "ODC #{lic_type.text}: #{lic_text}"
99
- new_lic = doc.create_element("accessCondition", new_text, :type => 'license')
93
+ new_lic = doc.create_element('accessCondition', "ODC #{lic_type.text}: #{lic_text}", :type => 'license')
100
94
  doc.root.element_children.last.add_next_sibling new_lic
101
95
  end
102
- end
96
+ end
103
97
 
104
98
  # returns the desc metadata a relatedItem with information about the collection this object belongs to for use in published mods and mods to DC conversion
105
99
  # @param [Nokogiri::XML::Document] doc A copy of the descriptiveMetadata of the object
106
100
  # @note this method modifies the passed in doc
107
101
  def add_collection_reference(doc)
108
- return unless self.methods.include? :public_relationships
109
- collections=self.public_relationships.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection',
110
- 'fedora' => 'info:fedora/fedora-system:def/relations-external#',
111
- 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' )
112
- return if collections.empty?
102
+ return unless methods.include? :public_relationships
103
+ collections = public_relationships.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection',
104
+ 'fedora' => 'info:fedora/fedora-system:def/relations-external#',
105
+ 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' )
106
+ return if collections.empty?
113
107
 
114
- # Remove any existing collections in the descMetadata
108
+ # Remove any existing collections in the descMetadata
115
109
  doc.search('/mods:mods/mods:relatedItem[@type="host"]/mods:typeOfResource[@collection=\'yes\']', 'mods' => 'http://www.loc.gov/mods/v3').each do |node|
116
110
  node.parent.remove
117
111
  end
118
112
 
119
113
  collections.each do |collection_node|
120
- druid=collection_node['rdf:resource']
121
- druid=druid.gsub('info:fedora/','')
122
- collection_obj=Dor::Item.find(druid)
114
+ druid = collection_node['rdf:resource']
115
+ druid = druid.gsub('info:fedora/','')
116
+ collection_obj = Dor::Item.find(druid)
123
117
  collection_title = Dor::Describable.get_collection_title(collection_obj)
124
- related_item_node=Nokogiri::XML::Node.new('relatedItem',doc)
125
- related_item_node['type']='host'
126
- title_info_node=Nokogiri::XML::Node.new('titleInfo',doc)
127
- title_node=Nokogiri::XML::Node.new('title',doc)
128
- title_node.content=collection_title
118
+ related_item_node = Nokogiri::XML::Node.new('relatedItem', doc)
119
+ related_item_node['type'] = 'host'
120
+ title_info_node = Nokogiri::XML::Node.new('titleInfo', doc)
121
+ title_node = Nokogiri::XML::Node.new('title', doc)
122
+ title_node.content = collection_title
129
123
 
130
- id_node=Nokogiri::XML::Node.new('identifier',doc)
124
+ id_node = Nokogiri::XML::Node.new('identifier', doc)
131
125
  id_node['type'] = 'uri'
132
126
  id_node.content = "http://#{Dor::Config.stacks.document_cache_host}/#{druid.split(':').last}"
133
127
 
134
- type_node=Nokogiri::XML::Node.new('typeOfResource',doc)
128
+ type_node = Nokogiri::XML::Node.new('typeOfResource', doc)
135
129
  type_node['collection'] = 'yes'
136
130
  doc.root.add_child(related_item_node)
137
131
  related_item_node.add_child(title_info_node)
@@ -140,118 +134,113 @@ module Dor
140
134
  related_item_node.add_child(type_node)
141
135
  end
142
136
  end
143
- def metadata_namespace
144
- desc_md = self.datastreams['descMetadata'].ng_xml
145
- if desc_md.nil? or desc_md.root.nil? or desc_md.root.namespace.nil?
146
- return nil
147
- else
148
- return desc_md.root.namespace.href
149
- end
150
- end
137
+ def metadata_namespace
138
+ desc_md = datastreams['descMetadata'].ng_xml
139
+ return nil if desc_md.nil? || desc_md.root.nil? || desc_md.root.namespace.nil?
140
+ desc_md.root.namespace.href
141
+ end
151
142
 
152
- def metadata_format
153
- DESC_MD_FORMATS[metadata_namespace]
154
- end
143
+ def metadata_format
144
+ DESC_MD_FORMATS[metadata_namespace]
145
+ end
146
+
147
+ def to_solr(solr_doc = {}, *args)
148
+ super solr_doc, *args
149
+ add_solr_value(solr_doc, 'metadata_format', metadata_format, :string, [:searchable, :facetable])
150
+ begin
151
+ dc_doc = generate_dublin_core
152
+ dc_doc.xpath('/oai_dc:dc/*').each do |node|
153
+ add_solr_value(solr_doc, "public_dc_#{node.name}", node.text, :string, [:searchable])
154
+ end
155
+ creator = ''
156
+ dc_doc.xpath('//dc:creator').each do |node|
157
+ creator = node.text
158
+ end
159
+ title = ''
160
+ dc_doc.xpath('//dc:title').each do |node|
161
+ title = node.text
162
+ end
163
+ creator_title = creator+title
164
+ add_solr_value(solr_doc, 'creator_title', creator_title, :string, [:sortable])
165
+ rescue CrosswalkError => e
166
+ ActiveFedora.logger.warn "Cannot index #{pid}.descMetadata: #{e.message}"
167
+ end
168
+ solr_doc
169
+ end
155
170
 
156
- def to_solr(solr_doc=Hash.new, *args)
157
- super solr_doc, *args
158
- add_solr_value(solr_doc, "metadata_format", self.metadata_format, :string, [:searchable, :facetable])
159
- begin
160
- dc_doc = self.generate_dublin_core
161
- dc_doc.xpath('/oai_dc:dc/*').each do |node|
162
- add_solr_value(solr_doc, "public_dc_#{node.name}", node.text, :string, [:searchable])
163
- end
164
- creator=''
165
- dc_doc.xpath('//dc:creator').each do |node|
166
- creator=node.text
167
- end
168
- title=''
169
- dc_doc.xpath('//dc:title').each do |node|
170
- title=node.text
171
- end
172
- creator_title=creator+title
173
- add_solr_value(solr_doc, 'creator_title', creator_title , :string, [:sortable])
174
- rescue CrosswalkError => e
175
- ActiveFedora.logger.warn "Cannot index #{self.pid}.descMetadata: #{e.message}"
176
- end
177
- solr_doc
178
- end
179
- def update_title(new_title)
180
- if not update_simple_field('mods:mods/mods:titleInfo/mods:title',new_title)
181
- raise 'Descriptive metadata has no title to update!'
182
- end
183
- end
184
- def add_identifier(type, value)
185
- ds_xml=self.descMetadata.ng_xml
186
- ds_xml.search('//mods:mods','mods' => 'http://www.loc.gov/mods/v3').each do |node|
187
- new_node=Nokogiri::XML::Node.new('identifier',ds_xml) #this ends up being mods:identifier without having to specify the namespace
188
- new_node['type']=type
189
- new_node.content=value
190
- node.add_child(new_node)
191
- end
192
- end
193
- def delete_identifier(type,value=nil)
171
+ def update_title(new_title)
172
+ unless update_simple_field('mods:mods/mods:titleInfo/mods:title', new_title)
173
+ raise 'Descriptive metadata has no title to update!'
174
+ end
175
+ end
194
176
 
195
- ds_xml=self.descMetadata.ng_xml
196
- ds_xml.search('//mods:identifier','mods' => 'http://www.loc.gov/mods/v3').each do |node|
197
- if node.content == value or value==nil
198
- node.remove
199
- return true
200
- end
201
- end
202
- return false
203
- end
177
+ def add_identifier(type, value)
178
+ ds_xml = descMetadata.ng_xml
179
+ ds_xml.search('//mods:mods','mods' => 'http://www.loc.gov/mods/v3').each do |node|
180
+ new_node = Nokogiri::XML::Node.new('identifier', ds_xml) # this ends up being mods:identifier without having to specify the namespace
181
+ new_node['type'] = type
182
+ new_node.content = value
183
+ node.add_child(new_node)
184
+ end
185
+ end
204
186
 
205
- def set_desc_metadata_using_label(force=false)
206
- ds=self.descMetadata
207
- unless force or ds.new?#22 is the length of <?xml version="1.0"?>
208
- raise 'Cannot proceed, there is already content in the descriptive metadata datastream.'+ds.content.to_s
209
- end
210
- label=self.label
211
- builder = Nokogiri::XML::Builder.new { |xml|
212
- xml.mods( 'xmlns' => 'http://www.loc.gov/mods/v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',:version => '3.3', "xsi:schemaLocation" => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd'){
213
- xml.titleInfo{
214
- xml.title label
215
- }
216
- }
217
- }
218
- self.descMetadata.content=builder.to_xml
219
- end
187
+ def delete_identifier(type, value = nil)
188
+ descMetadata.ng_xml.search('//mods:identifier','mods' => 'http://www.loc.gov/mods/v3').each do |node|
189
+ if node.content == value || value.nil?
190
+ node.remove
191
+ return true
192
+ end
193
+ end
194
+ false
195
+ end
220
196
 
221
- def self.get_collection_title(obj)
222
- xml=obj.descMetadata.ng_xml
223
- title=''
224
- title_node = xml.at_xpath('//mods:mods/mods:titleInfo/mods:title','mods' => 'http://www.loc.gov/mods/v3')
225
- if(title_node)
226
- title = title_node.content
227
- subtitle=xml.at_xpath('//mods:mods/mods:titleInfo/mods:subTitle','mods' => 'http://www.loc.gov/mods/v3')
228
- if(subtitle)
229
- title += ' (' + subtitle.content + ')'
230
- end
231
- end
232
- title
233
- end
197
+ def set_desc_metadata_using_label(force = false)
198
+ ds = descMetadata
199
+ unless force || ds.new?
200
+ raise 'Cannot proceed, there is already content in the descriptive metadata datastream.' + ds.content.to_s
201
+ end
202
+ label = self.label
203
+ builder = Nokogiri::XML::Builder.new { |xml|
204
+ xml.mods( 'xmlns' => 'http://www.loc.gov/mods/v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', :version => '3.3', "xsi:schemaLocation" => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd'){
205
+ xml.titleInfo{
206
+ xml.title label
207
+ }
208
+ }
209
+ }
210
+ descMetadata.content=builder.to_xml
211
+ end
234
212
 
235
- private
236
- #generic updater useful for updating things like title or subtitle which can only have a single occurance and must be present
237
- def update_simple_field(field,new_val)
238
- ds_xml=self.descMetadata.ng_xml
239
- ds_xml.search('//'+field,'mods' => 'http://www.loc.gov/mods/v3').each do |node|
240
- node.content=new_val
241
- return true
242
- end
243
- return false
244
- end
213
+ def self.get_collection_title(obj)
214
+ xml = obj.descMetadata.ng_xml
215
+ title = ''
216
+ title_node = xml.at_xpath('//mods:mods/mods:titleInfo/mods:title','mods' => 'http://www.loc.gov/mods/v3')
217
+ if title_node
218
+ title = title_node.content
219
+ subtitle = xml.at_xpath('//mods:mods/mods:titleInfo/mods:subTitle','mods' => 'http://www.loc.gov/mods/v3')
220
+ title += ' (' + subtitle.content + ')' if subtitle
221
+ end
222
+ title
223
+ end
245
224
 
246
- # Builds case-insensitive xpath translate function call that will match the attribute to a value
247
- def ci_compare(attribute, value)
248
- "translate(
249
- @#{attribute},
250
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
251
- 'abcdefghijklmnopqrstuvwxyz'
252
- ) = '#{value}' "
253
- end
225
+ private
226
+ #generic updater useful for updating things like title or subtitle which can only have a single occurance and must be present
227
+ def update_simple_field(field,new_val)
228
+ ds_xml = descMetadata.ng_xml
229
+ ds_xml.search('//'+field,'mods' => 'http://www.loc.gov/mods/v3').each do |node|
230
+ node.content = new_val
231
+ return true
232
+ end
233
+ false
234
+ end
254
235
 
236
+ # Builds case-insensitive xpath translate function call that will match the attribute to a value
237
+ def ci_compare(attribute, value)
238
+ "translate(
239
+ @#{attribute},
240
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
241
+ 'abcdefghijklmnopqrstuvwxyz'
242
+ ) = '#{value}' "
243
+ end
255
244
 
256
- end
245
+ end
257
246
  end
@@ -3,13 +3,13 @@ module Dor
3
3
  extend ActiveSupport::Concern
4
4
  #index gryphondor fields
5
5
  require 'stanford-mods'
6
- def to_solr(solr_doc=Hash.new, *args)
7
- super solr_doc, *args
8
-
9
- if self.descMetadata and not self.descMetadata.new?
6
+ def to_solr(solr_doc = Hash.new, *args)
7
+ super solr_doc, *args
8
+
9
+ if descMetadata && !descMetadata.new?
10
10
  stanford_mods_record=Stanford::Mods::Record.new
11
- stanford_mods_record.from_str(self.descMetadata.ng_xml.to_s)
12
- doc_hash = {
11
+ stanford_mods_record.from_str(descMetadata.ng_xml.to_s)
12
+ doc_hash = {
13
13
  :sw_format_facet => stanford_mods_record.format,
14
14
  # title fields
15
15
  :sw_title_245a_search_facet_facet => stanford_mods_record.sw_short_title,
@@ -19,7 +19,7 @@ module Dor
19
19
  :sw_title_245a_display_facet => stanford_mods_record.sw_short_title,
20
20
  :sw_title_display_facet => stanford_mods_record.sw_full_title,
21
21
  :sw_title_full_display_facet => stanford_mods_record.sw_full_title,
22
-
22
+
23
23
  # author fields
24
24
  :sw_author_1xx_search_facet_facet => stanford_mods_record.sw_main_author,
25
25
  :sw_author_7xx_search_facet_facet => stanford_mods_record.sw_addl_authors,
@@ -30,13 +30,13 @@ module Dor
30
30
  :sw_author_meeting_display_facet => stanford_mods_record.sw_meeting_authors,
31
31
  :sw_author_person_display_facet => stanford_mods_record.sw_person_authors,
32
32
  :sw_author_person_full_display_facet => stanford_mods_record.sw_person_authors,
33
-
33
+
34
34
  # subject search fields
35
- :sw_topic_search_facet_facet => stanford_mods_record.topic_search,
35
+ :sw_topic_search_facet_facet => stanford_mods_record.topic_search,
36
36
  :sw_geographic_search_facet_facet => stanford_mods_record.geographic_search,
37
- :sw_subject_other_search_facet_facet => stanford_mods_record.subject_other_search,
37
+ :sw_subject_other_search_facet_facet => stanford_mods_record.subject_other_search,
38
38
  :sw_subject_other_subvy_search_facet_facet => stanford_mods_record.subject_other_subvy_search,
39
- :sw_subject_all_search_facet_facet => stanford_mods_record.subject_all_search,
39
+ :sw_subject_all_search_facet_facet => stanford_mods_record.subject_all_search,
40
40
  :sw_topic_facet_facet => stanford_mods_record.topic_facet,
41
41
  :sw_geographic_facet_facet => stanford_mods_record.geographic_facet,
42
42
  :sw_era_facet_facet => stanford_mods_record.era_facet,
@@ -50,11 +50,11 @@ module Dor
50
50
  #publish date fields
51
51
  :sw_pub_search_facet_facet => stanford_mods_record.place,
52
52
  :sw_pub_date_sort_facet => stanford_mods_record.pub_date_sort,
53
- :sw_pub_date_group_facet_facet => stanford_mods_record.pub_date_groups(stanford_mods_record.pub_date),
53
+ :sw_pub_date_group_facet_facet => stanford_mods_record.pub_date_groups(stanford_mods_record.pub_date),
54
54
  :sw_pub_date_facet =>stanford_mods_record.pub_date_facet,
55
55
  :sw_pub_date_display_facet => stanford_mods_record.pub_date_display,
56
56
  :sw_all_search_facet_facet => stanford_mods_record.text
57
-
57
+
58
58
  }
59
59
  solr_doc.merge!(doc_hash) if doc_hash
60
60
  end