dor-services 6.0.5 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dor-services.rb +27 -12
  3. data/lib/dor/config.rb +45 -42
  4. data/lib/dor/datastreams/administrative_metadata_ds.rb +137 -44
  5. data/lib/dor/datastreams/content_metadata_ds.rb +42 -42
  6. data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
  7. data/lib/dor/datastreams/default_object_rights_ds.rb +185 -44
  8. data/lib/dor/datastreams/desc_metadata_ds.rb +36 -28
  9. data/lib/dor/datastreams/embargo_metadata_ds.rb +12 -14
  10. data/lib/dor/datastreams/events_ds.rb +10 -10
  11. data/lib/dor/datastreams/geo_metadata_ds.rb +4 -5
  12. data/lib/dor/datastreams/identity_metadata_ds.rb +14 -14
  13. data/lib/dor/datastreams/rights_metadata_ds.rb +23 -23
  14. data/lib/dor/datastreams/role_metadata_ds.rb +61 -15
  15. data/lib/dor/datastreams/simple_dublin_core_ds.rb +8 -8
  16. data/lib/dor/datastreams/version_metadata_ds.rb +10 -12
  17. data/lib/dor/datastreams/workflow_definition_ds.rb +6 -6
  18. data/lib/dor/datastreams/workflow_ds.rb +13 -13
  19. data/lib/dor/exceptions.rb +2 -2
  20. data/lib/dor/indexers/data_indexer.rb +1 -7
  21. data/lib/dor/indexers/describable_indexer.rb +1 -1
  22. data/lib/dor/indexers/identifiable_indexer.rb +0 -2
  23. data/lib/dor/indexers/processable_indexer.rb +55 -28
  24. data/lib/dor/indexers/releasable_indexer.rb +2 -2
  25. data/lib/dor/models/admin_policy_object.rb +4 -4
  26. data/lib/dor/models/concerns/assembleable.rb +4 -0
  27. data/lib/dor/models/concerns/contentable.rb +27 -69
  28. data/lib/dor/models/concerns/describable.rb +14 -29
  29. data/lib/dor/models/concerns/editable.rb +20 -334
  30. data/lib/dor/models/concerns/embargoable.rb +7 -11
  31. data/lib/dor/models/concerns/eventable.rb +5 -1
  32. data/lib/dor/models/concerns/geoable.rb +4 -4
  33. data/lib/dor/models/concerns/governable.rb +18 -87
  34. data/lib/dor/models/concerns/identifiable.rb +15 -75
  35. data/lib/dor/models/concerns/itemizable.rb +9 -11
  36. data/lib/dor/models/concerns/preservable.rb +4 -0
  37. data/lib/dor/models/concerns/processable.rb +30 -129
  38. data/lib/dor/models/concerns/publishable.rb +6 -55
  39. data/lib/dor/models/concerns/releaseable.rb +14 -227
  40. data/lib/dor/models/concerns/rightsable.rb +3 -3
  41. data/lib/dor/models/concerns/shelvable.rb +4 -49
  42. data/lib/dor/models/concerns/versionable.rb +21 -44
  43. data/lib/dor/models/set.rb +1 -1
  44. data/lib/dor/models/workflow_object.rb +2 -2
  45. data/lib/dor/services/ability.rb +77 -0
  46. data/lib/dor/services/cleanup_reset_service.rb +1 -3
  47. data/lib/dor/services/create_workflow_service.rb +51 -0
  48. data/lib/dor/services/creative_commons_license_service.rb +31 -0
  49. data/lib/dor/services/datastream_builder.rb +90 -0
  50. data/lib/dor/services/digital_stacks_service.rb +3 -21
  51. data/lib/dor/services/dublin_core_service.rb +40 -0
  52. data/lib/dor/services/file_metadata_merge_service.rb +67 -0
  53. data/lib/dor/services/indexing_service.rb +8 -4
  54. data/lib/dor/services/merge_service.rb +5 -5
  55. data/lib/dor/services/metadata_handlers/catalog_handler.rb +1 -1
  56. data/lib/dor/services/metadata_service.rb +6 -8
  57. data/lib/dor/{models/concerns → services}/mods2dc.xslt +0 -0
  58. data/lib/dor/services/ontology.rb +35 -0
  59. data/lib/dor/services/open_data_license_service.rb +20 -0
  60. data/lib/dor/services/public_desc_metadata_service.rb +21 -14
  61. data/lib/dor/services/public_xml_service.rb +6 -6
  62. data/lib/dor/services/publish_metadata_service.rb +100 -0
  63. data/lib/dor/services/registration_service.rb +43 -46
  64. data/lib/dor/services/release_tag_service.rb +251 -0
  65. data/lib/dor/services/reset_workspace_service.rb +1 -3
  66. data/lib/dor/services/sdr_ingest_service.rb +5 -7
  67. data/lib/dor/services/search_service.rb +10 -10
  68. data/lib/dor/services/secondary_file_name_service.rb +10 -0
  69. data/lib/dor/services/shelving_service.rb +67 -0
  70. data/lib/dor/services/status_service.rb +121 -0
  71. data/lib/dor/services/suri_service.rb +3 -5
  72. data/lib/dor/services/tag_service.rb +100 -0
  73. data/lib/dor/services/technical_metadata_service.rb +5 -4
  74. data/lib/dor/services/version_service.rb +84 -0
  75. data/lib/dor/utils/ng_tidy.rb +1 -1
  76. data/lib/dor/utils/sdr_client.rb +25 -9
  77. data/lib/dor/version.rb +1 -1
  78. data/lib/dor/workflow/document.rb +13 -13
  79. data/lib/dor/workflow/process.rb +71 -26
  80. data/lib/tasks/rdoc.rake +1 -1
  81. metadata +77 -51
  82. data/config/certs/robots-dor-dev.crt +0 -29
  83. data/config/certs/robots-dor-dev.key +0 -27
  84. data/config/dev_console_env.rb +0 -80
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'scanf'
@@ -13,10 +12,10 @@ module Dor
13
12
  class GeoMetadataDS < ActiveFedora::OmDatastream
