dor-services 5.1.1 → 5.2.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.
Files changed (68) hide show
  1. checksums.yaml +8 -8
  2. data/lib/dor-services.rb +1 -2
  3. data/lib/dor/config.rb +5 -6
  4. data/lib/dor/datastreams/content_metadata_ds.rb +17 -20
  5. data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
  6. data/lib/dor/datastreams/desc_metadata_ds.rb +7 -7
  7. data/lib/dor/datastreams/embargo_metadata_ds.rb +2 -7
  8. data/lib/dor/datastreams/events_ds.rb +9 -9
  9. data/lib/dor/datastreams/identity_metadata_ds.rb +29 -34
  10. data/lib/dor/datastreams/rights_metadata_ds.rb +1 -1
  11. data/lib/dor/datastreams/role_metadata_ds.rb +0 -1
  12. data/lib/dor/datastreams/simple_dublin_core_ds.rb +12 -13
  13. data/lib/dor/datastreams/version_metadata_ds.rb +11 -15
  14. data/lib/dor/datastreams/workflow_definition_ds.rb +18 -22
  15. data/lib/dor/datastreams/workflow_ds.rb +24 -36
  16. data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +1 -1
  17. data/lib/dor/migrations/identifiable/fix_model_assertions.rb +1 -1
  18. data/lib/dor/migrations/identifiable/record_remediation.rb +2 -2
  19. data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +1 -1
  20. data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +1 -1
  21. data/lib/dor/migrations/processable/unify_workflows.rb +4 -4
  22. data/lib/dor/migrations/versionable/add_missing_version_md.rb +2 -2
  23. data/lib/dor/models/assembleable.rb +2 -2
  24. data/lib/dor/models/collection.rb +1 -0
  25. data/lib/dor/models/contentable.rb +3 -3
  26. data/lib/dor/models/describable.rb +16 -13
  27. data/lib/dor/models/editable.rb +3 -3
  28. data/lib/dor/models/embargoable.rb +2 -2
  29. data/lib/dor/models/eventable.rb +2 -2
  30. data/lib/dor/models/geoable.rb +14 -18
  31. data/lib/dor/models/governable.rb +1 -1
  32. data/lib/dor/models/identifiable.rb +36 -57
  33. data/lib/dor/models/itemizable.rb +6 -6
  34. data/lib/dor/models/presentable.rb +12 -12
  35. data/lib/dor/models/preservable.rb +2 -5
  36. data/lib/dor/models/processable.rb +19 -25
  37. data/lib/dor/models/publishable.rb +2 -2
  38. data/lib/dor/models/releaseable.rb +165 -212
  39. data/lib/dor/models/shelvable.rb +10 -14
  40. data/lib/dor/models/upgradable.rb +11 -11
  41. data/lib/dor/models/versionable.rb +16 -21
  42. data/lib/dor/models/workflow_object.rb +3 -3
  43. data/lib/dor/services/cleanup_reset_service.rb +32 -27
  44. data/lib/dor/services/digital_stacks_service.rb +3 -3
  45. data/lib/dor/services/merge_service.rb +4 -8
  46. data/lib/dor/services/metadata_handlers/catalog_handler.rb +1 -1
  47. data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +4 -6
  48. data/lib/dor/services/metadata_service.rb +20 -22
  49. data/lib/dor/services/registration_service.rb +6 -8
  50. data/lib/dor/services/reset_workspace_service.rb +14 -16
  51. data/lib/dor/services/sdr_ingest_service.rb +2 -6
  52. data/lib/dor/services/search_service.rb +3 -3
  53. data/lib/dor/services/suri_service.rb +2 -3
  54. data/lib/dor/services/technical_metadata_service.rb +2 -3
  55. data/lib/dor/utils/ng_tidy.rb +6 -6
  56. data/lib/dor/utils/predicate_patch.rb +1 -1
  57. data/lib/dor/utils/solr_doc_helper.rb +2 -2
  58. data/lib/dor/version.rb +1 -1
  59. data/lib/dor/workflow/document.rb +27 -33
  60. data/lib/dor/workflow/graph.rb +34 -37
  61. data/lib/dor/workflow/process.rb +8 -8
  62. data/lib/tasks/rdoc.rake +5 -5
  63. metadata +4 -11
  64. data/bin/dor-indexer +0 -108
  65. data/bin/dor-indexerd +0 -73
  66. data/config/certs/robots-dor-dev.crt +0 -29
  67. data/config/certs/robots-dor-dev.key +0 -27
  68. data/config/dev_console_env.rb +0 -78
