dor-services 2.2.4 → 4.4.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +15 -0
  2. data/bin/dor-indexer +108 -0
  3. data/bin/dor-indexerd +73 -0
  4. data/bin/nokogiri +19 -0
  5. data/bin/rake +19 -0
  6. data/bin/ruby_noexec_wrapper +14 -0
  7. data/bin/solrizer +19 -0
  8. data/bin/solrizerd +19 -0
  9. data/config/certs/README +1 -0
  10. data/config/config_defaults.yml +62 -0
  11. data/config/dev_console_env.rb.example +67 -0
  12. data/config/predicate_mappings.yml +55 -0
  13. data/lib/dor-services.rb +152 -19
  14. data/lib/dor/config.rb +133 -35
  15. data/lib/dor/datastreams/administrative_metadata_ds.rb +84 -0
  16. data/lib/dor/datastreams/content_metadata_ds.rb +337 -0
  17. data/lib/dor/datastreams/datastream_spec_solrizer.rb +18 -0
  18. data/lib/dor/datastreams/default_object_rights_ds.rb +52 -0
  19. data/lib/dor/datastreams/desc_metadata_ds.rb +39 -0
  20. data/lib/{datastreams → dor/datastreams}/embargo_metadata_ds.rb +25 -20
  21. data/lib/{datastreams → dor/datastreams}/events_ds.rb +14 -9
  22. data/lib/dor/datastreams/identity.xsl +8 -0
  23. data/lib/dor/datastreams/identity_metadata_ds.rb +112 -0
  24. data/lib/dor/datastreams/role_metadata_ds.rb +51 -0
  25. data/lib/dor/datastreams/simple_dublin_core_ds.rb +45 -0
  26. data/lib/dor/datastreams/version_metadata_ds.rb +214 -0
  27. data/lib/dor/datastreams/workflow_definition_ds.rb +113 -0
  28. data/lib/dor/datastreams/workflow_ds.rb +103 -0
  29. data/lib/dor/exceptions.rb +0 -1
  30. data/lib/dor/migrations/content_metadata_ds/change_content_type.rb +7 -0
  31. data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +9 -0
  32. data/lib/dor/migrations/identifiable/fix_model_assertions.rb +13 -0
  33. data/lib/dor/migrations/identifiable/record_remediation.rb +18 -0
  34. data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +18 -0
  35. data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +18 -0
  36. data/lib/dor/migrations/processable/unify_workflows.rb +17 -0
  37. data/lib/dor/migrations/versionable/add_missing_version_md.rb +9 -0
  38. data/lib/dor/models/admin_policy_object.rb +16 -0
  39. data/lib/dor/models/assembleable.rb +14 -0
  40. data/lib/dor/models/collection.rb +14 -0
  41. data/lib/dor/models/contentable.rb +227 -0
  42. data/lib/dor/models/describable.rb +194 -0
  43. data/lib/dor/models/discoverable.rb +66 -0
  44. data/lib/dor/models/editable.rb +267 -0
  45. data/lib/dor/models/embargoable.rb +97 -0
  46. data/lib/dor/models/eventable.rb +12 -0
  47. data/lib/dor/models/governable.rb +162 -0
  48. data/lib/dor/models/identifiable.rb +211 -0
  49. data/lib/dor/models/item.rb +44 -0
  50. data/lib/dor/models/itemizable.rb +66 -0
  51. data/lib/dor/{mods2dc.xslt → models/mods2dc.xslt} +39 -12
  52. data/lib/dor/models/preservable.rb +50 -0
  53. data/lib/dor/models/processable.rb +229 -0
  54. data/lib/dor/models/publishable.rb +74 -0
  55. data/lib/dor/models/set.rb +12 -0
  56. data/lib/dor/models/shelvable.rb +27 -0
  57. data/lib/dor/models/upgradable.rb +74 -0
  58. data/lib/dor/models/versionable.rb +94 -0
  59. data/lib/dor/models/workflow_object.rb +54 -0
  60. data/lib/dor/services/cleanup_service.rb +47 -0
  61. data/lib/dor/services/digital_stacks_service.rb +55 -0
  62. data/lib/dor/services/merge_service.rb +96 -0
  63. data/lib/dor/{metadata_handlers → services/metadata_handlers}/catalog_handler.rb +0 -2
  64. data/lib/dor/{metadata_handlers → services/metadata_handlers}/mdtoolkit_handler.rb +0 -2
  65. data/lib/dor/{metadata_service.rb → services/metadata_service.rb} +1 -3
  66. data/lib/dor/services/registration_service.rb +181 -0
  67. data/lib/dor/services/sdr_ingest_service.rb +181 -0
  68. data/lib/dor/services/search_service.rb +131 -0
  69. data/lib/dor/services/suri_service.rb +32 -0
  70. data/lib/dor/services/technical_metadata_service.rb +226 -0
  71. data/lib/dor/{tei2dc.xslt → services/tei2dc.xslt} +0 -0
  72. data/lib/dor/utils/ng_tidy.rb +37 -0
  73. data/lib/dor/utils/predicate_patch.rb +23 -0
  74. data/lib/dor/utils/solr_doc_helper.rb +9 -0
  75. data/lib/dor/utils/utc_date_field_mapper.rb +7 -0
  76. data/lib/dor/version.rb +3 -0
  77. data/lib/dor/workflow/document.rb +131 -0
  78. data/lib/dor/workflow/graph.rb +166 -0
  79. data/lib/dor/workflow/process.rb +99 -0
  80. data/lib/gsearch/demoFoxmlToSolr.xslt +340 -122
  81. data/lib/tasks/dor.rake +39 -0
  82. metadata +494 -384
  83. data/lib/datastreams/content_metadata_ds.rb +0 -12
  84. data/lib/datastreams/identity_metadata_ds.rb +0 -28
  85. data/lib/datastreams/ng_tidy.rb +0 -19
  86. data/lib/datastreams/simple_dublin_core_ds.rb +0 -23
  87. data/lib/datastreams/workflow_definition_ds.rb +0 -105
  88. data/lib/datastreams/workflow_ds.rb +0 -16
  89. data/lib/dor/admin_policy_object.rb +0 -11
  90. data/lib/dor/base.rb +0 -81
  91. data/lib/dor/cleanup_service.rb +0 -32
  92. data/lib/dor/digital_stacks_service.rb +0 -82
  93. data/lib/dor/druid_utils.rb +0 -41
  94. data/lib/dor/embargo.rb +0 -41
  95. data/lib/dor/item.rb +0 -141
  96. data/lib/dor/provenance_metadata_service.rb +0 -65
  97. data/lib/dor/registration_service.rb +0 -87
  98. data/lib/dor/rsolr.rb +0 -27
  99. data/lib/dor/sdr_ingest_service.rb +0 -117
  100. data/lib/dor/search_service.rb +0 -86
  101. data/lib/dor/suri_service.rb +0 -37
  102. data/lib/dor/workflow_object.rb +0 -13
  103. data/lib/dor/workflow_service.rb +0 -111
  104. data/lib/xml_models/foxml.rb +0 -261
  105. data/lib/xml_models/identity_metadata/dublin_core.rb +0 -119
  106. data/lib/xml_models/identity_metadata/identity_metadata.rb +0 -288
