dor-services 6.0.0 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dor-services.rb +7 -6
  3. data/lib/dor/certificate_authenticated_rest_resource_factory.rb +2 -1
  4. data/lib/dor/config.rb +38 -37
  5. data/lib/dor/datastreams/administrative_metadata_ds.rb +98 -98
  6. data/lib/dor/datastreams/content_metadata_ds.rb +26 -17
  7. data/lib/dor/datastreams/datastream_spec_solrizer.rb +4 -2
  8. data/lib/dor/datastreams/default_object_rights_ds.rb +10 -7
  9. data/lib/dor/datastreams/desc_metadata_ds.rb +6 -6
  10. data/lib/dor/datastreams/embargo_metadata_ds.rb +94 -94
  11. data/lib/dor/datastreams/events_ds.rb +55 -54
  12. data/lib/dor/datastreams/geo_metadata_ds.rb +7 -6
  13. data/lib/dor/datastreams/identity_metadata_ds.rb +128 -125
  14. data/lib/dor/datastreams/provenance_metadata_ds.rb +3 -1
  15. data/lib/dor/datastreams/rights_metadata_ds.rb +4 -4
  16. data/lib/dor/datastreams/role_metadata_ds.rb +42 -42
  17. data/lib/dor/datastreams/simple_dublin_core_ds.rb +45 -43
  18. data/lib/dor/datastreams/technical_metadata_ds.rb +3 -1
  19. data/lib/dor/datastreams/version_metadata_ds.rb +12 -5
  20. data/lib/dor/datastreams/workflow_definition_ds.rb +74 -73
  21. data/lib/dor/datastreams/workflow_ds.rb +12 -7
  22. data/lib/dor/exceptions.rb +2 -0
  23. data/lib/dor/indexers/data_indexer.rb +16 -0
  24. data/lib/dor/indexers/describable_indexer.rb +2 -0
  25. data/lib/dor/indexers/editable_indexer.rb +2 -0
  26. data/lib/dor/indexers/identifiable_indexer.rb +23 -8
  27. data/lib/dor/indexers/processable_indexer.rb +2 -0
  28. data/lib/dor/indexers/releasable_indexer.rb +2 -0
  29. data/lib/dor/models/abstract.rb +2 -0
  30. data/lib/dor/models/admin_policy_object.rb +2 -0
  31. data/lib/dor/models/agreement.rb +2 -0
  32. data/lib/dor/models/collection.rb +3 -0
  33. data/lib/dor/models/concerns/assembleable.rb +2 -0
  34. data/lib/dor/models/concerns/contentable.rb +5 -2
  35. data/lib/dor/models/concerns/describable.rb +7 -2
  36. data/lib/dor/models/concerns/editable.rb +28 -21
  37. data/lib/dor/models/concerns/embargoable.rb +4 -0
  38. data/lib/dor/models/concerns/eventable.rb +2 -0
  39. data/lib/dor/models/concerns/geoable.rb +2 -0
  40. data/lib/dor/models/concerns/governable.rb +7 -2
  41. data/lib/dor/models/concerns/identifiable.rb +33 -34
  42. data/lib/dor/models/concerns/itemizable.rb +4 -1
  43. data/lib/dor/models/concerns/preservable.rb +2 -0
  44. data/lib/dor/models/concerns/processable.rb +15 -9
  45. data/lib/dor/models/concerns/publishable.rb +9 -4
  46. data/lib/dor/models/concerns/releaseable.rb +21 -11
  47. data/lib/dor/models/concerns/rightsable.rb +2 -0
  48. data/lib/dor/models/concerns/shelvable.rb +6 -2
  49. data/lib/dor/models/concerns/versionable.rb +8 -4
  50. data/lib/dor/models/item.rb +2 -0
  51. data/lib/dor/models/set.rb +2 -0
  52. data/lib/dor/models/workflow_object.rb +5 -1
  53. data/lib/dor/rest_resource_factory.rb +2 -0
  54. data/lib/dor/services/cleanup_reset_service.rb +2 -1
  55. data/lib/dor/services/cleanup_service.rb +2 -1
  56. data/lib/dor/services/digital_stacks_service.rb +3 -1
  57. data/lib/dor/services/indexing_service.rb +3 -1
  58. data/lib/dor/services/merge_service.rb +6 -4
  59. data/lib/dor/services/metadata_handlers/catalog_handler.rb +2 -0
  60. data/lib/dor/services/metadata_service.rb +4 -4
  61. data/lib/dor/services/public_desc_metadata_service.rb +16 -8
  62. data/lib/dor/services/public_xml_service.rb +7 -4
  63. data/lib/dor/services/registration_service.rb +25 -20
  64. data/lib/dor/services/reset_workspace_service.rb +4 -4
  65. data/lib/dor/services/sdr_ingest_service.rb +4 -2
  66. data/lib/dor/services/search_service.rb +8 -9
  67. data/lib/dor/services/suri_service.rb +3 -2
  68. data/lib/dor/services/technical_metadata_service.rb +15 -9
  69. data/lib/dor/services/thumbnail_service.rb +14 -10
  70. data/lib/dor/utils/hydrus_shims.rb +2 -0
  71. data/lib/dor/utils/ng_tidy.rb +3 -7
  72. data/lib/dor/utils/predicate_patch.rb +2 -0
  73. data/lib/dor/utils/sdr_client.rb +3 -0
  74. data/lib/dor/utils/solr_doc_helper.rb +4 -2
  75. data/lib/dor/version.rb +3 -1
  76. data/lib/dor/workflow/document.rb +113 -108
  77. data/lib/dor/workflow/process.rb +90 -87
  78. data/lib/tasks/rdoc.rake +4 -3
  79. metadata +4 -4