@@ -99,7 +99,7 @@ module Dor
99
99
  self.administrativeMetadata.metadata_source.first
100
100
  end
101
101
  def metadata_source=(val)
102
- if self.administrativeMetadata.descMetadata == nil
102
+ if self.administrativeMetadata.descMetadata.nil?
103
103
  self.administrativeMetadata.add_child_node(self.administrativeMetadata, :descMetadata)
104
104
  end
105
105
  self.administrativeMetadata.update_values({[:descMetadata, :source] => val})
@@ -124,13 +124,13 @@ module Dor
124
124
  end
125
125
  def creative_commons_license=(val)
126
126
  (machine, human)=val
127
- if creative_commons_license == nil
127
+ if creative_commons_license.nil?
128
128
  self.defaultObjectRights.add_child_node(self.defaultObjectRights.ng_xml.root, :creative_commons)
129
129
  end
130
130
  self.defaultObjectRights.update_values({[:creative_commons] => val})
131
131
  end
132
132
  def creative_commons_license_human=(val)
133
- if creative_commons_license_human == nil
133
+ if creative_commons_license_human.nil?
134
134
  #add the nodes
135
135
  self.defaultObjectRights.add_child_node(self.defaultObjectRights.ng_xml.root, :creative_commons)
136
136
  end
@@ -28,7 +28,7 @@ module Dor
28
28
  release_access = embargo_md.release_access_node
29
29
  release_access.xpath('//releaseAccess/access').each do |new_access|
30
30
  access_sibling = rights_xml.at_xpath("//rightsMetadata/access[last()]")
31
- if(access_sibling)
31
+ if access_sibling
32
32
  access_sibling.add_next_sibling(new_access.clone)
33
33
  else
34
34
  rights_xml.root.add_child(new_access.clone)
@@ -50,7 +50,7 @@ module Dor
50
50
 
51
51
  # Replace rights <access> nodes with 1 machine/world node
52
52
  access_sibling = rights_xml.at_xpath("//rightsMetadata/access[last()]")
53
- if(access_sibling)
53
+ if access_sibling
54
54
  access_sibling.add_next_sibling(world_doc.root.clone)
55
55
  else
56
56
  rights_xml.root.add_child(world_doc.root.clone)
@@ -4,9 +4,9 @@ module Dor
4
4
  included do
5
5
  has_metadata :name => 'events', :type => Dor::EventsDS, :label => 'Events'
6
6
  end
7
-
7
+
8
8
  def add_event *args
9
9
  self.datastreams['events'].add_event *args
10
10
  end
11
11
  end
12
- end
12
+ end
@@ -2,34 +2,30 @@ module Dor
2
2
  module Geoable
3
3
  extend ActiveSupport::Concern
4
4
 
5
- class CrosswalkError < Exception; end
6
-
5
+ class CrosswalkError < Exception; end
6
+
7
7
  included do
8
- has_metadata :name => 'geoMetadata',
9
- :type => Dor::GeoMetadataDS,
10
- :label => 'Geographic Information Metadata in ISO 19139',
8
+ has_metadata :name => 'geoMetadata',
9
+ :type => Dor::GeoMetadataDS,
10
+ :label => 'Geographic Information Metadata in ISO 19139',
11
11
  :control_group => 'M'
12
12
  end
13
-
14
- # @return [String] XML
13
+
14
+ # @return [String, nil] XML
15
15
  def fetch_geoMetadata_datastream
16
16
  candidates = self.datastreams['identityMetadata'].otherId.collect { |oid| oid.to_s }
17
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
18
+ return nil if metadata_id.nil?
19
+ return Dor::MetadataService.fetch(metadata_id.to_s)
23
20
  end
