dor-services 5.5.3 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d115a932d8e1cb2d0001a0cbd438ccb3b221295
4
- data.tar.gz: c6e29d1b5dc81f5b0d01a8219af8203d26f19b8e
3
+ metadata.gz: ff194a7c8f4523d03cae50e749ca4347aef2ce63
4
+ data.tar.gz: 0187ff1e3f17f874cbc1412aa3ee1d0a2726284d
5
5
  SHA512:
6
- metadata.gz: 5a5376112d318df10bfc33b35560bec04ed86d2af40c69fe3347567dd61c33b44c150234f7567c704bf417aa2df84cd65539d3bd0bbdff2b4dd50eac21a2bdb2
7
- data.tar.gz: 6559d7a4c7728648b6862bc7e59aad6333404bedbd026588e8ea5b9b2893cbc62295752a0f1d4e81d049dca0dd85eb2676d62ddbc8ae9bee4509a03596c60638
6
+ metadata.gz: a78df8989f349a9b1d20fd940dd54437d2d756343b56fe1124e1ddad13e0933a076c434ec4db61829989154b50a3f12b51efd7198bb670784add5ed68848a91a
7
+ data.tar.gz: 9bd63d841e4a4bc0324ace233c5f72ef9b9a67c36e90fcc17eb5477be1ac59d3afbf70c93aa5af289831afe280558fa8399d7d811249c06239fadb0fac4d71a3
@@ -69,7 +69,7 @@ module Dor
69
69
  externalFile.add_previous_sibling(src_label)
70
70
  externalFile << src_image_data unless src_image_data.nil?
71
71
  end
72
-
72
+
73
73
  result
74
74
  end
75
75
 
@@ -132,7 +132,7 @@ module Dor
132
132
  preserved_size += file['size'].to_i if file['preserve'] == 'yes'
133
133
  next unless file['shelve'] == 'yes'
134
134
  counts['shelved_file'] += 1
135
- first_shelved_image ||= file['id'] if file['id'].match(/jp2$/)
135
+ first_shelved_image ||= file['id'] if file['id'] =~ /jp2$/
136
136
  end
137
137
  end
138
138
  solr_doc['content_type_ssim' ] = doc.root['type']
@@ -119,7 +119,7 @@ module Dor
119
119
  # cleanup ordering is important here
120
120
  doc.xpath('//machine/text()').each { |node| node.content = node.content.strip }
121
121
  doc.xpath('//human')
122
- .tap { |nodeset| norm.clean_linefeeds(nodeset) }
122
+ .tap { |node_set| norm.clean_linefeeds(node_set) }
123
123
  .each do |node|
124
124
  norm.trim_text(node)
125
125
  norm.remove_empty_nodes(node)
@@ -33,7 +33,9 @@ module Dor
33
33
 
34
34
  def self.xml_template
35
35
  Nokogiri::XML::Builder.new do |xml|