@@ -1,139 +1,142 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dor
2
- class IdentityMetadataDS < ActiveFedora::OmDatastream
3
- include SolrDocHelper
4
-
5
- set_terminology do |t|
6
- t.root(:path => 'identityMetadata')
7
- t.objectId :index_as => [:symbol]
8
- t.objectType :index_as => [:symbol]
9
- t.objectLabel
10
- t.citationCreator
11
- t.sourceId
12
- t.otherId(:path => 'otherId') do
13
- t.name_(:path => { :attribute => 'name' })
4
+ class IdentityMetadataDS < ActiveFedora::OmDatastream
5
+ include SolrDocHelper
6
+
7
+ set_terminology do |t|
8
+ t.root(:path => 'identityMetadata')
9
+ t.objectId :index_as => [:symbol]
10
+ t.objectType :index_as => [:symbol]
11
+ t.objectLabel
12
+ t.citationCreator
13
+ t.sourceId
14
+ t.otherId(:path => 'otherId') do
15
+ t.name_(:path => { :attribute => 'name' })
16
+ end
17
+ t.agreementId :index_as => [:stored_searchable, :symbol]
18
+ t.tag :index_as => [:symbol]
19
+ t.citationTitle
20
+ t.objectCreator :index_as => [:stored_searchable, :symbol]
21
+ t.adminPolicy :index_as => [:not_searchable]
22
+ end
23
+
24
+ define_template :value do |builder, name, value, attrs|
25
+ builder.send(name.to_sym, value, attrs)
26
+ end
27
+
28
+ def self.xml_template
29
+ Nokogiri::XML('<identityMetadata/>')
14
30
  end
15
- t.agreementId :index_as => [:stored_searchable, :symbol]
16
- t.tag :index_as => [:symbol]
17
- t.citationTitle
18
- t.objectCreator :index_as => [:stored_searchable, :symbol]
19
- t.adminPolicy :index_as => [:not_searchable]
20
- end
21
-
22
- define_template :value do |builder, name, value, attrs|
23
- builder.send(name.to_sym, value, attrs)
24
- end
25
-
26
- def self.xml_template
27
- Nokogiri::XML('<identityMetadata/>')
28
- end
29
-
30
- def add_value(name, value, attrs = {})
31
- ng_xml_will_change!
32
- add_child_node(ng_xml.root, :value, name, value, attrs)
33
- end
34
-
35
- def objectId
36
- find_by_terms(:objectId).text
37
- end
38
-
39
- def sourceId
40
- node = find_by_terms(:sourceId).first
41
- node ? [node['source'], node.text].join(':') : nil
42
- end
43
-
44
- # @param [String, Nil] value, or nil/empty string to delete sourceId node
45
- # @return [String, Nil] The same value, as per Ruby convention for assignment operators
46
- # @note The actual values assigned will have leading/trailing whitespace stripped.
47
- def sourceId=(value)
48
- ng_xml_will_change!
49
- node = find_by_terms(:sourceId).first
50
- unless value.present? # so setting it to '' is the same as removal: worth documenting maybe?
51
- node.remove unless node.nil?
52
- return nil
31
+
32
+ def add_value(name, value, attrs = {})
33
+ ng_xml_will_change!
34
+ add_child_node(ng_xml.root, :value, name, value, attrs)
53
35
  end