24
21
 
25
22
  def build_geoMetadata_datastream(ds)
26
23
  content = fetch_geoMetadata_datastream
27
- unless content.nil?
28
- ds.dsLabel = self.label
29
- ds.ng_xml = Nokogiri::XML(content)
30
- ds.ng_xml.normalize_text!
31
- ds.content = ds.ng_xml.to_xml
32
- end
24
+ return nil if content.nil?
25
+ ds.dsLabel = self.label
26
+ ds.ng_xml = Nokogiri::XML(content)
27
+ ds.ng_xml.normalize_text!
28
+ ds.content = ds.ng_xml.to_xml
33
29
  end
34
30
  end
35
31
  end
@@ -26,7 +26,7 @@ module Dor
26
26
  lane
27
27
  end
28
28
 
29
- def reset_to_apo_default()
29
+ def reset_to_apo_default
30
30
  self.rightsMetadata.content = admin_policy_object.rightsMetadata.ng_xml
31
31
  end
32
32
 
@@ -19,10 +19,8 @@ module Dor
19
19
  end
20
20
 
21
21
  def initialize attrs={}
22
- if Dor::Config.suri.mint_ids
23
- unless attrs[:pid]
24
- attrs = attrs.merge!({:pid=>Dor::SuriService.mint_id, :new_object => true})
25
- end
22
+ if Dor::Config.suri.mint_ids && !attrs[:pid]
23
+ attrs = attrs.merge!({:pid=>Dor::SuriService.mint_id, :new_object => true})
26
24
  end
27
25
  super
28
26
  end
@@ -80,7 +78,7 @@ module Dor
80
78
  return solr_doc
81
79
  end
82
80
 
83
- #@return [String] calculated value for Solr index
81
+ # @return [String] calculated value for Solr index
84
82
  def identity_metadata_source
85
83
  if self.identityMetadata.otherId('catkey').first ||
86
84
  self.identityMetadata.otherId('barcode').first
@@ -104,25 +102,17 @@ module Dor
104
102
  end
105
103
 
106
104
  def update_other_Id(type, new_val, val=nil)
107
- updated=false
108
- self.identityMetadata.ng_xml.search('//otherId[@name=\''+type+'\']').each do |node|
109
- if node.content==val || val.nil?
110
- node.content=new_val
111
- updated=true
112
- end
113
- end
114
- return updated
105
+ self.identityMetadata.ng_xml.search('//otherId[@name=\''+type+'\']')
106
+ .select{ |node| val.nil? || node.content == val }
107
+ .each { |node| node.content = new_val }
108
+ .any?
115
109
  end
116
110
 
117
111
  def remove_other_Id(type, val=nil)
118
- removed=false
119
- self.identityMetadata.ng_xml.search('//otherId[@name=\''+type+'\']').each do |node|
120
- if node.content===val || val.nil?
121
- node.remove
122
- removed=true
123
- end
124
- end
125
- return removed
112
+ self.identityMetadata.ng_xml.search('//otherId[@name=\''+type+'\']')
113
+ .select{ |node| val.nil? || node.content == val }
114
+ .each(&:remove)
115
+ .any?
126
116
  end
127
117
 
128
118
  # turns a tag string into an array with one element per tag part.
@@ -158,11 +148,9 @@ module Dor
158
148
  return normalized_tag
159
149
  end
160
150
 
161
- #Ensure that an administrative tag meets the proper mininum format
162
- #
163
- #@param tag_str [String] the tag
164
- #
165
- #@return [Array] the tag split into an array via ':'
151
+ # Ensure that an administrative tag meets the proper mininum format
152
+ # @param tag_str [String] the tag
153
+ # @return [Array] the tag split into an array via ':'
166
154
  def validate_tag_format(tag_str)
167
155
  tag_arr = split_tag_to_arr(tag_str)
168
156
 
@@ -176,9 +164,8 @@ module Dor
176
164
  return tag_arr
177
165
  end
178
166
 