14
13
  # namespaces
15
14
  NS = {
16
- :rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
17
- :gco => 'http://www.isotc211.org/2005/gco',
18
- :gmd => 'http://www.isotc211.org/2005/gmd',
19
- :gfc => 'http://www.isotc211.org/2005/gfc'
15
+ rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
16
+ gco: 'http://www.isotc211.org/2005/gco',
17
+ gmd: 'http://www.isotc211.org/2005/gmd',
18
+ gfc: 'http://www.isotc211.org/2005/gfc'
20
19
  }.freeze
21
20
 
22
21
  # hash with all namespaces
@@ -5,20 +5,20 @@ module Dor
5
5
  include SolrDocHelper
6
6
 
7
7
  set_terminology do |t|
8
- t.root(:path => 'identityMetadata')
9
- t.objectId :index_as => [:symbol]
10
- t.objectType :index_as => [:symbol]
8
+ t.root(path: 'identityMetadata')
9
+ t.objectId index_as: [:symbol]
10
+ t.objectType index_as: [:symbol]
11
11
  t.objectLabel
12
12
  t.citationCreator
13
13
  t.sourceId
14
- t.otherId(:path => 'otherId') do
15
- t.name_(:path => { :attribute => 'name' })
14
+ t.otherId(path: 'otherId') do
15
+ t.name_(path: { attribute: 'name' })
16
16
  end
17
- t.agreementId :index_as => [:stored_searchable, :symbol]
18
- t.tag :index_as => [:symbol]
17
+ t.agreementId index_as: %i[stored_searchable symbol]
18
+ t.tag index_as: [:symbol]
19
19
  t.citationTitle
20
- t.objectCreator :index_as => [:stored_searchable, :symbol]
21
- t.adminPolicy :index_as => [:not_searchable]
20
+ t.objectCreator index_as: %i[stored_searchable symbol]
21
+ t.adminPolicy index_as: [:not_searchable]
22
22
  end
23
23
 
24
24
  define_template :value do |builder, name, value, attrs|