54
- parts = value.split(':', 2).map(&:strip)
55
- raise ArgumentError, "Source ID must follow the format 'namespace:value', not '#{value}'" unless
56
- parts.length == 2 && parts[0].present? && parts[1].present?
57
- node ||= ng_xml.root.add_child('<sourceId/>').first
58
- node['source'] = parts[0]
59
- node.content = parts[1]
60
- end
61
-
62
- def tags
63
- ng_xml.search('//tag').collect(&:content)
64
- end
65
-
66
- def otherId(type = nil)
67
- result = find_by_terms(:otherId).to_a
68
- if type.nil?
69
- result.collect { |n| [n['name'], n.text].join(':') }
70
- else
71
- result.select { |n| n['name'] == type }.collect { |n| n.text }
36
+
37
+ def objectId
38
+ find_by_terms(:objectId).text
39
+ end
40
+
41
+ def sourceId
42
+ node = find_by_terms(:sourceId).first
43
+ node ? [node['source'], node.text].join(':') : nil
72
44
  end
73
- end
74
-
75
- def add_otherId(other_id)
76
- ng_xml_will_change!
77
- (name, val) = other_id.split(/:/, 2)
78
- node = ng_xml.root.add_child('<otherId/>').first
79
- node['name'] = name
80
- node.content = val
81
- node
82
- end
83
-
84
- def to_solr(solr_doc = {}, *args)
85
- solr_doc = super(solr_doc, *args)
86
-
87
- if digital_object.respond_to?(:profile)
88
- digital_object.profile.each_pair do |property, value|
89
- add_solr_value(solr_doc, property.underscore, value, (property =~ /Date/ ? :date : :symbol), [:stored_searchable])
45
+
46
+ # @param [String, Nil] value, or nil/empty string to delete sourceId node
47
+ # @return [String, Nil] The same value, as per Ruby convention for assignment operators
48
+ # @note The actual values assigned will have leading/trailing whitespace stripped.
49
+ def sourceId=(value)
50
+ ng_xml_will_change!
51
+ node = find_by_terms(:sourceId).first
52
+ unless value.present? # so setting it to '' is the same as removal: worth documenting maybe?
53
+ node&.remove
54
+ return nil
90
55
  end
56
+ parts = value.split(':', 2).map(&:strip)
57
+ raise ArgumentError, "Source ID must follow the format 'namespace:value', not '#{value}'" unless
58
+ parts.length == 2 && parts[0].present? && parts[1].present?
59
+
60
+ node ||= ng_xml.root.add_child('<sourceId/>').first
61
+ node['source'] = parts[0]
62
+ node.content = parts[1]
91
63
  end
92
64
 
93
- if sourceId.present?
94
- (name, id) = sourceId.split(/:/, 2)
95
- add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
96
- add_solr_value(solr_doc, 'identifier', sourceId, :symbol, [:stored_searchable])
97
- add_solr_value(solr_doc, 'source_id', sourceId, :symbol, [])
65
+ def tags
66
+ ng_xml.search('//tag').collect(&:content)
98
67
  end