179
- #Add an administrative tag to an item, you will need to seperately save the item to write it to fedora
180
- #
181
- #@param tag [string] The tag you wish to add
167
+ # Add an administrative tag to an item, you will need to seperately save the item to write it to fedora
168
+ # @param tag [string] The tag you wish to add
182
169
  def add_tag(tag)
183
170
  identity_metadata_ds = self.identityMetadata
184
171
  normalized_tag = validate_and_normalize_tag(tag, identity_metadata_ds.tags)
@@ -186,37 +173,30 @@ module Dor
186
173
  end
187
174
 
188
175
  def remove_tag(tag)
189
- removed = false
190
- self.identityMetadata.ng_xml.search('//tag').each do |node|
191
- if normalize_tag(node.content) === normalize_tag(tag)
192
- node.remove
193
- removed = true
194
- end
195
- end
196
- return removed
176
+ normtag = normalize_tag(tag)
177
+ self.identityMetadata.ng_xml.search('//tag')
178
+ .select{ |node| normalize_tag(node.content) == normtag }
179
+ .each(&:remove)
180
+ .any?
197
181
  end
198
-
199
- #Removes all displayTypes from an item in preparation of adding a new display type
200
- #
201
- #@return Boolean True if displayTypes were removed, False if no displayTypes were removed
182
+
183
+ # Removes all displayTypes from an item in preparation of adding a new display type
184
+ # @return Boolean True if displayTypes were removed, False if no displayTypes were removed
202
185
  def remove_displayTypes
203
- removed = false
204
- self.identityMetadata.ng_xml.search('//displayType').each do |node|
205
- node.remove
206
- removed = true
207
- end
208
- return removed
186
+ nodes = self.identityMetadata.ng_xml.search('//displayType')
187
+ # NOTE: .each after search is different than normal ruby enumerator:
188
+ # ~ ng_xml.search('//nonexistant_tag').each(&:foo) == 0
189
+ # ~ [].each(&:foo) == []
190
+ nodes.each(&:remove)
191
+ nodes.any?
209
192
  end
210
193
 
211
194
  def update_tag(old_tag, new_tag)
212
- updated = false
213
- self.identityMetadata.ng_xml.search('//tag').each do |node|
214
- if normalize_tag(node.content) == normalize_tag(old_tag)
215
- node.content = normalize_tag(new_tag)
216
- updated = true
217
- end
218
- end
219
- return updated
195
+ normtag = normalize_tag(old_tag)
196
+ self.identityMetadata.ng_xml.search('//tag')
197
+ .select{ |node| normalize_tag(node.content) == normtag }
198
+ .each { |node| node.content = normalize_tag(new_tag) }
199
+ .any?
220
200
  end
221
201
 
222
202
  def get_related_obj_display_title(related_obj, default_title)
@@ -231,7 +211,6 @@ module Dor
231
211
  return default_title
232
212
  end
233
213
 
234
-
235
214
  private
236
215
  def solrize_related_obj_titles(solr_doc, relationships, title_hash, field_name)
237
216
  title_type = :symbol # we'll get an _ssim because of the type
@@ -240,7 +219,7 @@ module Dor
240
219
  rel_druid = rel_node['rdf:resource']
241
220
  next unless rel_druid # TODO: warning here would also be useful
242
221
  rel_druid = rel_druid.gsub('info:fedora/', '')
243
- if title_hash.has_key?(rel_druid)
222
+ if title_hash.key?(rel_druid)
244
223
  add_solr_value(solr_doc, field_name, title_hash[rel_druid], title_type, title_attrs)
245
224
  else
246
225
  related_obj = Dor.find(rel_druid)
@@ -8,20 +8,20 @@ module Dor
8
8
  included do
9
9
  has_metadata :name => "contentMetadata", :type => Dor::ContentMetadataDS, :label => 'Content Metadata', :control_group => 'M'
10
10
  end
11
-
11
+
12
12
  DIFF_FILENAME = 'cm_inv_diff'
13
13
  DIFF_QUERY = DIFF_FILENAME.gsub('_', '-')
14
14
 
15
15
  # Deletes all cm_inv_diff files in the workspace for the Item