@@ -71,7 +71,7 @@ module Dor
71
71
  if type.nil?
72
72
  result.collect { |n| [n['name'], n.text].join(':') }
73
73
  else
74
- result.select { |n| n['name'] == type }.collect { |n| n.text }
74
+ result.select { |n| n['name'] == type }.collect(&:text)
75
75
  end
76
76
  end
77
77
 
@@ -99,16 +99,16 @@ module Dor
99
99
  add_solr_value(solr_doc, 'identifier', sourceId, :symbol, [:stored_searchable])
100
100
  add_solr_value(solr_doc, 'source_id', sourceId, :symbol, [])
101
101
  end
102
- otherId.compact.each { |qid|
102
+ otherId.compact.each do |qid|
103
103
  # this section will solrize barcode and catkey, which live in otherId
104
104
  (name, id) = qid.split(/:/, 2)
105
105
  add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
106
106
  add_solr_value(solr_doc, 'identifier', qid, :symbol, [:stored_searchable])
107
107
  add_solr_value(solr_doc, "#{name}_id", id, :symbol, [])
108
- }
108
+ end
109
109
 
110
110
  # do some stuff to make tags in general and project tags specifically more easily searchable and facetable
111
- find_by_terms(:tag).each { |tag|
111
+ find_by_terms(:tag).each do |tag|
112
112
  (prefix, rest) = tag.text.split(/:/, 2)
113
113
  prefix = prefix.downcase.strip.gsub(/\s/, '_')
114
114
  unless rest.nil?
@@ -129,7 +129,7 @@ module Dor
129
129
  progressive_tag_prefix += part.strip
130
130
  add_solr_value(solr_doc, 'exploded_tag', progressive_tag_prefix, :symbol, [])
131
131
  end
132
- }
132
+ end
133
133
 
134
134
  solr_doc
135
135
  end
@@ -11,43 +11,43 @@ module Dor
11
11
  # Ultimately, default_object_rights should go away and APOs also use an instantation of this class
12
12
 
13
13
  set_terminology do |t|
14
- t.root :path => 'rightsMetadata', :index_as => [:not_searchable]
15
- t.copyright :path => 'copyright/human', :index_as => [:symbol]
16
- t.use_statement :path => '/use/human[@type=\'useAndReproduction\']', :index_as => [:symbol]
14
+ t.root path: 'rightsMetadata', index_as: [:not_searchable]
15
+ t.copyright path: 'copyright/human', index_as: [:symbol]
16
+ t.use_statement path: '/use/human[@type=\'useAndReproduction\']', index_as: [:symbol]
17
17
 
18
18
  t.use do
19
19
  t.machine
20
20
  t.human
21
21
  end
22
22
 
23
- t.creative_commons :path => '/use/machine[@type=\'creativeCommons\']', :type => 'creativeCommons' do
24
- t.uri :path => '@uri'
23
+ t.creative_commons path: '/use/machine[@type=\'creativeCommons\']', type: 'creativeCommons' do
24
+ t.uri path: '@uri'
25
25
  end
26
- t.creative_commons_human :path => '/use/human[@type=\'creativeCommons\']'
27
- t.open_data_commons :path => '/use/machine[@type=\'openDataCommons\']', :type => 'openDataCommons' do
28
- t.uri :path => '@uri'
26
+ t.creative_commons_human path: '/use/human[@type=\'creativeCommons\']'
27
+ t.open_data_commons path: '/use/machine[@type=\'openDataCommons\']', type: 'openDataCommons' do
28
+ t.uri path: '@uri'
29
29
  end
30
- t.open_data_commons_human :path => '/use/human[@type=\'openDataCommons\']'
30
+ t.open_data_commons_human path: '/use/human[@type=\'openDataCommons\']'
31
31
  end
32
32
 
33
33
  def self.xml_template
34
34
  Nokogiri::XML::Builder.new do |xml|