99
- otherId.compact.each { |qid|
100
- # this section will solrize barcode and catkey, which live in otherId
101
- (name, id) = qid.split(/:/, 2)
102
- add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
103
- add_solr_value(solr_doc, 'identifier', qid, :symbol, [:stored_searchable])
104
- add_solr_value(solr_doc, "#{name}_id", id, :symbol, [])
105
- }
106
-
107
- # do some stuff to make tags in general and project tags specifically more easily searchable and facetable
108
- find_by_terms(:tag).each { |tag|
109
- (prefix, rest) = tag.text.split(/:/, 2)
110
- prefix = prefix.downcase.strip.gsub(/\s/, '_')
111
- unless rest.nil?
112
- # this part will index a value in a field specific to the tag, e.g. registered_by_tag_*,
113
- # book_tag_*, project_tag_*, remediated_by_tag_*, etc. project_tag_* and registered_by_tag_*
114
- # definitley get used, but most don't. we can limit the prefixes that get solrized if things
115
- # get out of hand.
116
- add_solr_value(solr_doc, "#{prefix}_tag", rest.strip, :symbol, [])
68
+
69
+ def otherId(type = nil)
70
+ result = find_by_terms(:otherId).to_a
71
+ if type.nil?
72
+ result.collect { |n| [n['name'], n.text].join(':') }
73
+ else
74
+ result.select { |n| n['name'] == type }.collect { |n| n.text }
117
75
  end
76
+ end
77
+
78
+ def add_otherId(other_id)
79
+ ng_xml_will_change!
80
+ (name, val) = other_id.split(/:/, 2)
81
+ node = ng_xml.root.add_child('<otherId/>').first
82
+ node['name'] = name
83
+ node.content = val
84
+ node
85
+ end
86
+
87
+ def to_solr(solr_doc = {}, *args)
88
+ solr_doc = super(solr_doc, *args)
118
89
 
119
- # solrize each possible prefix for the tag, inclusive of the full tag.
120
- # e.g., for a tag such as "A : B : C", this will solrize to an _ssim field
121
- # that contains ["A", "A : B", "A : B : C"].
122
- tag_parts = tag.text.split(/:/)
123
- progressive_tag_prefix = ''
124
- tag_parts.each_with_index do |part, index|
125
- progressive_tag_prefix += ' : ' if index > 0
126
- progressive_tag_prefix += part.strip
127
- add_solr_value(solr_doc, 'exploded_tag', progressive_tag_prefix, :symbol, [])
90
+ if digital_object.respond_to?(:profile)
91
+ digital_object.profile.each_pair do |property, value|
92
+ add_solr_value(solr_doc, property.underscore, value, (property =~ /Date/ ? :date : :symbol), [:stored_searchable])
93
+ end
128
94
  end
129
- }
130
95
 
131
- solr_doc
132
- end
96
+ if sourceId.present?
97
+ (name, id) = sourceId.split(/:/, 2)
98
+ add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
99
+ add_solr_value(solr_doc, 'identifier', sourceId, :symbol, [:stored_searchable])
100
+ add_solr_value(solr_doc, 'source_id', sourceId, :symbol, [])
101
+ end
102
+ otherId.compact.each { |qid|
103
+ # this section will solrize barcode and catkey, which live in otherId
104
+ (name, id) = qid.split(/:/, 2)
105
+ add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
106
+ add_solr_value(solr_doc, 'identifier', qid, :symbol, [:stored_searchable])
107
+ add_solr_value(solr_doc, "#{name}_id", id, :symbol, [])
108
+ }
109
+
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|
112
+ (prefix, rest) = tag.text.split(/:/, 2)
113
+ prefix = prefix.downcase.strip.gsub(/\s/, '_')
114
+ unless rest.nil?
115
+ # this part will index a value in a field specific to the tag, e.g. registered_by_tag_*,
116
+ # book_tag_*, project_tag_*, remediated_by_tag_*, etc. project_tag_* and registered_by_tag_*
117
+ # definitley get used, but most don't. we can limit the prefixes that get solrized if things
118
+ # get out of hand.
119
+ add_solr_value(solr_doc, "#{prefix}_tag", rest.strip, :symbol, [])
120
+ end
121
+
122
+ # solrize each possible prefix for the tag, inclusive of the full tag.
123
+ # e.g., for a tag such as "A : B : C", this will solrize to an _ssim field
124
+ # that contains ["A", "A : B", "A : B : C"].
125
+ tag_parts = tag.text.split(/:/)
126
+ progressive_tag_prefix = ''
127
+ tag_parts.each_with_index do |part, index|
128
+ progressive_tag_prefix += ' : ' if index > 0
129
+ progressive_tag_prefix += part.strip
130
+ add_solr_value(solr_doc, 'exploded_tag', progressive_tag_prefix, :symbol, [])
131
+ end
132
+ }
133
+
134
+ solr_doc
135
+ end
133
136
 
134
- # maintain AF < 8 indexing behavior
135
- def prefix
136
- ''
137
- end
138
- end # class
137
+ # maintain AF < 8 indexing behavior
138
+ def prefix
139
+ ''
140
+ end
141
+ end # class
139
142
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dor
2
4
  # Represents the Fedora 3 datastream that hold provenance metadata
3
5
  class ProvenanceMetadataDS < ActiveFedora::OmDatastream