16
16
  def clear_diff_cache
17
17
  if Dor::Config.stacks.local_workspace_root.nil?
18
- raise ArgumentError, 'Missing Dor::Config.stacks.local_workspace_root'
18
+ raise ArgumentError, 'Missing Dor::Config.stacks.local_workspace_root'
19
19
  end
20
20
  druid = DruidTools::Druid.new(self.pid, Dor::Config.stacks.local_workspace_root)
21
21
  diff_pattern = File.join(druid.temp_dir, DIFF_FILENAME + '.*')
22
22
  FileUtils.rm_f Dir.glob(diff_pattern)
23
23
  end
24
-
24
+
25
25
  # Retrieves file difference manifest for contentMetadata from SDR
26
26
  #
27
27
  # @param [String] subset keyword for file attributes :shelve, :preserve, :publish. Default is :all.
@@ -29,7 +29,7 @@ module Dor
29
29
  # @return [String] XML contents of cm_inv_diff manifest
30
30
  def get_content_diff(subset = :all, version = nil)
31
31
  if Dor::Config.stacks.local_workspace_root.nil?
32
- raise Dor::ParameterError, 'Missing Dor::Config.stacks.local_workspace_root'
32
+ raise Dor::ParameterError, 'Missing Dor::Config.stacks.local_workspace_root'
33
33
  end
34
34
  unless %w{all shelve preserve publish}.include?(subset.to_s)
35
35
  raise Dor::ParameterError, "Invalid subset value: #{subset}"
@@ -51,6 +51,6 @@ module Dor
51
51
  response = sdr_client[sdr_query].post(current_content, :content_type => 'application/xml')
52
52
  response
53
53
  end
54
-
54
+
55
55
  end
56
- end
56
+ end
@@ -6,9 +6,9 @@ module Dor
6
6
  DC_NS = {"dc"=>"http://purl.org/dc/elements/1.1/", "oai_dc"=>"http://www.openarchives.org/OAI/2.0/oai_dc/"}
7
7
 
8
8
  def iiif_presentation_manifest_needed? pub_obj_doc
9
- if(pub_obj_doc.at_xpath('/publicObject/contentMetadata[contains(@type,"image") or contains(@type,"map")]/resource[@type="image"]'))
9
+ if pub_obj_doc.at_xpath('/publicObject/contentMetadata[contains(@type,"image") or contains(@type,"map")]/resource[@type="image"]')
10
10
  return true
11
- elsif(pub_obj_doc.at_xpath('/publicObject/contentMetadata[@type="book"]/resource[@type="page"]'))
11
+ elsif pub_obj_doc.at_xpath('/publicObject/contentMetadata[@type="book"]/resource[@type="page"]')
12
12
  return true
13
13
  else
14
14
  return false
@@ -32,13 +32,13 @@ module Dor
32
32
  '@id' => "#{purl_base_uri}/iiif/manifest.json",
33
33
  'label' => lbl,
34
34
  'attribution' => 'Provided by the Stanford University Libraries',
35
- 'logo' => {
36
- '@id' => "http://stacks.stanford.edu/image/iiif/wy534zh7137%2FSULAIR_rosette/full/400,/0/default.jpg",
37
- 'service' => {
38
- '@context' => "http://iiif.io/api/image/2/context.json",
39
- '@id' => "http://stacks.stanford.edu/image/iiif/wy534zh7137%2FSULAIR_rosette",
40
- 'profile' => "http://iiif.io/api/image/2/level1.json"
41
- }
35
+ 'logo' => {
36
+ '@id' => "https://stacks.stanford.edu/image/iiif/wy534zh7137%2FSULAIR_rosette/full/400,/0/default.jpg",
37
+ 'service' => {
38
+ '@context' => "http://iiif.io/api/image/2/context.json",
39
+ '@id' => "https://stacks.stanford.edu/image/iiif/wy534zh7137%2FSULAIR_rosette",
40
+ 'profile' => "http://iiif.io/api/image/2/level1.json"
41
+ }
42
42
  },
43
43
  'seeAlso' => {
44
44
  '@id' => "#{purl_base_uri}.mods",
@@ -46,14 +46,14 @@ module Dor
46
46
  }
47
47
  }