36
- xml.mods( 'xmlns' => MODS_NS, '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') {
36
+ xml.mods(
37
+ 'xmlns' => MODS_NS, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', :version => '3.3',
38
+ 'xsi:schemaLocation' => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd') {
37
39
  xml.titleInfo {
38
40
  xml.title
39
41
  }
@@ -2,7 +2,12 @@ module Dor
2
2
  class SimpleDublinCoreDs < ActiveFedora::OmDatastream
3
3
 
4
4
  set_terminology do |t|
5
- t.root(:path => 'dc', :xmlns => 'http://www.openarchives.org/OAI/2.0/oai_dc/', :schema => 'http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd', :namespace_prefix => 'oai_dc', :index_as => [:not_searchable])
5
+ t.root(
6
+ path: 'dc',
7
+ xmlns: 'http://www.openarchives.org/OAI/2.0/oai_dc/',
8
+ schema: 'http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd',
9
+ namespace_prefix: 'oai_dc',
10
+ index_as: [:not_searchable])
6
11
  t.title( :index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
7
12
  t.creator( :index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
8
13
  t.identifier(:index_as => [:symbol, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
@@ -64,7 +64,7 @@ module Dor
64
64
  #
65
65
  # @return [Integer] value of the priority. Defaults to 0 if none of the workflows are expedited
66
66
  def current_priority
67
- cp = workflows.detect &:expedited?
67
+ cp = workflows.detect(&:expedited?)
68
68
  return 0 if cp.nil?
69
69
  cp.priority.to_i
70
70
  end
@@ -101,6 +101,48 @@ module Dor
101
101
  end
102
102
  end
103
103
 
104
+ # Remove existing relatedItem entries for collections from descMetadata
105
+ def remove_related_item_nodes_for_collections(doc)
106
+ doc.search('/mods:mods/mods:relatedItem[@type="host"]/mods:typeOfResource[@collection=\'yes\']', 'mods' => 'http://www.loc.gov/mods/v3').each do |node|
107
+ node.parent.remove
108
+ end
109
+ end
110
+
111
+ def add_related_item_node_for_collection(doc, collection_druid)
112
+ begin
113
+ collection_obj = Dor::Item.find(collection_druid)
114
+ rescue ActiveFedora::ObjectNotFoundError
115
+ return nil
116
+ end
117
+
118
+ title_node = Nokogiri::XML::Node.new('title', doc)
119
+ title_node.content = Dor::Describable.get_collection_title(collection_obj)
120
+
121
+ title_info_node = Nokogiri::XML::Node.new('titleInfo', doc)
122
+ title_info_node.add_child(title_node)
123
+
124
+ # e.g.:
125
+ # <location>
126
+ # <url>http://purl.stanford.edu/rh056sr3313</url>
127
+ # </location>
128
+ loc_node = doc.create_element('location')
129
+ url_node = doc.create_element('url')
130
+ url_node.content = "https://#{Dor::Config.stacks.document_cache_host}/#{collection_druid.split(':').last}"
131
+ loc_node << url_node
132
+
133
+ type_node = Nokogiri::XML::Node.new('typeOfResource', doc)
134
+ type_node['collection'] = 'yes'
135
+
136
+ related_item_node = Nokogiri::XML::Node.new('relatedItem', doc)
137
+ related_item_node['type'] = 'host'
138
+
139
+ related_item_node.add_child(title_info_node)
140
+ related_item_node.add_child(loc_node)
141
+ related_item_node.add_child(type_node)
142
+
143
+ doc.root.add_child(related_item_node)
144
+ end
145
+
104
146
  # Adds to desc metadata a relatedItem with information about the collection this object belongs to.
105
147
  # For use in published mods and mods-to-DC conversion.
106
148
  # @param [Nokogiri::XML::Document] doc A copy of the descriptiveMetadata of the object, to be modified
@@ -110,41 +152,14 @@ module Dor
110
152
  return unless methods.include? :public_relationships
111
153
  collections = public_relationships.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection',
112
154
  'fedora' => 'info:fedora/fedora-system:def/relations-external#',
113
- 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' )
155
+ 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
114
156
  return if collections.empty?
115
157
 
116
- # Remove any existing collections in the descMetadata
117
- doc.search('/mods:mods/mods:relatedItem[@type="host"]/mods:typeOfResource[@collection=\'yes\']', 'mods' => 'http://www.loc.gov/mods/v3').each do |node|
118
- node.parent.remove
119
- end
158
+ remove_related_item_nodes_for_collections(doc)
120
159
 
121
160
  collections.each do |collection_node|
122
- druid = collection_node['rdf:resource']
123
- druid = druid.gsub('info:fedora/', '')
124
- collection_obj = Dor::Item.find(druid)
125
- collection_title = Dor::Describable.get_collection_title(collection_obj)
126
- related_item_node = Nokogiri::XML::Node.new('relatedItem', doc)
127
- related_item_node['type'] = 'host'
128
- title_info_node = Nokogiri::XML::Node.new('titleInfo', doc)
129
- title_node = Nokogiri::XML::Node.new('title', doc)
130
- title_node.content = collection_title
131
-
132
- # e.g.:
133
- # <location>
134
- # <url>http://purl.stanford.edu/rh056sr3313</url>
135
- # </location>
136
- loc_node = doc.create_element('location')
137
- url_node = doc.create_element('url')
138
- url_node.content = "https://#{Dor::Config.stacks.document_cache_host}/#{druid.split(':').last}"
139
- loc_node << url_node
140
-
141
- type_node = Nokogiri::XML::Node.new('typeOfResource', doc)
142
- type_node['collection'] = 'yes'
143
- doc.root.add_child(related_item_node)
144
- related_item_node.add_child(title_info_node)
145
- title_info_node.add_child(title_node)
146
- related_item_node.add_child(loc_node)
147
- related_item_node.add_child(type_node)
161
+ collection_druid = collection_node['rdf:resource'].gsub('info:fedora/', '')
162
+ add_related_item_node_for_collection(doc, collection_druid)
148
163
  end
149
164
  end
150
165
 
@@ -285,7 +300,9 @@ module Dor
285
300
  end
286
301
  label = self.label
287
302
  builder = Nokogiri::XML::Builder.new { |xml|
288
- 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') {
303
+ xml.mods(
304
+ 'xmlns' => 'http://www.loc.gov/mods/v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', :version => '3.3',
305
+ 'xsi:schemaLocation' => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd') {
289
306
  xml.titleInfo {
290
307
  xml.title label
291
308
  }
@@ -35,23 +35,25 @@ module Dor
35
35
  end
36
36
 
37
37
  def add_collection(collection_or_druid)
38
- collection = case collection_or_druid
38
+ collection =
39
+ case collection_or_druid
39
40
  when String
40
41
  Dor::Collection.find(collection_or_druid)
41
42
  when Dor::Collection
42
43
  collection_or_druid
43
- end
44
+ end
44
45
  collections << collection
45
46
  sets << collection
46
47
  end
47
48
 
48
49
  def remove_collection(collection_or_druid)
49
- collection = case collection_or_druid
50
+ collection =
51
+ case collection_or_druid
50
52
  when String
51
53
  Dor::Collection.find(collection_or_druid)
52
54
  when Dor::Collection
53
55
  collection_or_druid
54
- end
56
+ end
55
57
 
56
58
  collections.delete(collection)
57
59
  sets.delete(collection)
@@ -69,8 +69,9 @@ module Dor
69
69
  add_solr_value(solr_doc, 'title_sort', label, :string, [:stored_sortable])
70
70
 
71
71
  rels_doc = Nokogiri::XML(datastreams['RELS-EXT'].content)
72
- apos = rels_doc.search('//rdf:RDF/rdf:Description/hydra:isGovernedBy', 'hydra' => 'http://projecthydra.org/ns/relations#', 'fedora' => 'info:fedora/fedora-system:def/relations-external#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
73
- collections = rels_doc.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection', 'fedora' => 'info:fedora/fedora-system:def/relations-external#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
72
+ ns_hash = {'hydra' => 'http://projecthydra.org/ns/relations#', 'fedora' => 'info:fedora/fedora-system:def/relations-external#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'}
73
+ apos = rels_doc.search('//rdf:RDF/rdf:Description/hydra:isGovernedBy', ns_hash)
74
+ collections = rels_doc.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection', ns_hash)
74
75
  solrize_related_obj_titles(solr_doc, apos, @@apo_hash, 'apo_title', 'nonhydrus_apo_title', 'hydrus_apo_title')
75
76
  solrize_related_obj_titles(solr_doc, collections, @@collection_hash, 'collection_title', 'nonhydrus_collection_title', 'hydrus_collection_title')
76
77
 
@@ -151,7 +152,7 @@ module Dor
151
152
  # note that the comparison for duplicate tags is case-insensitive, but we don't change case as part of the normalized version
152
153
  # we return, because we want to preserve the user's intended case.
153
154
  normalized_tag = normalize_tag_arr(tag_arr)
154
- dupe_existing_tag = existing_tag_list.detect { |existing_tag| normalize_tag(existing_tag).downcase == normalized_tag.downcase }
155
+ dupe_existing_tag = existing_tag_list.detect { |existing_tag| normalize_tag(existing_tag).casecmp(normalized_tag) == 0 }
155
156
  if dupe_existing_tag
156
157
  raise "An existing tag (#{dupe_existing_tag}) is the same, consider using update_tag?"
157
158
  end
@@ -208,15 +209,13 @@ module Dor
208
209
  end
209
210
 
210
211
  def get_related_obj_display_title(related_obj, default_title)
211
- if related_obj
212
- if related_obj.datastreams['DC'] && related_obj.datastreams['DC'].title
213
- return related_obj.datastreams['DC'].title
214
- else
215
- return related_obj.label
216
- end
212
+ # desc_md_ds_title will be nil if related_obj is nil
213
+ desc_md_ds_title = if related_obj
214
+ desc_md_ds = related_obj.datastreams['descMetadata']
215
+ desc_md_ds ? desc_md_ds.title_info.main_title.first : nil
217
216
  end
218
217
 
219
- default_title
218
+ desc_md_ds_title.present? ? desc_md_ds_title : default_title
220
219
  end
221
220
 
222
221
  private
@@ -165,7 +165,8 @@ module Dor
165
165
  if self.respond_to?('versionMetadata')
166
166
  # add an entry with version id, tag and description for each version
167
167
  while current_version_num > 0
168
- add_solr_value(solr_doc, 'versions', current_version_num.to_s + ';' + versionMetadata.tag_for_version(current_version_num.to_s) + ';' + versionMetadata.description_for_version(current_version_num.to_s), :string, [:displayable])
168
+ new_val = "#{current_version_num};#{versionMetadata.tag_for_version(current_version_num.to_s)};#{versionMetadata.description_for_version(current_version_num.to_s)}"
169
+ add_solr_value(solr_doc, 'versions', new_val, :string, [:displayable])
169
170
  current_version_num -= 1
170
171
  end
171
172
  end
@@ -103,7 +103,7 @@ module Dor
103
103
  def get_tags_for_what_value(tags, what_target)
104
104
  return_hash = {}
105
105
  tags.keys.each do |key|
106
- self_tags = tags[key].select {|tag| tag['what'] == what_target.downcase}
106
+ self_tags = tags[key].select {|tag| tag['what'].casecmp(what_target) == 0}
107
107
  return_hash[key] = self_tags if self_tags.size > 0
108
108
  end
109
109
  return_hash
@@ -180,7 +180,7 @@ module Dor
180
180
  attrs = rtag.attributes
181
181
  return_hash = { :to => attrs[to].value }
182
182
  attrs.tap { |a| a.delete(to) }
183
- attrs[release] = rtag.text.downcase == 'true' # save release as a boolean
183
+ attrs[release] = rtag.text.casecmp('true') == 0 # save release as a boolean
184
184
  return_hash[:attrs] = attrs
185
185
 
186
186
  # convert all the attrs beside :to to strings, they are currently Nokogiri::XML::Attr
@@ -316,7 +316,7 @@ module Dor
316
316
  def get_release_tags_from_purl_xml(doc)
317
317
  nodes = doc.xpath('//html/body/publicobject/releasedata').children
318
318
  # We only want the nodes with a name that isn't text
319
- nodes.reject {|n| n.name.nil? || n.name.downcase == 'text'}.map {|n| n.attr('to')}.uniq
319
+ nodes.reject {|n| n.name.nil? || n.name.casecmp('text') == 0 }.map {|n| n.attr('to')}.uniq
320
320
  end
321
321
 
322
322
  # Pull all release nodes from the public xml obtained via the purl query
@@ -74,9 +74,12 @@ module Dor
74
74
  false
75
75
  end
76
76
 
77
- # @return [Boolean] true if the object is in a state that allows it to be modified. States that will allow modification are: has not been submitted for accessioning, has an open version or has sdr-ingest set to hold
77
+ # @return [Boolean] true if the object is in a state that allows it to be modified.
78
+ # States that will allow modification are: has not been submitted for accessioning, has an open version or has sdr-ingest set to hold
78
79
  def allows_modification?
79
- if Dor::Config.workflow.client.get_lifecycle('dor', pid, 'submitted') && !new_version_open? && Dor::Config.workflow.client.get_workflow_status('dor', pid, 'accessionWF', 'sdr-ingest-transfer') != 'hold'
80
+ if Dor::Config.workflow.client.get_lifecycle('dor', pid, 'submitted') &&
81
+ !new_version_open? &&
82
+ Dor::Config.workflow.client.get_workflow_status('dor', pid, 'accessionWF', 'sdr-ingest-transfer') != 'hold'
80
83
  false
81
84
  else
82
85
  true
@@ -115,7 +115,9 @@ module Dor
115
115
  if metadata_source == 'label'
116
116
  ds = new_item.build_datastream('descMetadata')
117
117
  builder = Nokogiri::XML::Builder.new { |xml|
118
- 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') {
118
+ xml.mods(
119
+ 'xmlns' => 'http://www.loc.gov/mods/v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', :version => '3.3',
120
+ 'xsi:schemaLocation' => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd') {
119
121
  xml.titleInfo {
120
122
  xml.title label
121
123
  }
data/lib/dor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dor
2
- VERSION = '5.5.3'
2
+ VERSION = '5.6.0'
3
3
  end
@@ -105,7 +105,8 @@ module Workflow
105
105
  if process.date_time && process.status && (process.status == 'completed' || process.status == 'error')
106
106
  solr_doc["wf_#{wf_name}_#{process.name}_dttsi"] = "#{process.date_time}Z"
107
107
  end
108
- add_solr_value(solr_doc, 'wf_error', "#{wf_name}:#{process.name}:#{process.error_message}", wf_solr_type, wf_solr_attrs) if process.error_message # index the error message without the druid so we hopefully get some overlap
108
+ # index the error message without the druid so we hopefully get some overlap
109
+ add_solr_value(solr_doc, 'wf_error', "#{wf_name}:#{process.name}:#{process.error_message}", wf_solr_type, wf_solr_attrs) if process.error_message
109
110
  add_solr_value(solr_doc, 'wf_wsp', "#{wf_name}:#{process.status}", wf_solr_type, wf_solr_attrs)
110
111
  add_solr_value(solr_doc, 'wf_wsp', "#{wf_name}:#{process.status}:#{process.name}", wf_solr_type, wf_solr_attrs)
111
112
  add_solr_value(solr_doc, 'wf_wps', "#{wf_name}:#{process.name}", wf_solr_type, wf_solr_attrs)
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.5.3
4
+ version: 5.6.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-03-03 00:00:00.000000000 Z
17
+ date: 2016-03-11 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: active-fedora
@@ -295,6 +295,9 @@ dependencies:
295
295
  - - "~>"
296
296
  - !ruby/object:Gem::Version
297
297
  version: '2.0'
298
+ - - ">="
299
+ - !ruby/object:Gem::Version
300
+ version: 2.0.1
298
301
  type: :runtime
299
302
  prerelease: false
300
303
  version_requirements: !ruby/object:Gem::Requirement
@@ -302,6 +305,9 @@ dependencies:
302
305
  - - "~>"
303
306
  - !ruby/object:Gem::Version
304
307
  version: '2.0'
308
+ - - ">="
309
+ - !ruby/object:Gem::Version
310
+ version: 2.0.1
305
311
  - !ruby/object:Gem::Dependency
306
312
  name: druid-tools
307
313
  requirement: !ruby/object:Gem::Requirement
@@ -524,6 +530,20 @@ dependencies:
524
530
  - - ">="
525
531
  - !ruby/object:Gem::Version
526
532
  version: '0'
533
+ - !ruby/object:Gem::Dependency
534
+ name: rubocop
535
+ requirement: !ruby/object:Gem::Requirement
536
+ requirements:
537
+ - - ">="
538
+ - !ruby/object:Gem::Version
539
+ version: '0'
540
+ type: :development
541
+ prerelease: false
542
+ version_requirements: !ruby/object:Gem::Requirement
543
+ requirements:
544
+ - - ">="
545
+ - !ruby/object:Gem::Version
546
+ version: '0'
527
547
  - !ruby/object:Gem::Dependency
528
548
  name: yard
529
549
  requirement: !ruby/object:Gem::Requirement