4
6
  # This provides the prefix for the solr fields generated by ActiveFedora.
5
7
  # Since we don't want a prefix, we override this to return an empty string.
6
8
  def prefix
7
- ''.freeze
9
+ ''
8
10
  end
9
11
  end
10
12
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dor
2
4
  class RightsMetadataDS < ActiveFedora::OmDatastream
3
5
  require 'dor/rights_auth'
@@ -35,7 +37,7 @@ module Dor
35
37
  xml.machine { xml.none }
36
38
  }
37
39
  xml.access(:type => 'read') {
38
- xml.machine { xml.none } # dark default
40
+ xml.machine { xml.none } # dark default
39
41
  }
40
42
  xml.use {
41
43
  xml.human(:type => 'useAndReproduction')
@@ -64,7 +66,6 @@ module Dor
64
66
  'none' => 'Citation Only'
65
67
  }.freeze
66
68
 
67
-
68
69
  # just a wrapper to invalidate @dra_object
69
70
  def content=(xml)
70
71
  @dra_object = nil
@@ -112,7 +113,7 @@ module Dor
112
113
  loc_node = Nokogiri::XML::Node.new('location', rights_xml)
113
114
  loc_node.content = rights_type.split(':').last
114
115
  machine_node.add_child(loc_node)
115
- else # we know it is none or dark by the argument filter (first line)
116
+ else # we know it is none or dark by the argument filter (first line)
116
117
  machine_node.add_child Nokogiri::XML::Node.new('none', rights_xml)
117
118
  end
118
119
  end
@@ -215,6 +216,5 @@ module Dor
215
216
  def prefix
216
217
  ''
217
218
  end
218
-
219
219
  end # class
220
220
  end
@@ -1,55 +1,55 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dor
2
- class RoleMetadataDS < ActiveFedora::OmDatastream
3
- include SolrDocHelper
4
+ class RoleMetadataDS < ActiveFedora::OmDatastream
5
+ include SolrDocHelper
4
6
 
5
- set_terminology do |t|
6
- t.root :path => 'roleMetadata'
7
+ set_terminology do |t|
8
+ t.root :path => 'roleMetadata'
7
9
 
8
- t.actor do
9
- t.identifier do
10
- t.type_ :path => {:attribute => 'type'}
10
+ t.actor do
11
+ t.identifier do
12
+ t.type_ :path => { :attribute => 'type' }
13
+ end
14
+ t.name
11
15
  end
12
- t.name
13
- end
14
- t.person :ref => [:actor], :path => 'person'
15
- t.group :ref => [:actor], :path => 'group'
16
+ t.person :ref => [:actor], :path => 'person'
17
+ t.group :ref => [:actor], :path => 'group'
16
18
 
17
- t.role do
18
- t.type_ :path => {:attribute => 'type'}
19
- t.person :ref => [:person]
20
- t.group :ref => [:group]
21
- end
19
+ t.role do
20
+ t.type_ :path => { :attribute => 'type' }
21
+ t.person :ref => [:person]
22
+ t.group :ref => [:group]
23
+ end
22
24
 
23
- t.manager :ref => [:role], :attributes => {:type => 'manager'}
24
- t.depositor :ref => [:role], :attributes => {:type => 'depositor'}
25
- t.reviewer :ref => [:role], :attributes => {:type => 'reviewer'}
26
- t.viewer :ref => [:role], :attributes => {:type => 'viewer'}
27
- end
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
+ end
28
30
 
29
- def self.xml_template
30
- Nokogiri::XML::Builder.new do |xml|
31
- xml.roleMetadata {
32
- }
33
- end.doc
34
- end
31
+ def self.xml_template
32
+ Nokogiri::XML::Builder.new do |xml|
33
+ xml.roleMetadata {}
34
+ end.doc
35
+ end
35
36
 