48
48
  # Use the human copyright statement for attribution if present
49
- if(cr = pub_obj_doc.at_xpath('/publicObject/rightsMetadata/copyright/human[@type="copyright"]'))
49
+ if (cr = pub_obj_doc.at_xpath('/publicObject/rightsMetadata/copyright/human[@type="copyright"]'))
50
50
  manifest_data['attribution'] = cr.text
51
51
  end
52
52
 
53
53
  manifest = IIIF::Presentation::Manifest.new manifest_data
54
54
 
55
55
  # Set viewingHint to paged if this is a book
56
- if(pub_obj_doc.at_xpath('/publicObject/contentMetadata[@type="book"]'))
56
+ if pub_obj_doc.at_xpath('/publicObject/contentMetadata[@type="book"]')
57
57
  manifest.viewingHint = "paged"
58
58
  end
59
59
 
@@ -65,7 +65,7 @@ module Dor
65
65
  add_metadata 'Date', '//oai_dc:dc/dc:date', metadata, pub_obj_doc
66
66
 
67
67
  # Save off the first dc:description without displayLabel
68
- if(desc = pub_obj_doc.at_xpath('//oai_dc:dc/dc:description[not(@displayLabel)]', DC_NS))
68
+ if (desc = pub_obj_doc.at_xpath('//oai_dc:dc/dc:description[not(@displayLabel)]', DC_NS))
69
69
  manifest.description = desc.text
70
70
  end
71
71
 
@@ -13,11 +13,9 @@ module Dor
13
13
  workflow_provenance = create_workflow_provenance(workflow_id, event_text)
14
14
  dsname = 'provenanceMetadata'
15
15
  ds = datastreams[dsname]
16
- unless datastreams.keys.include?(dsname)
17
- ds.label = 'Provenance Metadata'
18
- end
16
+ ds.label = 'Provenance Metadata' unless datastreams.keys.include?(dsname)
19
17
  ds.ng_xml = workflow_provenance
20
- ds.content=ds.ng_xml.to_s
18
+ ds.content=ds.ng_xml.to_s
21
19
  ds.save
22
20
  end
23
21
 
@@ -29,7 +27,6 @@ module Dor
29
27
  SdrIngestService.transfer(self,agreement_id)
30
28
  end
31
29
 
32
-
33
30
  # @return [Nokogiri::Document]
34
31
  def create_workflow_provenance(workflow_id, event_text)
35
32
  builder = Nokogiri::XML::Builder.new do |xml|
@@ -38,23 +38,21 @@ module Dor
38
38
  'opened' => 1
39
39
  }
40
40
 
41
+ # This is a work-around for some strange logic in ActiveFedora that
42
+ # don't allow self.workflows.new? to work if we load the object using
43
+ # .load_instance_from_solr.
41
44
  def set_workflows_datastream_location
42
- # This is a work-around for some strange logic in ActiveFedora that
43
- # don't allow self.workflows.new? to work if we load the object using
44
- # .load_instance_from_solr.
45
- return if self.respond_to? :inner_object and self.inner_object.is_a? ActiveFedora::SolrDigitalObject
46
-
47
- if self.workflows.new?
48
- workflows.mimeType = 'application/xml'
49
- workflows.dsLocation = File.join(Dor::Config.workflow.url,"dor/objects/#{self.pid}/workflows")
50
- end
45
+ return if self.respond_to?(:inner_object) && self.inner_object.is_a?(ActiveFedora::SolrDigitalObject)
46
+ return unless self.workflows.new?
47
+ workflows.mimeType = 'application/xml'
48
+ workflows.dsLocation = File.join(Dor::Config.workflow.url,"dor/objects/#{self.pid}/workflows")
51
49
  end
52
50
 
53
51
  def empty_datastream?(datastream)
54
52
  if datastream.new?
55
53
  true
56
54
  elsif datastream.class.respond_to?(:xml_template)