35
- xml.rightsMetadata {
36
- xml.access(:type => 'discover') {
35
+ xml.rightsMetadata do
36
+ xml.access(type: 'discover') do
37
37
  xml.machine { xml.none }
38
- }
39
- xml.access(:type => 'read') {
38
+ end
39
+ xml.access(type: 'read') do
40
40
  xml.machine { xml.none } # dark default
41
- }
42
- xml.use {
43
- xml.human(:type => 'useAndReproduction')
44
- xml.human(:type => 'creativeCommons')
45
- xml.machine(:type => 'creativeCommons', :uri => '')
46
- xml.human(:type => 'openDataCommons')
47
- xml.machine(:type => 'openDataCommons', :uri => '')
48
- }
41
+ end
42
+ xml.use do
43
+ xml.human(type: 'useAndReproduction')
44
+ xml.human(type: 'creativeCommons')
45
+ xml.machine(type: 'creativeCommons', uri: '')
46
+ xml.human(type: 'openDataCommons')
47
+ xml.machine(type: 'openDataCommons', uri: '')
48
+ end
49
49
  xml.copyright { xml.human }
50
- }
50
+ end
51
51
  end.doc
52
52
  end
53
53
 
@@ -186,7 +186,7 @@ module Dor
186
186
 
187
187
  # these two values are returned by index_elements[:primary], but are just a less granular version of
188
188
  # what the other more specific fields return, so discard them
189
- solr_doc['rights_descriptions_ssim'] -= ['access_restricted', 'access_restricted_qualified', 'world_qualified']
189
+ solr_doc['rights_descriptions_ssim'] -= %w[access_restricted access_restricted_qualified world_qualified]
190
190
  solr_doc['rights_descriptions_ssim'] += ['dark (file)'] if dra.index_elements[:terms].include? 'none_read_file'
191
191
 
192
192
  solr_doc['obj_rights_locations_ssim'] = dra.index_elements[:obj_locations] unless dra.index_elements[:obj_locations].blank?
@@ -5,27 +5,27 @@ module Dor
5
5
  include SolrDocHelper
6
6
 
7
7
  set_terminology do |t|
8
- t.root :path => 'roleMetadata'
8
+ t.root path: 'roleMetadata'
9
9
 
10
10
  t.actor do
11
11
  t.identifier do
12
- t.type_ :path => { :attribute => 'type' }
12
+ t.type_ path: { attribute: 'type' }
13
13
  end
14
14
  t.name
15
15
  end
16
- t.person :ref => [:actor], :path => 'person'
17
- t.group :ref => [:actor], :path => 'group'
16
+ t.person ref: [:actor], path: 'person'
17
+ t.group ref: [:actor], path: 'group'
18
18
 
19
19
  t.role do
20
- t.type_ :path => { :attribute => 'type' }
21
- t.person :ref => [:person]
22
- t.group :ref => [:group]
20
+ t.type_ path: { attribute: 'type' }
21
+ t.person ref: [:person]
22
+ t.group ref: [:group]
23
23
  end
24
24
 
25
- t.manager :ref => [:role], :attributes => { :type => 'manager' }
26
- t.depositor :ref => [:role], :attributes => { :type => 'depositor' }
27
- t.reviewer :ref => [:role], :attributes => { :type => 'reviewer' }
28
- t.viewer :ref => [:role], :attributes => { :type => 'viewer' }
25
+ t.manager ref: [:role], attributes: { type: 'manager' }
26
+ t.depositor ref: [:role], attributes: { type: 'depositor' }
27
+ t.reviewer ref: [:role], attributes: { type: 'reviewer' }
28
+ t.viewer ref: [:role], attributes: { type: 'viewer' }
29
29
  end
30
30
 
31
31
  def self.xml_template
@@ -34,19 +34,65 @@ module Dor
34
34
  end.doc
35
35
  end
36
36
 
37
- def to_solr(solr_doc = {}, *args)
37
+ def to_solr(solr_doc = {}, *_args)
38
38
  find_by_xpath('/roleMetadata/role/*').each do |actor|
39
39
  role_type = actor.parent['type']
40
40
  val = [actor.at_xpath('identifier/@type'), actor.at_xpath('identifier/text()')].join ':'
41
41
  add_solr_value(solr_doc, "apo_role_#{actor.name}_#{role_type}", val, :string, [:symbol])