36
- def to_solr(solr_doc = {}, *args)
37
- find_by_xpath('/roleMetadata/role/*').each do |actor|
38
- role_type = actor.parent['type']
39
- val = [actor.at_xpath('identifier/@type'), actor.at_xpath('identifier/text()')].join ':'
40
- add_solr_value(solr_doc, "apo_role_#{actor.name}_#{role_type}", val, :string, [:symbol])
41
- add_solr_value(solr_doc, "apo_role_#{role_type}", val, :string, [:symbol])
42
- if ['dor-apo-manager', 'dor-apo-depositor'].include? role_type
43
- add_solr_value(solr_doc, 'apo_register_permissions', val, :string, [:symbol, :stored_searchable])
37
+ def to_solr(solr_doc = {}, *args)
38
+ find_by_xpath('/roleMetadata/role/*').each do |actor|
39
+ role_type = actor.parent['type']
40
+ val = [actor.at_xpath('identifier/@type'), actor.at_xpath('identifier/text()')].join ':'
41
+ add_solr_value(solr_doc, "apo_role_#{actor.name}_#{role_type}", val, :string, [:symbol])
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
44
46
  end
47
+ solr_doc
45
48
  end
46
- solr_doc
47
- end
48
49
 
49
- # maintain AF < 8 indexing behavior
50
- def prefix
51
- ''
50
+ # maintain AF < 8 indexing behavior
51
+ def prefix
52
+ ''
53
+ end
52
54
  end
53
-
54
- end
55
55
  end
@@ -1,57 +1,59 @@
1
- module Dor
2
- class SimpleDublinCoreDs < ActiveFedora::OmDatastream
3
-
4
- set_terminology do |t|
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])
11
- t.title( :index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
12
- t.creator( :index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
13
- t.identifier(:index_as => [:symbol, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
14
- end
1
+ # frozen_string_literal: true
15
2
 
16
- def self.xml_template
17
- builder = Nokogiri::XML::Builder.new do |xml|
18
- xml['oai_dc'].dc(
19
- 'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
20
- 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
21
- 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
22
- 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
3
+ module Dor
4
+ class SimpleDublinCoreDs < ActiveFedora::OmDatastream
5
+ set_terminology do |t|
6
+ t.root(
7
+ path: 'dc',
8
+ xmlns: 'http://www.openarchives.org/OAI/2.0/oai_dc/',
9
+ schema: 'http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd',
10
+ namespace_prefix: 'oai_dc',
11
+ index_as: [:not_searchable]
23
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')
24
16
  end
25
17
 
26
- builder.doc
27
- end
18
+ def self.xml_template
19
+ builder = Nokogiri::XML::Builder.new do |xml|
20
+ xml['oai_dc'].dc(
21
+ 'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
22
+ 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
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',
25
+ )
26
+ end
27
+
28
+ builder.doc
29
+ end
28
30
 
29
- def to_solr(solr_doc = {}, *args)
30
- # There are a whole bunch of namespace-related things that can go
31
- # wrong with this terminology. Until it's fixed in OM, ignore them all.
31
+ def to_solr(solr_doc = {}, *args)
32
+ # There are a whole bunch of namespace-related things that can go
33
+ # wrong with this terminology. Until it's fixed in OM, ignore them all.
32
34
 
33
- doc = super solr_doc, *args
35
+ doc = super solr_doc, *args
34
36
 
35
- add_solr_value(doc, 'dc_title', title.first, :string, [:stored_sortable, :stored_searchable])
36
- add_solr_value(doc, 'dc_creator', creator.first, :string, [:stored_sortable, :stored_searchable])
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
39
 
38
- identifiers = {}
40
+ identifiers = {}
39
41
 
40
- identifier.each { |i| ns, val = i.split(':'); identifiers[ns] ||= val }
42
+ identifier.each { |i| ns, val = i.split(':'); identifiers[ns] ||= val }
41
43
 
42
- identifiers.each do |ns, val|
43
- add_solr_value(doc, "dc_identifier_#{ns}", val, :string, [:stored_sortable, :stored_searchable])
44
- end
44
+ identifiers.each do |ns, val|
45
+ add_solr_value(doc, "dc_identifier_#{ns}", val, :string, [:stored_sortable, :stored_searchable])
46
+ end
45
47
 
46
- return doc
47
- rescue Exception => e
48
- warn "ERROR in SimpleDublinCoreDs to_solr()! #{e}"
49
- solr_doc
50
- end
48
+ return doc
49
+ rescue Exception => e
50
+ warn "ERROR in SimpleDublinCoreDs to_solr()! #{e}"
51
+ solr_doc
52
+ end
51
53
 
52
- # maintain AF < 8 indexing behavior
53
- def prefix
54
- ''
54
+ # maintain AF < 8 indexing behavior
55
+ def prefix
56
+ ''
57
+ end
55
58
  end
56
59
  end
57
- end