@@ -1,119 +0,0 @@
1
- require 'rubygems'
2
- require 'nokogiri'
3
-
4
- #<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
5
- #xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
- #xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd">
7
- # <dc:title>Life of Abraham Lincoln, sixteenth president of the United States: Containing his early
8
- #history and political career; together with the speeches, messages, proclamations and other official
9
- #documents illus. of his eventful administration</dc:title>
10
- # <dc:creator>Crosby, Frank.</dc:creator>
11
- # <dc:format>text</dc:format>
12
- # <dc:language>eng</dc:language>
13
- # <dc:subject>E457 .C94</dc:subject>
14
- # <dc:identifier>lccn:11030686</dc:identifier>
15
- # <dc:identifier>callseq:1</dc:identifier>
16
- # <dc:identifier>shelfseq:973.7111 .L731CR</dc:identifier>
17
- # <dc:identifier>catkey:1206382</dc:identifier>
18
- # <dc:identifier>barcode:36105005459602</dc:identifier>
19
- # <dc:identifier>uuid:ddcf5f1a-0331-4345-beca-e66f7db276eb</dc:identifier>
20
- # <dc:identifier>google:STANFORD_36105005459602</dc:identifier>
21
- # <dc:identifier>druid:ng786kn0371</dc:identifier>
22
- #</oai_dc:dc>
23
-
24
- # TODO: Rewrite in OM
25
-
26
- class DublinCore
27
-
28
-
29
- attr_accessor :xml
30
-
31
- attr_accessor :title
32
- attr_accessor :creator
33
- attr_accessor :subject
34
- attr_accessor :description
35
- attr_accessor :publisher
36
- attr_accessor :contributor
37
- attr_accessor :date
38
- attr_accessor :type
39
- attr_accessor :format
40
- attr_accessor :identifier
41
- attr_accessor :source
42
- attr_accessor :language
43
- attr_accessor :relation
44
- attr_accessor :coverage
45
- attr_accessor :rights
46
-
47
-
48
-
49
-
50
- def initialize(xml = nil)
51
-
52
- @title ||= []
53
- @creator ||= []
54
- @subject ||= []
55
- @description ||= []
56
- @publisher ||= []
57
- @contributor ||= []
58
- @date ||= []
59
- @type ||= []
60
- @format ||= []
61
- @identifier ||= []
62
- @source ||= []
63
- @language ||= []
64
- @relation ||= []
65
- @coverage ||= []
66
- @rights ||= []
67
-
68
- # if the new is given an xml string, store that in the xml attr_accessor and don't rebuild.
69
- # this will allow users to access the raw unprocessed XML string via @xml.
70
- if xml.nil?
71
- build_xml()
72
- else
73
- @xml = xml
74
- end
75
-
76
- end #initalize
77
-
78
-
79
- def build_xml()
80
- builder = Nokogiri::XML::Builder.new do |xml|
81
- xml.dc('xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:srw_dc' => 'info:srw/schema/1/dc-schema', "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance" ) {
82
- xml.parent.namespace = xml.parent.add_namespace_definition('oai_dc','http://www.openarchives.org/OAI/2.0/oai_dc/')
83
- xml.parent.add_namespace_definition("xsi:schemaLocation", "http://www.openarchives.org/OAI/2.0/oai_dc/ http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd")
84
- self.instance_variables.each do |var|
85
- unless var == "@xml"
86
- self.instance_variable_get(var).each { |v| xml['dc'].send("#{var.gsub('@','')}_", v) }
87
- end #unless
88
- end #instance_Variables.each
89
- }
90
- end
91
- @xml = builder.to_xml
92
- end
93
-
94
-
95
-
96
- # This method rebuilds the xml attr_accesor and returns it as a string.
97
- def to_xml
98
- build_xml
99
- return self.xml
100
- end #to_xml
101
-
102
-
103
- # This method takes DC XML as a string, and maps the root child node to their proper attr_accesor.
104
-
105
- def self.from_xml(xml="")
106
- dc = DublinCore.new(xml)
107
- doc = Nokogiri::XML(xml)
108
- children = doc.root.element_children
109
- children.each do |c|
110
- if dc.instance_variables.include?("@#{c.name}")
111
- dc.send("#{c.name}").send("<<", c.text.strip)
112
- end #if
113
- end #each
114
- return dc
115
- end #from_xml
116
-
117
-
118
-
119
- end #dublin_core
@@ -1,288 +0,0 @@
1
- require 'rubygems'
2
- require 'nokogiri'
3
- #<identityMetadata>
4
- # <objectId>druid:rt923jk342</objectId>
5
- # <objectType>item</objectType>
6
- # <objectLabel>google download barcode 36105049267078</objectLabel>
7
- # <objectCreator>DOR</objectCreator>
8
- # <citationTitle>Squirrels of North America</citationTitle>
9
- # <citationCreator>Eder, Tamara, 1974-</citationCreator>
10
- # <sourceId source="google">STANFORD_342837261527</sourceId>
11
- # <otherId name="barcode">36105049267078</otherId>
12
- # <otherId name="catkey">129483625</otherId>
13
- # <otherId name="uuid">7f3da130-7b02-11de-8a39-0800200c9a66</otherId>
14
- # <tag>Google Books : Phase 1</tag>
15
- # <tag>Google Books : Scan source STANFORD</tag>
16
- #</identityMetadata>
17
-
18
- # TODO: Rewrite in OM
19
-
20
- # this just maps the #value method to return the "text", "source", "name" values form the hash
21
- class SourceId
22
- attr_reader :source
23
- attr_reader :value
24
-
25
- def xml_values
26
- [self.value, {:source => self.source}]
27
- end
28
-
29
- def source=(val)
30
- @source = val.nil? ? nil : val.to_s
31
- end
32
-
33
- def value=(val)
34
- @value = val.nil? ? nil : val.to_s
35
- end
36
-
37
- def to_s
38
- "#{self.source}:#{self.value}"
39
- end
40
-
41
- def empty?
42
- (self.source.nil? || self.source.empty?) && (self.value.nil? || self.value.empty?)
43
- end
44
-
45
- end
46
-
47
- class OtherId
48
- attr_reader :name
49
- attr_reader :value
50
-
51
- def xml_values
52
- [self.value, {:name => self.name}]
53
- end
54
-
55
- def name=(val)
56
- @name = val.nil? ? nil : val.to_s
57
- end
58
-
59
- def value=(val)
60
- @value = val.nil? ? nil : val.to_s
61
- end
62
-
63
- def to_s
64
- "#{self.name}:#{self.value}"
65
- end
66
-
67
- def empty?
68
- (self.name.nil? || self.name.empty?) && (self.value.nil? || self.value.empty?)
69
- end
70
-
71
- end
72
-
73
- class Tag
74
- attr_accessor :value
75
-
76
- def xml_values
77
- [self.value]
78
- end
79
- end
80
-
81
-
82
- class IdentityMetadata
83
-
84
-
85
-
86
- # these are single values
87
- attr_accessor :objectId
88
- attr_reader :sourceId, :tags
89
- # these instance vars map to nodes in the identityMetadata XML
90
- attr_accessor :objectTypes, :objectLabels, :objectCreators, :citationCreators, :citationTitle,
91
- :otherIds, :adminPolicy, :agreementId
92
- # this stores the Nokogiri XML
93
- attr_reader :ng_xml
94
-
95
-
96
- def initialize(xml = nil)
97
-
98
- @objectId, @citationTitle, @adminPolicy, @agreementId = "", "", "", "" #there can only be one of these values
99
- @sourceId = SourceId.new #there can be only one.
100
- @otherIds, @tags = [], [] # this is an array that will be filled with OtherId and Tag objects
101
- @objectTypes, @objectLabels, @objectCreators, @citationCreators = [], [], [], []
102
-
103
-
104
- # if the new is given an xml string, store that in the xml attr_accessor and don't rebuild.
105
- # this will allow users to access the raw unprocessed XML string via @xml.
106
- if xml.nil?
107
- build_xml()
108
- else
109
- @xml = xml
110
- end
111
- end #def init
112
-
113
- #this builds the xml based on the instance variables in the object. If it's a hash, this assumes that we want to
114
- #use attributes ==> {"text"=> "7f3da130-7b02-11de-8a39-0800200c9a66", "name" => "uuid" }. If the instance var is
115
- # an array, we assume we don't need attrs, so all values get put into the text node.
116
- def build_xml()
117
- builder = Nokogiri::XML::Builder.new do |xml|
118
- xml.identityMetadata {
119
- field_names = self.instance_variables.sort { |a,b| "#{a}:#{self.instance_variable_get(a).to_s}" <=> "#{b}:#{self.instance_variable_get(b).to_s}"}
120
- field_names.each do |var_name|
121
- unless var_name == "@xml"
122
- var = self.instance_variable_get(var_name)
123
- tag_name = var_name[1..-1]
124
- if var.is_a?(Array)
125
- tag_name.chomp!('s')
126
- end
127
- # wrap the singleton properties in a one-element array
128
- var = Array(var)
129
- var.each do |v|
130
- if v.respond_to?(:xml_values)
131
- unless (v.respond_to?(:empty?) && v.empty?)
132
- xml.send(tag_name, *(v.xml_values))
133
- end
134
- else
135
- xml.send(tag_name, v.to_s)
136
- end
137
- end #var.each
138
- end #unless
139
- end #instance_variables.each
140
- }
141
- end
142
- @ng_xml = builder.doc
143
- end
144
-
145
- def xml
146
- @ng_xml.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::NO_DECLARATION, :indent => 2)
147
- end
148
-
149
- def xml=(value)
150
- @ng_xml = Nokogiri::XML(value)
151
- end
152
-
153
- # This method rebuilds the xml attr_accesor and returns it as a string.
154
- def to_xml
155
- build_xml
156
- return self.xml
157
- end #to_xml
158
-
159
- #
160
- # The following methods are convience methods
161
- #
162
-
163
-
164
- # Add a new tag to the IdentityMetadata instance
165
- def add_tag(new_tag_value)
166
- # Make sure tag is not already present
167
- unless self.get_tags.include?(new_tag_value)
168
- tag = Tag.new
169
- tag.value = new_tag_value
170
- self.tags << tag
171
- end
172
- return self.get_tags
173
- end
174
-
175
- alias :tag :add_tag
176
-
177
- # Returns an array of tag values
178
- def get_tags()
179
- self.tags.collect { |t| t.value }
180
- end
181
-
182
-
183
- # Return the OtherId hash for the specified identier name
184
- def get_other_id(name)
185
- self.otherIds.each do |oi|
186
- if oi.name == name
187
- return oi
188
- end
189
- end
190
- return nil
191
- end
192
-
193
- # Return the identifier value for the specified identier name
194
- def get_identifier_value(key)
195
- other_id = self.get_other_id(key)
196
- if other_id != nil && other_id.value != nil
197
- return other_id.value
198
- end
199
- raise "No #{key} indentifier found for druid #{@objectId}"
200
- end
201
-
202
- # Add a new name,value pair to the set of identifiers
203
- def add_identifier(*args)
204
- (key,value) = args.collect { |arg| arg.to_s }
205
- if value.nil? and key =~ /:/
206
- (key,value) = key.split(/:/,2)
207
- end
208
-
209
- other_id = self.get_other_id(key)
210
- if (other_id != nil)
211
- other_id.value = value
212
- else
213
- other_id = OtherId.new
214
- other_id.name = key
215
- other_id.value = value
216
- @otherIds << other_id
217
- end
218
- end
219
-
220
- def sourceId=(value)
221
- if value.nil?
222
- @sourceId.source = nil
223
- @sourceId.value = nil
224
- else
225
- (source,value) = value.split(/:/,2)
226
-
227
- @sourceId.source = source
228
- @sourceId.value = value
229
- end
230
- end
231
-
232
- # Return an array of strings where each entry consists of name:value
233
- def get_id_pairs
234
- pairs=Array.new
235
- self.otherIds.collect do |other_id|
236
- other_id.to_s
237
- end
238
- end
239
-
240
- #another convience method to allow citationCreator=
241
- def citationCreator=(creator)
242
- if creator.is_a?(Array)
243
- self.citationCreators = creator
244
- elsif creator.is_a?(String)
245
- self.citationCreators = [creator]
246
- else
247
- raise "Identity_metadata.citationCreator requires either a string or array. "
248
- end
249
- end
250
-
251
- #takes a string of XML and constructs the object with all the instance variables added to the correct location.
252
- def self.from_xml(xml="")
253
- if xml.is_a?(File)
254
- xml = xml.read
255
- end
256
-
257
- im = self.new(xml)
258
- doc = Nokogiri::XML(xml)
259
-
260
- children = doc.root.element_children #iterate through the nodes and map them to instance vars in the object.
261
- children.each do |c|
262
- if im.instance_variables.include?("@#{c.name}") or im.instance_variables.include?("@#{c.name}s")
263
- if c.name == "sourceId" #SourceID already has a SourceID object made
264
- im.sourceId.source = c["source"]
265
- im.sourceId.value = c.text.strip
266
- elsif c.name == "otherId" #otherID needs to be cast as an object and stored in an array
267
- im.add_identifier(c['name'],c.text.strip)
268
- elsif c.name == "tag" #tags also need to have objects created and stored in an array
269
- im.add_tag(c.text.strip)
270
- elsif c.name == "objectId" # objectId needs to be mapped to objectId attr_access
271
- im.objectId = c.text.strip
272
- elsif c.name == "citationTitle" #citationTitle also needs to be mapped to citationTitle attr_accessor
273
- im.citationTitle = c.text.strip
274
- elsif c.name == "adminPolicy"
275
- im.adminPolicy = c.text.strip
276
- elsif c.name == "agreementId"
277
- im.agreementId = c.text.strip
278
- else # everything else gets put into an attr_accessor array (note the added 's' on the attr_accessor.)
279
- im.send("#{c.name}s").send("<<", c.text.strip)
280
- end #if
281
- end #if
282
- end #each
283
-
284
- return im
285
-
286
- end #from_xml
287
-
288
- end #class IdentityMetadata