dor-services 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/lib/datastreams/content_metadata_ds.rb +12 -0
  2. data/lib/datastreams/embargo_metadata_ds.rb +107 -0
  3. data/lib/datastreams/events_ds.rb +58 -0
  4. data/lib/datastreams/identity_metadata_ds.rb +28 -0
  5. data/lib/datastreams/ng_tidy.rb +19 -0
  6. data/lib/datastreams/simple_dublin_core_ds.rb +23 -0
  7. data/lib/datastreams/workflow_definition_ds.rb +105 -0
  8. data/lib/datastreams/workflow_ds.rb +16 -0
  9. data/lib/dor-services.rb +19 -0
  10. data/lib/dor/admin_policy_object.rb +11 -0
  11. data/lib/dor/base.rb +81 -0
  12. data/lib/dor/cleanup_service.rb +32 -0
  13. data/lib/dor/config.rb +45 -0
  14. data/lib/dor/digital_stacks_service.rb +82 -0
  15. data/lib/dor/druid_utils.rb +41 -0
  16. data/lib/dor/embargo.rb +41 -0
  17. data/lib/dor/exceptions.rb +13 -0
  18. data/lib/dor/item.rb +141 -0
  19. data/lib/dor/metadata_handlers/catalog_handler.rb +22 -0
  20. data/lib/dor/metadata_handlers/mdtoolkit_handler.rb +42 -0
  21. data/lib/dor/metadata_service.rb +88 -0
  22. data/lib/dor/mods2dc.xslt +447 -0
  23. data/lib/dor/provenance_metadata_service.rb +65 -0
  24. data/lib/dor/registration_service.rb +87 -0
  25. data/lib/dor/rsolr.rb +27 -0
  26. data/lib/dor/sdr_ingest_service.rb +117 -0
  27. data/lib/dor/search_service.rb +86 -0
  28. data/lib/dor/suri_service.rb +37 -0
  29. data/lib/dor/tei2dc.xslt +102 -0
  30. data/lib/dor/workflow_object.rb +13 -0
  31. data/lib/dor/workflow_service.rb +111 -0
  32. data/lib/gsearch/demoFoxmlToSolr.xslt +384 -0
  33. data/lib/gsearch/schema.xml +229 -0
  34. data/lib/tasks/rdoc.rake +32 -0
  35. data/lib/xml_models/foxml.rb +261 -0
  36. data/lib/xml_models/identity_metadata/dublin_core.rb +119 -0
  37. data/lib/xml_models/identity_metadata/identity_metadata.rb +288 -0
  38. metadata +462 -0