42
42
  add_solr_value(solr_doc, "apo_role_#{role_type}", val, :string, [:symbol])
43
- if ['dor-apo-manager', 'dor-apo-depositor'].include? role_type
44
- add_solr_value(solr_doc, 'apo_register_permissions', val, :string, [:symbol, :stored_searchable])
45
- end
43
+ add_solr_value(solr_doc, 'apo_register_permissions', val, :string, %i[symbol stored_searchable]) if ['dor-apo-manager', 'dor-apo-depositor'].include? role_type
46
44
  end
47
45
  solr_doc
48
46
  end
49
47
 
48
+ # Adds a person or group to a role in the APO role metadata datastream
49
+ #
50
+ # @param role [String] the role the group or person will be filed under, ex. dor-apo-manager
51
+ # @param entity [String] the name of the person or group, ex dlss:developers or sunetid:someone
52
+ # @param type [Symbol] :workgroup for a group or :person for a person
53
+ def add_roleplayer(role, entity, type = :workgroup)
54
+ xml = ng_xml
55
+ ng_xml_will_change!
56
+ group = type == :workgroup ? 'group' : 'person'
57
+ nodes = xml.search('/roleMetadata/role[@type=\'' + role + '\']')
58
+ if nodes.length > 0
59
+ group_node = Nokogiri::XML::Node.new(group, xml)
60
+ id_node = Nokogiri::XML::Node.new('identifier', xml)
61
+ group_node.add_child(id_node)
62
+ id_node.content = entity
63
+ id_node['type'] = type.to_s
64
+ nodes.first.add_child(group_node)
65
+ else
66
+ node = Nokogiri::XML::Node.new('role', xml)
67
+ node['type'] = role
68
+ group_node = Nokogiri::XML::Node.new(group, xml)
69
+ node.add_child group_node
70
+ id_node = Nokogiri::XML::Node.new('identifier', xml)
71
+ group_node.add_child(id_node)
72
+ id_node.content = entity
73
+ id_node['type'] = type.to_s
74
+ xml.search('/roleMetadata').first.add_child(node)
75
+ end
76
+ end
77
+
78
+ # remove all people groups and roles from the APO role metadata datastream
79
+ def purge_roles
80
+ ng_xml.search('/roleMetadata/role').each(&:remove)
81
+ end
82
+
83
+ # Get all roles defined in the role metadata, and the people or groups in those roles. Groups are prefixed with 'workgroup:'
84
+ # @return [Hash] role => ['person','group'] ex. {"dor-apo-manager" => ["workgroup:dlss:developers", "sunetid:lmcrae"]
85
+ def roles
86
+ {}.tap do |roles|
87
+ ng_xml.search('/roleMetadata/role').each do |role|
88
+ roles[role['type']] = []
89
+ role.search('identifier').each do |entity|
90
+ roles[role['type']] << entity['type'] + ':' + entity.text
91
+ end
92
+ end
93
+ end
94
+ end
95
+
50
96
  # maintain AF < 8 indexing behavior
51
97
  def prefix
52
98
  ''
@@ -10,9 +10,9 @@ module Dor
10
10
  namespace_prefix: 'oai_dc',
11
11
  index_as: [:not_searchable]
12
12
  )