57
- datastream.content.to_s.empty? or EquivalentXml.equivalent?(datastream.content, datastream.class.xml_template)
55
+ datastream.content.to_s.empty? || EquivalentXml.equivalent?(datastream.content, datastream.class.xml_template)
58
56
  else
59
57
  datastream.content.to_s.empty?
60
58
  end
@@ -84,7 +82,7 @@ module Dor
84
82
  ds.content = content
85
83
  ds.ng_xml = Nokogiri::XML(content) if ds.respond_to?(:ng_xml)
86
84
  ds.save unless ds.digital_object.new?
87
- elsif force or empty_datastream?(ds)
85
+ elsif force || empty_datastream?(ds)
88
86
  meth = "build_#{datastream}_datastream".to_sym
89
87
  if respond_to?(meth)
90
88
  content = self.send(meth, ds)
@@ -98,7 +96,7 @@ module Dor
98
96
  return ds
99
97
  end
100
98
 
101
- def cleanup()
99
+ def cleanup
102
100
  CleanupService.cleanup(self)
103
101
  end
104
102
 
@@ -107,7 +105,7 @@ module Dor
107
105
  end
108
106
 
109
107
  # @return [Hash] including :current_version, :status_code and :status_time
110
- def status_info()
108
+ def status_info
111
109
  current_version = '1'
112
110
  begin
113
111
  current_version = self.versionMetadata.current_version_id
@@ -118,8 +116,8 @@ module Dor
118
116
  #only get steps that are part of accessioning and part of the current version. That can mean they were archived with the current version
119
117
  #number, or they might be active (no version number).
120
118
  milestones.each do |m|
121
- if STEPS.keys.include?(m[:milestone]) and (m[:version].nil? or m[:version] == current_version)
122
- current_milestones << m unless m[:milestone] == 'registered' and current_version.to_i > 1
119
+ if STEPS.keys.include?(m[:milestone]) && (m[:version].nil? || m[:version] == current_version)
120
+ current_milestones << m unless m[:milestone] == 'registered' && current_version.to_i > 1
123
121
  end
124
122
  end
125
123
 
@@ -129,12 +127,9 @@ module Dor
129
127
  current_milestones.each do |m|
130
128
  name = m[:milestone]
131
129
  time = m[:at].utc.xmlschema
132
- if STEPS.keys.include? name
133
- if STEPS[name] > status_code
134
- status_code = STEPS[name]
135
- status_time = time
136
- end
137
- end
130
+ next unless STEPS.keys.include?(name) && STEPS[name] > status_code
131
+ status_code = STEPS[name]
132
+ status_time = time
138
133
  end
139
134
 
140
135
  return {:current_version => current_version, :status_code => status_code, :status_time => status_time}
@@ -220,7 +215,7 @@ module Dor
220
215
  def initialize_workflow(name, create_ds=true, priority=0)
221
216
  priority = workflows.current_priority if priority == 0
222
217
  opts = { :create_ds => create_ds, :lane_id => default_workflow_lane }
223
- opts[:priority] = priority if(priority > 0)
218
+ opts[:priority] = priority if priority > 0
224
219
  Dor::WorkflowService.create_workflow(Dor::WorkflowObject.initial_repo(name), self.pid, name, Dor::WorkflowObject.initial_workflow(name), opts)
225
220
  end
226
221
 
@@ -228,16 +223,15 @@ module Dor
228
223
  #handles formating utc date/time to human readable
229
224
  # XXX: bad form to hardcode TZ here. Code smell abounds.
230
225
  def format_date datetime
231
- begin
226
+
232
227
  d = datetime.is_a?(Time) ? datetime :
233
228
  DateTime.parse(datetime).in_time_zone(ActiveSupport::TimeZone.new("Pacific Time (US & Canada)"))
234
229
  I18n.l(d).strftime('%Y-%m-%d %I:%M%p')
235
230
  rescue
236
231
  d = datetime.is_a?(Time) ? datetime : Time.parse(datetime.to_s)
237
232
  d.strftime('%Y-%m-%d %I:%M%p')
238
- end
233
+
239
234
  end
240
235
  end
241
236
 
242
-
243
237
  end