@@ -0,0 +1,88 @@
1
+ require 'cache'
2
+
3
+ module Dor
4
+
5
+ class MetadataError < Exception ; end
6
+
7
+ # class MetadataHandler
8
+ #
9
+ # def fetch(prefix, identifier)
10
+ # ### Return metadata for prefix/identifier combo
11
+ # end
12
+ #
13
+ # def label(metadata)
14
+ # ### Return a Fedora-compatible label from the metadata format returned by #fetch
15
+ # end
16
+ #
17
+ # end
18
+
19
+ class MetadataService
20
+
21
+ Config.declare(:metadata)
22
+
23
+ class << self
24
+ @@cache = Cache.new(nil, nil, 250, 300)
25
+
26
+ def register(handler_class)
27
+ ['fetch', 'label', 'prefixes'].each do |method|
28
+ unless handler_class.instance_methods.include?(method)
29
+ raise TypeError, "Metadata handlers must define ##{method.to_s}"
30
+ end
31
+ end
32
+ handler = handler_class.new
33
+ handler.prefixes.each do |prefix|
34
+ handlers[prefix.to_sym] = handler
35
+ end
36
+ return handler
37
+ end
38
+
39
+ def known_prefixes
40
+ return handlers.keys
41
+ end
42
+
43
+ def can_resolve?(identifier)
44
+ (prefix, identifier) = identifier.split(/:/,2)
45
+ handlers.keys.include?(prefix.to_sym)
46
+ end
47
+
48
+ # TODO: Return a prioritized list
49
+ def resolvable(identifiers)
50
+ identifiers.select { |identifier| self.can_resolve?(identifier) }
51
+ end
52
+
53
+ def fetch(identifier)
54
+ @@cache.fetch(identifier) do
55
+ (prefix, identifier) = identifier.split(/:/,2)
56
+ handler = handler_for(prefix)
57
+ handler.fetch(prefix, identifier)
58
+ end
59
+ end
60
+
61
+ def label_for(identifier)
62
+ (prefix, identifier) = identifier.split(/:/,2)
63
+ handler = handler_for(prefix)
64
+ handler.label(handler.fetch(prefix, identifier))
65
+ end
66
+
67
+ def handler_for(prefix)
68
+ handler = handlers[prefix.to_sym]
69
+ if handler.nil?
70
+ raise MetadataError, "Unkown metadata prefix: #{prefix}"
71
+ end
72
+ return handler
73
+ end
74
+
75
+ private
76
+ def handlers
77
+ @handlers ||= {}
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+
86
+ Dir[File.join(File.dirname(__FILE__),'metadata_handlers','*.rb')].each { |handler_file|
87
+ load handler_file
88
+ }
@@ -0,0 +1,447 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <xsl:stylesheet version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xmlns:mods="http://www.loc.gov/mods/v3" exclude-result-prefixes="mods"
4
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
5
+ xmlns:srw_dc="info:srw/schema/1/dc-schema"
6
+ xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
7
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
8
+
9
+ <!--
10
+ This stylesheet transforms MODS version 3.2 records and collections of records to simple Dublin Core (DC) records,
11
+ based on the Library of Congress' MODS to simple DC mapping <http://www.loc.gov/standards/mods/mods-dcsimple.html>
12
+
13
+ The stylesheet will transform a collection of MODS 3.2 records into simple Dublin Core (DC)
14
+ as expressed by the SRU DC schema <http://www.loc.gov/standards/sru/dc-schema.xsd>
15
+
16
+ The stylesheet will transform a single MODS 3.2 record into simple Dublin Core (DC)
17
+ as expressed by the OAI DC schema <http://www.openarchives.org/OAI/2.0/oai_dc.xsd>
18
+
19
+ Because MODS is more granular than DC, transforming a given MODS element or subelement to a DC element frequently results in less precise tagging,
20
+ and local customizations of the stylesheet may be necessary to achieve desired results.
21
+
22
+ This stylesheet makes the following decisions in its interpretation of the MODS to simple DC mapping:
23
+
24
+ When the roleTerm value associated with a name is creator, then name maps to dc:creator
25
+ When there is no roleTerm value associated with name, or the roleTerm value associated with name is a value other than creator, then name maps to dc:contributor
26
+ Start and end dates are presented as span dates in dc:date and in dc:coverage
27
+ When the first subelement in a subject wrapper is topic, subject subelements are strung together in dc:subject with hyphens separating them
28
+ Some subject subelements, i.e., geographic, temporal, hierarchicalGeographic, and cartographics, are also parsed into dc:coverage
29
+ The subject subelement geographicCode is dropped in the transform
30
+
31
+
32
+ Revision 1.1 2007-05-18 <tmee@loc.gov>
33
+ Added modsCollection conversion to DC SRU
34
+ Updated introductory documentation
35
+
36
+ Version 1.0 2007-05-04 Tracy Meehleib <tmee@loc.gov>
37
+
38
+ -->
39
+
40
+ <xsl:output method="xml" indent="yes"/>
41
+
42
+ <xsl:template match="/">
43
+ <xsl:choose>
44
+ <xsl:when test="//mods:modsCollection">
45
+ <srw_dc:dcCollection xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd">
46
+ <xsl:apply-templates/>
47
+ <xsl:for-each select="mods:modsCollection/mods:mods">
48
+ <srw_dc:dc xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/dc-schema.xsd">
49
+
50
+ <xsl:apply-templates/>
51
+ </srw_dc:dc>
52
+ </xsl:for-each>
53
+ </srw_dc:dcCollection>
54
+ </xsl:when>
55
+ <xsl:otherwise>
56
+ <xsl:for-each select="mods:mods">
57
+ <oai_dc:dc xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
58
+ <xsl:apply-templates/>
59
+
60
+ </oai_dc:dc>
61
+ </xsl:for-each>
62
+ </xsl:otherwise>
63
+ </xsl:choose>
64
+ </xsl:template>
65
+
66
+ <xsl:template match="mods:titleInfo">
67
+ <dc:title>
68
+ <xsl:value-of select="mods:nonSort"/>
69
+ <xsl:if test="mods:nonSort">
70
+
71
+ <xsl:text> </xsl:text>
72
+ </xsl:if>
73
+ <xsl:value-of select="mods:title"/>
74
+ <xsl:if test="mods:subTitle">
75
+ <xsl:text>: </xsl:text>
76
+ <xsl:value-of select="mods:subTitle"/>
77
+ </xsl:if>
78
+ <xsl:if test="mods:partNumber">
79
+
80
+ <xsl:text>. </xsl:text>
81
+ <xsl:value-of select="mods:partNumber"/>
82
+ </xsl:if>
83
+ <xsl:if test="mods:partName">
84
+ <xsl:text>. </xsl:text>
85
+ <xsl:value-of select="mods:partName"/>
86
+ </xsl:if>
87
+ </dc:title>
88
+
89
+ </xsl:template>
90
+
91
+ <xsl:template match="mods:name">
92
+ <xsl:choose>
93
+ <xsl:when
94
+ test="mods:role/mods:roleTerm[@type='text']='creator' or mods:role/mods:roleTerm[@type='code']='cre' ">
95
+ <dc:creator>
96
+ <xsl:call-template name="name"/>
97
+ </dc:creator>
98
+ </xsl:when>
99
+
100
+ <xsl:otherwise>
101
+ <dc:contributor>
102
+ <xsl:call-template name="name"/>
103
+ </dc:contributor>
104
+ </xsl:otherwise>
105
+ </xsl:choose>
106
+ </xsl:template>
107
+
108
+ <xsl:template match="mods:classification">
109
+
110
+ <dc:subject>
111
+ <xsl:value-of select="."/>
112
+ </dc:subject>
113
+ </xsl:template>
114
+
115
+ <xsl:template match="mods:subject[mods:topic | mods:name | mods:occupation | mods:geographic | mods:hierarchicalGeographic | mods:cartographics | mods:temporal] ">
116
+ <dc:subject>
117
+ <xsl:for-each select="mods:topic">
118
+ <xsl:value-of select="."/>
119
+
120
+ <xsl:if test="position()!=last()">--</xsl:if>
121
+ </xsl:for-each>
122
+
123
+ <xsl:for-each select="mods:occupation">
124
+ <xsl:value-of select="."/>
125
+ <xsl:if test="position()!=last()">--</xsl:if>
126
+ </xsl:for-each>
127
+
128
+ <xsl:for-each select="mods:name">
129
+
130
+ <xsl:call-template name="name"/>
131
+ </xsl:for-each>
132
+ </dc:subject>
133
+
134
+ <xsl:for-each select="mods:titleInfo/mods:title">
135
+ <dc:subject>
136
+ <xsl:value-of select="mods:titleInfo/mods:title"/>
137
+ </dc:subject>
138
+ </xsl:for-each>
139
+
140
+ <xsl:for-each select="mods:geographic">
141
+ <dc:coverage>
142
+ <xsl:value-of select="."/>
143
+ </dc:coverage>
144
+ </xsl:for-each>
145
+
146
+ <xsl:for-each select="mods:hierarchicalGeographic">
147
+ <dc:coverage>
148
+ <xsl:for-each
149
+ select="mods:continent|mods:country|mods:provence|mods:region|mods:state|mods:territory|mods:county|mods:city|mods:island|mods:area">
150
+
151
+ <xsl:value-of select="."/>
152
+ <xsl:if test="position()!=last()">--</xsl:if>
153
+ </xsl:for-each>
154
+ </dc:coverage>
155
+ </xsl:for-each>
156
+
157
+ <xsl:for-each select="mods:cartographics/*">
158
+ <dc:coverage>
159
+ <xsl:value-of select="."/>
160
+
161
+ </dc:coverage>
162
+ </xsl:for-each>
163
+
164
+ <xsl:if test="mods:temporal">
165
+ <dc:coverage>
166
+ <xsl:for-each select="mods:temporal">
167
+ <xsl:value-of select="."/>
168
+ <xsl:if test="position()!=last()">-</xsl:if>
169
+ </xsl:for-each>
170
+
171
+ </dc:coverage>
172
+ </xsl:if>
173
+
174
+ <xsl:if test="*[1][local-name()='topic'] and *[local-name()!='topic']">
175
+ <dc:subject>
176
+ <xsl:for-each select="*[local-name()!='cartographics' and local-name()!='geographicCode' and local-name()!='hierarchicalGeographic'] ">
177
+ <xsl:value-of select="."/>
178
+ <xsl:if test="position()!=last()">--</xsl:if>
179
+ </xsl:for-each>
180
+
181
+ </dc:subject>
182
+ </xsl:if>
183
+ </xsl:template>
184
+
185
+ <xsl:template match="mods:abstract | mods:tableOfContents | mods:note">
186
+ <dc:description>
187
+ <xsl:value-of select="."/>
188
+ </dc:description>
189
+ </xsl:template>
190
+
191
+ <xsl:template match="mods:originInfo">
192
+ <xsl:apply-templates select="*[@point='start']"/>
193
+ <xsl:for-each
194
+ select="mods:dateIssued[@point!='start' and @point!='end'] |mods:dateCreated[@point!='start' and @point!='end'] | mods:dateCaptured[@point!='start' and @point!='end'] | mods:dateOther[@point!='start' and @point!='end']">
195
+ <dc:date>
196
+ <xsl:value-of select="."/>
197
+ </dc:date>
198
+ </xsl:for-each>
199
+
200
+ <xsl:for-each select="mods:publisher">
201
+
202
+ <dc:publisher>
203
+ <xsl:value-of select="."/>
204
+ </dc:publisher>
205
+ </xsl:for-each>
206
+ </xsl:template>
207
+
208
+ <xsl:template match="mods:dateIssued | mods:dateCreated | mods:dateCaptured">
209
+ <dc:date>
210
+ <xsl:choose>
211
+
212
+ <xsl:when test="@point='start'">
213
+ <xsl:value-of select="."/>
214
+ <xsl:text> - </xsl:text>
215
+ </xsl:when>
216
+ <xsl:when test="@point='end'">
217
+ <xsl:value-of select="."/>
218
+ </xsl:when>
219
+ <xsl:otherwise>
220
+
221
+ <xsl:value-of select="."/>
222
+ </xsl:otherwise>
223
+ </xsl:choose>
224
+ </dc:date>
225
+ </xsl:template>
226
+
227
+ <xsl:template match="mods:genre">
228
+ <xsl:choose>
229
+ <xsl:when test="@authority='dct'">
230
+
231
+ <dc:type>
232
+ <xsl:value-of select="."/>
233
+ </dc:type>
234
+ <xsl:for-each select="mods:typeOfResource">
235
+ <dc:type>
236
+ <xsl:value-of select="."/>
237
+ </dc:type>
238
+ </xsl:for-each>
239
+ </xsl:when>
240
+
241
+ <xsl:otherwise>
242
+ <dc:type>
243
+ <xsl:value-of select="."/>
244
+ </dc:type>
245
+ </xsl:otherwise>
246
+ </xsl:choose>
247
+ </xsl:template>
248
+
249
+ <xsl:template match="mods:typeOfResource">
250
+
251
+ <xsl:if test="@collection='yes'">
252
+ <dc:type>Collection</dc:type>
253
+ </xsl:if>
254
+ <xsl:if test=". ='software' and ../mods:genre='database'">
255
+ <dc:type>DataSet</dc:type>
256
+ </xsl:if>
257
+ <xsl:if test=".='software' and ../mods:genre='online system or service'">
258
+ <dc:type>Service</dc:type>
259
+
260
+ </xsl:if>
261
+ <xsl:if test=".='software'">
262
+ <dc:type>Software</dc:type>
263
+ </xsl:if>
264
+ <xsl:if test=".='cartographic material'">
265
+ <dc:type>Image</dc:type>
266
+ </xsl:if>
267
+ <xsl:if test=".='multimedia'">
268
+
269
+ <dc:type>InteractiveResource</dc:type>
270
+ </xsl:if>
271
+ <xsl:if test=".='moving image'">
272
+ <dc:type>MovingImage</dc:type>
273
+ </xsl:if>
274
+ <xsl:if test=".='three-dimensional object'">
275
+ <dc:type>PhysicalObject</dc:type>
276
+
277
+ </xsl:if>
278
+ <xsl:if test="starts-with(.,'sound recording')">
279
+ <dc:type>Sound</dc:type>
280
+ </xsl:if>
281
+ <xsl:if test=".='still image'">
282
+ <dc:type>StillImage</dc:type>
283
+ </xsl:if>
284
+ <xsl:if test=". ='text'">
285
+
286
+ <dc:type>Text</dc:type>
287
+ </xsl:if>
288
+ <xsl:if test=".='notated music'">
289
+ <dc:type>Text</dc:type>
290
+ </xsl:if>
291
+ </xsl:template>
292
+
293
+ <xsl:template match="mods:physicalDescription">
294
+
295
+ <xsl:if test="mods:extent">
296
+ <dc:format>
297
+ <xsl:value-of select="mods:extent"/>
298
+ </dc:format>
299
+ </xsl:if>
300
+ <xsl:if test="mods:form">
301
+ <dc:format>
302
+ <xsl:value-of select="mods:form"/>
303
+ </dc:format>
304
+
305
+ </xsl:if>
306
+ <xsl:if test="mods:internetMediaType">
307
+ <dc:format>
308
+ <xsl:value-of select="mods:internetMediaType"/>
309
+ </dc:format>
310
+ </xsl:if>
311
+ </xsl:template>
312
+
313
+ <xsl:template match="mods:mimeType">
314
+
315
+ <dc:format>
316
+ <xsl:value-of select="."/>
317
+ </dc:format>
318
+ </xsl:template>
319
+
320
+ <xsl:template match="mods:identifier">
321
+ <xsl:variable name="type" select="translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
322
+ <xsl:choose>
323
+ <xsl:when test="contains ('isbn issn uri doi lccn uri', $type)">
324
+
325
+ <dc:identifier>
326
+ <xsl:value-of select="$type"/>: <xsl:value-of select="."/>
327
+ </dc:identifier>
328
+ </xsl:when>
329
+ <xsl:otherwise>
330
+ <dc:identifier>
331
+ <xsl:value-of select="."/>
332
+ </dc:identifier>
333
+
334
+ </xsl:otherwise>
335
+ </xsl:choose>
336
+ </xsl:template>
337
+
338
+ <xsl:template match="mods:location">
339
+ <dc:identifier>
340
+ <xsl:for-each select="mods:url">
341
+ <xsl:value-of select="."/>
342
+ </xsl:for-each>
343
+
344
+ </dc:identifier>
345
+ </xsl:template>
346
+
347
+ <xsl:template match="mods:language">
348
+ <dc:language>
349
+ <xsl:value-of select="normalize-space(.)"/>
350
+ </dc:language>
351
+ </xsl:template>
352
+
353
+ <xsl:template match="mods:relatedItem[mods:titleInfo | mods:name | mods:identifier | mods:location]">
354
+
355
+ <xsl:choose>
356
+ <xsl:when test="@type='original'">
357
+ <dc:source>
358
+ <xsl:for-each
359
+ select="mods:titleInfo/mods:title | mods:identifier | mods:location/mods:url">
360
+ <xsl:if test="normalize-space(.)!= ''">
361
+ <xsl:value-of select="."/>
362
+ <xsl:if test="position()!=last()">--</xsl:if>
363
+ </xsl:if>
364
+
365
+ </xsl:for-each>
366
+ </dc:source>
367
+ </xsl:when>
368
+ <xsl:when test="@type='series'"/>
369
+ <xsl:otherwise>
370
+ <dc:relation>
371
+ <xsl:for-each
372
+ select="mods:titleInfo/mods:title | mods:identifier | mods:location/mods:url">
373
+ <xsl:if test="normalize-space(.)!= ''">
374
+ <xsl:value-of select="."/>
375
+
376
+ <xsl:if test="position()!=last()">--</xsl:if>
377
+ </xsl:if>
378
+ </xsl:for-each>
379
+ </dc:relation>
380
+ </xsl:otherwise>
381
+ </xsl:choose>
382
+ </xsl:template>
383
+
384
+ <xsl:template match="mods:accessCondition">
385
+
386
+ <dc:rights>
387
+ <xsl:value-of select="."/>
388
+ </dc:rights>
389
+ </xsl:template>
390
+
391
+ <xsl:template name="name">
392
+ <xsl:variable name="name">
393
+ <xsl:for-each select="mods:namePart[not(@type)]">
394
+ <xsl:value-of select="."/>
395
+
396
+ <xsl:text> </xsl:text>
397
+ </xsl:for-each>
398
+ <xsl:value-of select="mods:namePart[@type='family']"/>
399
+ <xsl:if test="mods:namePart[@type='given']">
400
+ <xsl:text>, </xsl:text>
401
+ <xsl:value-of select="mods:namePart[@type='given']"/>
402
+ </xsl:if>
403
+ <xsl:if test="mods:namePart[@type='date']">
404
+
405
+ <xsl:text>, </xsl:text>
406
+ <xsl:value-of select="mods:namePart[@type='date']"/>
407
+ <xsl:text/>
408
+ </xsl:if>
409
+ <xsl:if test="mods:displayForm">
410
+ <xsl:text> (</xsl:text>
411
+ <xsl:value-of select="mods:displayForm"/>
412
+
413
+ <xsl:text>) </xsl:text>
414
+ </xsl:if>
415
+ <xsl:for-each select="mods:role[mods:roleTerm[@type='text']!='creator']">
416
+ <xsl:text> (</xsl:text>
417
+ <xsl:value-of select="normalize-space(.)"/>
418
+ <xsl:text>) </xsl:text>
419
+ </xsl:for-each>
420
+
421
+ </xsl:variable>
422
+ <xsl:value-of select="normalize-space($name)"/>
423
+ </xsl:template>
424
+
425
+ <xsl:template match="mods:dateIssued[@point='start'] | mods:dateCreated[@point='start'] | mods:dateCaptured[@point='start'] | mods:dateOther[@point='start'] ">
426
+ <xsl:variable name="dateName" select="local-name()"/>
427
+ <dc:date>
428
+ <xsl:value-of select="."/>-<xsl:value-of select="../*[local-name()=$dateName][@point='end']"/>
429
+ </dc:date>
430
+
431
+ </xsl:template>
432
+
433
+ <xsl:template match="mods:temporal[@point='start'] ">
434
+ <xsl:value-of select="."/>-<xsl:value-of select="../mods:temporal[@point='end']"/>
435
+ </xsl:template>
436
+
437
+ <xsl:template match="mods:temporal[@point!='start' and @point!='end'] ">
438
+ <xsl:value-of select="."/>
439
+ </xsl:template>
440
+
441
+ <!-- suppress all else:-->
442
+
443
+ <xsl:template match="*"/>
444
+
445
+
446
+
447
+ </xsl:stylesheet>