13
- t.title(:index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
14
- t.creator(:index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
15
- t.identifier(:index_as => [:symbol, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
13
+ t.title(index_as: %i[stored_sortable stored_searchable], xmlns: 'http://purl.org/dc/elements/1.1/', namespace_prefix: 'dc')
14
+ t.creator(index_as: %i[stored_sortable stored_searchable], xmlns: 'http://purl.org/dc/elements/1.1/', namespace_prefix: 'dc')
15
+ t.identifier(index_as: %i[symbol stored_searchable], xmlns: 'http://purl.org/dc/elements/1.1/', namespace_prefix: 'dc')
16
16
  end
17
17
 
18
18
  def self.xml_template
@@ -21,7 +21,7 @@ module Dor
21
21
  'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
22
22
  'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
23
23
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
24
- 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
24
+ 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'
25
25
  )
26
26
  end
27
27
 
@@ -34,18 +34,18 @@ module Dor
34
34
 
35
35
  doc = super solr_doc, *args
36
36
 
37
- add_solr_value(doc, 'dc_title', title.first, :string, [:stored_sortable, :stored_searchable])
38
- add_solr_value(doc, 'dc_creator', creator.first, :string, [:stored_sortable, :stored_searchable])
37
+ add_solr_value(doc, 'dc_title', title.first, :string, %i[stored_sortable stored_searchable])
38
+ add_solr_value(doc, 'dc_creator', creator.first, :string, %i[stored_sortable stored_searchable])
39
39
 
40
40
  identifiers = {}
41
41
 
42
42
  identifier.each { |i| ns, val = i.split(':'); identifiers[ns] ||= val }
43
43
 
44
44
  identifiers.each do |ns, val|
45
- add_solr_value(doc, "dc_identifier_#{ns}", val, :string, [:stored_sortable, :stored_searchable])
45
+ add_solr_value(doc, "dc_identifier_#{ns}", val, :string, %i[stored_sortable stored_searchable])
46
46
  end
47
47
 
48
- return doc
48
+ doc
49
49
  rescue Exception => e
50
50
  warn "ERROR in SimpleDublinCoreDs to_solr()! #{e}"
51
51
  solr_doc
@@ -55,10 +55,10 @@ module Dor
55
55
  before_create :ensure_non_versionable
56
56
 
57
57
  set_terminology do |t|
58
- t.root(:path => 'versionMetadata')
58
+ t.root(path: 'versionMetadata')
59
59
  t.version do
60
- t.version_id :path => { :attribute => 'versionID' }
61
- t.tag :path => { :attribute => 'tag' }
60
+ t.version_id path: { attribute: 'versionID' }
61
+ t.tag path: { attribute: 'tag' }
62
62
  t.description
63
63
  end
64
64
  end
@@ -66,11 +66,11 @@ module Dor
66
66
  # Default EventsDS xml
67
67
  def self.xml_template
68
68
  builder = Nokogiri::XML::Builder.new do |xml|
69
- xml.versionMetadata {
70
- xml.version(:versionId => '1', :tag => '1.0.0') {
69
+ xml.versionMetadata do
70
+ xml.version(versionId: '1', tag: '1.0.0') do
71
71
  xml.description 'Initial Version'
72
- }
73
- }
72
+ end
73
+ end
74
74
  end
75
75
  builder.doc
76
76
  end
@@ -86,7 +86,7 @@ module Dor
86
86
  ng_xml_will_change!
87
87
  if find_by_terms(:version).size == 0
88
88
  v = ng_xml.create_element 'version',
89
- :versionId => '1', :tag => '1.0.0'
89
+ versionId: '1', tag: '1.0.0'
90
90
  d = ng_xml.create_element 'description', 'Initial Version'
91
91
  ng_xml.root['objectId'] = pid
92
92
  ng_xml.root.add_child(v)
@@ -96,10 +96,8 @@ module Dor
96
96
  current_id = current[:versionId].to_i
97
97
  current_tag = VersionTag.parse(current[:tag])
98
98
 
99
- v = ng_xml.create_element 'version', :versionId => (current_id + 1).to_s
100
- if significance && current_tag
101
- v[:tag] = current_tag.increment(significance).to_s
102
- end
99
+ v = ng_xml.create_element 'version', versionId: (current_id + 1).to_s
100
+ v[:tag] = current_tag.increment(significance).to_s if significance && current_tag
103
101
  ng_xml.root['objectId'] = pid
104
102
  ng_xml.root.add_child(v)
105
103
 
@@ -5,8 +5,8 @@ module Dor
5
5
  include SolrDocHelper
6
6
 
7
7
  set_terminology do |t|
8
- t.root(:path => 'workflow-def', :index_as => [:not_searchable])
9
- t.process(:index_as => [:not_searchable])
8
+ t.root(path: 'workflow-def', index_as: [:not_searchable])
9
+ t.process(index_as: [:not_searchable])
10
10
  end
11
11
 
12
12
  define_template :process do |builder, workflow, attrs|
@@ -24,7 +24,7 @@ module Dor
24
24
  repo = nil
25
25
  wf = nil
26
26
  end
27
- attrs = (repo.nil? && wf.nil?) ? {} : { :repository => repo, :workflow => wf }
27
+ attrs = repo.nil? && wf.nil? ? {} : { repository: repo, workflow: wf }
28
28
  node.prereq(attrs) { node.text prereq_name }
29
29
  end
30
30
  end
@@ -59,7 +59,7 @@ module Dor
59
59
  doc = Nokogiri::XML('<workflow/>')
60
60
  root = doc.root
61
61
  root['id'] = name
62
- processes.each { |proc|
62
+ processes.each do |proc|
63
63
  doc.create_element 'process' do |node|
64
64
  node['name'] = proc.name
65
65
  if proc.status
@@ -71,8 +71,8 @@ module Dor
71
71
  node['lifecycle'] = proc.lifecycle if proc.lifecycle
72
72
  root.add_child node
73
73
  end
74
- }
75
- Nokogiri::XML(doc.to_xml) { |x| x.noblanks }.to_xml { |config| config.no_declaration }
74
+ end
75
+ Nokogiri::XML(doc.to_xml, &:noblanks).to_xml(&:no_declaration)
76
76
  end
77
77
 
78
78
  def to_solr(solr_doc = {}, *args)
@@ -5,18 +5,18 @@ module Dor
5
5
  class WorkflowDs < ActiveFedora::OmDatastream
6
6
  before_save :build_location
7
7
  set_terminology do |t|
8
- t.root(:path => 'workflows')
9
- t.workflow {
10
- t.workflowId(:path => { :attribute => 'id' })
11
- t.process {
12
- t.name_(:path => { :attribute => 'name' }, :index_as => [:displayable, :not_searchable])
13
- t.status(:path => { :attribute => 'status' }, :index_as => [:displayable, :not_searchable])
14
- t.timestamp(:path => { :attribute => 'datetime' }, :index_as => [:displayable, :not_searchable]) # , :data_type => :date)
15
- t.elapsed(:path => { :attribute => 'elapsed' }, :index_as => [:displayable, :not_searchable])
16
- t.lifecycle(:path => { :attribute => 'lifecycle' }, :index_as => [:displayable, :not_searchable])
17
- t.attempts(:path => { :attribute => 'attempts' }, :index_as => [:displayable, :not_searchable])
18
- }
19
- }
8
+ t.root(path: 'workflows')
9
+ t.workflow do
10
+ t.workflowId(path: { attribute: 'id' })
11
+ t.process do
12
+ t.name_(path: { attribute: 'name' }, index_as: %i[displayable not_searchable])
13
+ t.status(path: { attribute: 'status' }, index_as: %i[displayable not_searchable])
14
+ t.timestamp(path: { attribute: 'datetime' }, index_as: %i[displayable not_searchable]) # , :data_type => :date)
15
+ t.elapsed(path: { attribute: 'elapsed' }, index_as: %i[displayable not_searchable])
16
+ t.lifecycle(path: { attribute: 'lifecycle' }, index_as: %i[displayable not_searchable])
17
+ t.attempts(path: { attribute: 'attempts' }, index_as: %i[displayable not_searchable])
18
+ end
19
+ end
20
20
  end
21
21
 
22
22
  # Called before saving, but after a pid has been assigned
@@ -39,7 +39,7 @@ module Dor
39
39
  Workflow::Document.new(xml.to_s)
40
40
  end
41
41
 
42
- alias :[] :get_workflow
42
+ alias [] get_workflow
43
43
 
44
44
  def ng_xml
45
45
  @ng_xml ||= Nokogiri::XML::Document.parse(content)
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Dor
4
4
  class Exception < ::StandardError; end
5
- class ParameterError < Exception; end
6
- class DuplicateIdError < Exception
5
+ class ParameterError < RuntimeError; end
6
+ class DuplicateIdError < RuntimeError
7
7
  attr_reader :pid
8
8
 
9
9
  def initialize(pid)