cul_hydra 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +7 -0
  2. data/app/assets/images/cul_hydra/crystal/binary.png +0 -0
  3. data/app/assets/images/cul_hydra/crystal/document.png +0 -0
  4. data/app/assets/images/cul_hydra/crystal/file.png +0 -0
  5. data/app/assets/images/cul_hydra/crystal/file_broken.png +0 -0
  6. data/app/assets/images/cul_hydra/crystal/folder_documents.png +0 -0
  7. data/app/assets/images/cul_hydra/crystal/folder_images.png +0 -0
  8. data/app/assets/images/cul_hydra/crystal/folder_music.png +0 -0
  9. data/app/assets/images/cul_hydra/crystal/folder_sound.png +0 -0
  10. data/app/assets/images/cul_hydra/crystal/folder_video.png +0 -0
  11. data/app/assets/images/cul_hydra/crystal/kmultiple.png +0 -0
  12. data/app/assets/images/cul_hydra/crystal/knotify.png +0 -0
  13. data/app/assets/images/cul_hydra/crystal/mp3.png +0 -0
  14. data/app/assets/images/cul_hydra/crystal/multimedia2.png +0 -0
  15. data/app/assets/images/cul_hydra/crystal/video.png +0 -0
  16. data/app/assets/images/cul_hydra/filesystem/application.png +0 -0
  17. data/app/assets/images/cul_hydra/filesystem/code.png +0 -0
  18. data/app/assets/images/cul_hydra/filesystem/css.png +0 -0
  19. data/app/assets/images/cul_hydra/filesystem/db.png +0 -0
  20. data/app/assets/images/cul_hydra/filesystem/directory.png +0 -0
  21. data/app/assets/images/cul_hydra/filesystem/doc.png +0 -0
  22. data/app/assets/images/cul_hydra/filesystem/file.png +0 -0
  23. data/app/assets/images/cul_hydra/filesystem/film.png +0 -0
  24. data/app/assets/images/cul_hydra/filesystem/flash.png +0 -0
  25. data/app/assets/images/cul_hydra/filesystem/folder_open.png +0 -0
  26. data/app/assets/images/cul_hydra/filesystem/html.png +0 -0
  27. data/app/assets/images/cul_hydra/filesystem/java.png +0 -0
  28. data/app/assets/images/cul_hydra/filesystem/linux.png +0 -0
  29. data/app/assets/images/cul_hydra/filesystem/music.png +0 -0
  30. data/app/assets/images/cul_hydra/filesystem/pdf.png +0 -0
  31. data/app/assets/images/cul_hydra/filesystem/php.png +0 -0
  32. data/app/assets/images/cul_hydra/filesystem/picture.png +0 -0
  33. data/app/assets/images/cul_hydra/filesystem/ppt.png +0 -0
  34. data/app/assets/images/cul_hydra/filesystem/psd.png +0 -0
  35. data/app/assets/images/cul_hydra/filesystem/ruby.png +0 -0
  36. data/app/assets/images/cul_hydra/filesystem/script.png +0 -0
  37. data/app/assets/images/cul_hydra/filesystem/spinner.gif +0 -0
  38. data/app/assets/images/cul_hydra/filesystem/txt.png +0 -0
  39. data/app/assets/images/cul_hydra/filesystem/xls.png +0 -0
  40. data/app/assets/images/cul_hydra/filesystem/zip.png +0 -0
  41. data/app/controllers/concerns/cul/hydra/application_id_behavior.rb +43 -0
  42. data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
  43. data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
  44. data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
  45. data/app/helpers/cul/hydra/ore_proxies_helper_behavior.rb +119 -0
  46. data/app/helpers/cul/hydra/struct_metadata_helper_behavior.rb +89 -0
  47. data/app/models/bag_aggregator.rb +7 -0
  48. data/app/models/concept.rb +23 -0
  49. data/app/models/concerns/cul/hydra/models.rb +24 -0
  50. data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
  51. data/app/models/concerns/cul/hydra/models/common.rb +220 -0
  52. data/app/models/concerns/cul/hydra/models/image_resource.rb +106 -0
  53. data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
  54. data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
  55. data/app/models/concerns/nfo/common.rb +17 -0
  56. data/app/models/concerns/nfo/file_data_object.rb +10 -0
  57. data/app/models/concerns/nfo/folder.rb +10 -0
  58. data/app/models/concerns/nie/information_element.rb +10 -0
  59. data/app/models/concerns/ore/proxy.rb +124 -0
  60. data/app/models/concerns/rdf/cul.rb +77 -0
  61. data/app/models/concerns/rdf/fcrepo3.rb +360 -0
  62. data/app/models/concerns/rdf/nfo.rb +807 -0
  63. data/app/models/concerns/rdf/nie.rb +338 -0
  64. data/app/models/concerns/rdf/olo.rb +100 -0
  65. data/app/models/concerns/rdf/ore.rb +101 -0
  66. data/app/models/concerns/rdf/pimo.rb +605 -0
  67. data/app/models/concerns/rdf/sc.rb +47 -0
  68. data/app/models/concerns/sc/canvas.rb +12 -0
  69. data/app/models/concerns/sc/sequence.rb +21 -0
  70. data/app/models/content_aggregator.rb +3 -0
  71. data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
  72. data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
  73. data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
  74. data/app/models/dc_document.rb +39 -0
  75. data/app/models/generic_aggregator.rb +68 -0
  76. data/app/models/generic_object.rb +18 -0
  77. data/app/models/generic_resource.rb +210 -0
  78. data/app/models/jp2_image_aggregator.rb +34 -0
  79. data/app/models/mets_structured_aggregator.rb +18 -0
  80. data/app/models/resource.rb +78 -0
  81. data/app/models/resource_aggregator.rb +22 -0
  82. data/app/models/static_audio_aggregator.rb +12 -0
  83. data/app/models/static_image_aggregator.rb +32 -0
  84. data/bin/rails +12 -0
  85. data/config/fedora.yml +17 -0
  86. data/config/jetty.yml +6 -0
  87. data/config/locales/ldpd_hydra.en.yml +125 -0
  88. data/config/predicate_mappings.yml +79 -0
  89. data/config/solr.yml +8 -0
  90. data/config/solr_mappings.yml +26 -0
  91. data/config/solr_value_maps.yml +41 -0
  92. data/config/subs.yml +17 -0
  93. data/fixtures/cmodels/ldpd_ADLMetadata.xml +56 -0
  94. data/fixtures/cmodels/ldpd_AESMetadata.xml +56 -0
  95. data/fixtures/cmodels/ldpd_BagAggregator.xml +70 -0
  96. data/fixtures/cmodels/ldpd_Concept.xml +69 -0
  97. data/fixtures/cmodels/ldpd_ContentAggregator.xml +70 -0
  98. data/fixtures/cmodels/ldpd_DynamicAggregator.xml +56 -0
  99. data/fixtures/cmodels/ldpd_JP2ImageAggregator.xml +60 -0
  100. data/fixtures/cmodels/ldpd_METSMetadata.xml +56 -0
  101. data/fixtures/cmodels/ldpd_METSStructuredAggregator.xml +53 -0
  102. data/fixtures/cmodels/ldpd_MODSMetadata.xml +73 -0
  103. data/fixtures/cmodels/ldpd_MostRecent.xml +46 -0
  104. data/fixtures/cmodels/ldpd_PTIFImageAggregator.xml +63 -0
  105. data/fixtures/cmodels/ldpd_Resource.xml +72 -0
  106. data/fixtures/cmodels/ldpd_RestrictedResource.xml +54 -0
  107. data/fixtures/cmodels/ldpd_Since.xml +62 -0
  108. data/fixtures/cmodels/ldpd_StaticAudioAggregator.xml +54 -0
  109. data/fixtures/cmodels/ldpd_StaticImageAggregator.xml +71 -0
  110. data/fixtures/cmodels/ldpd_htest.xml +54 -0
  111. data/fixtures/cmodels/ldpd_nullbind.xml +63 -0
  112. data/fixtures/cmodels/ldpd_sdef.Aggregator.xml +71 -0
  113. data/fixtures/cmodels/ldpd_sdef.Core.xml +48 -0
  114. data/fixtures/cmodels/ldpd_sdef.Image.xml +47 -0
  115. data/fixtures/cmodels/ldpd_sdef.Metadata.xml +62 -0
  116. data/fixtures/cmodels/ldpd_sdef.Resource.xml +76 -0
  117. data/fixtures/cmodels/ldpd_sdef.ZoomingImage.xml +46 -0
  118. data/fixtures/cmodels/ldpd_sdep.BagAggregator.xml +160 -0
  119. data/fixtures/cmodels/ldpd_sdep.BagAggregatorCore.xml +221 -0
  120. data/fixtures/cmodels/ldpd_sdep.ContentAggregatorCore.xml +221 -0
  121. data/fixtures/cmodels/ldpd_sdep.DynamicAggregator.xml +171 -0
  122. data/fixtures/cmodels/ldpd_sdep.DynamicAggregatorCore.xml +215 -0
  123. data/fixtures/cmodels/ldpd_sdep.JP2Image.xml +220 -0
  124. data/fixtures/cmodels/ldpd_sdep.JP2ImageAggregator.xml +167 -0
  125. data/fixtures/cmodels/ldpd_sdep.JP2ImageCore.xml +229 -0
  126. data/fixtures/cmodels/ldpd_sdep.MODSMetadata.xml +158 -0
  127. data/fixtures/cmodels/ldpd_sdep.MODSMetadataCore.xml +227 -0
  128. data/fixtures/cmodels/ldpd_sdep.PTIFImage.xml +222 -0
  129. data/fixtures/cmodels/ldpd_sdep.PTIFImageAggregator.xml +167 -0
  130. data/fixtures/cmodels/ldpd_sdep.PTIFImageCore.xml +215 -0
  131. data/fixtures/cmodels/ldpd_sdep.StaticImage.xml +210 -0
  132. data/fixtures/cmodels/ldpd_sdep.StaticImageAggregator.xml +186 -0
  133. data/fixtures/cmodels/ldpd_sdep.StaticImageCore.xml +220 -0
  134. data/fixtures/cmodels/ore_Proxy.xml +50 -0
  135. data/fixtures/spec/BLOB/test001.jpg +0 -0
  136. data/fixtures/spec/CUL_DC/dc.xml +5 -0
  137. data/fixtures/spec/CUL_MODS/mods-001.xml +25 -0
  138. data/fixtures/spec/CUL_MODS/mods-all.xml +65 -0
  139. data/fixtures/spec/CUL_MODS/mods-bad-repo.xml +7 -0
  140. data/fixtures/spec/CUL_MODS/mods-date-created-range.xml +7 -0
  141. data/fixtures/spec/CUL_MODS/mods-date-created-single.xml +6 -0
  142. data/fixtures/spec/CUL_MODS/mods-date-end-with-all-u-characters.xml +7 -0
  143. data/fixtures/spec/CUL_MODS/mods-date-issued-range.xml +7 -0
  144. data/fixtures/spec/CUL_MODS/mods-date-issued-single.xml +6 -0
  145. data/fixtures/spec/CUL_MODS/mods-date-other-range.xml +7 -0
  146. data/fixtures/spec/CUL_MODS/mods-date-other-single.xml +6 -0
  147. data/fixtures/spec/CUL_MODS/mods-date-range-short-years.xml +7 -0
  148. data/fixtures/spec/CUL_MODS/mods-date-start-with-all-u-characters.xml +7 -0
  149. data/fixtures/spec/CUL_MODS/mods-dates-with-all-u-characters.xml +7 -0
  150. data/fixtures/spec/CUL_MODS/mods-dates-with-some-u-characters.xml +7 -0
  151. data/fixtures/spec/CUL_MODS/mods-item.xml +31 -0
  152. data/fixtures/spec/CUL_MODS/mods-names.xml +35 -0
  153. data/fixtures/spec/CUL_MODS/mods-notes.xml +8 -0
  154. data/fixtures/spec/CUL_MODS/mods-ns.xml +2 -0
  155. data/fixtures/spec/CUL_MODS/mods-origin-info.xml +9 -0
  156. data/fixtures/spec/CUL_MODS/mods-part.xml +22 -0
  157. data/fixtures/spec/CUL_MODS/mods-physical-description.xml +12 -0
  158. data/fixtures/spec/CUL_MODS/mods-physical-location.xml +9 -0
  159. data/fixtures/spec/CUL_MODS/mods-record-info.xml +4 -0
  160. data/fixtures/spec/CUL_MODS/mods-relateditem-project.xml +8 -0
  161. data/fixtures/spec/CUL_MODS/mods-subjects.xml +73 -0
  162. data/fixtures/spec/CUL_MODS/mods-textual-date.xml +8 -0
  163. data/fixtures/spec/CUL_MODS/mods-titles.xml +33 -0
  164. data/fixtures/spec/CUL_MODS/mods-top-level-location-vs-relateditem-location.xml +21 -0
  165. data/fixtures/spec/CUL_MODS/mods-unmapped-project.xml +7 -0
  166. data/fixtures/spec/CUL_SOLR/mods-001.xml +1 -0
  167. data/fixtures/spec/CUL_SOLR/mods-001.yml +30 -0
  168. data/fixtures/spec/FOXML/content-aggregator.xml +64 -0
  169. data/fixtures/spec/FOXML/content-cmodel.xml +48 -0
  170. data/fixtures/spec/FOXML/image-cmodel.xml +48 -0
  171. data/fixtures/spec/FOXML/resource-max.xml +83 -0
  172. data/fixtures/spec/FOXML/resource-screen.xml +273 -0
  173. data/fixtures/spec/FOXML/resource-thumb.xml +86 -0
  174. data/fixtures/spec/FOXML/static-image-aggregator.xml +31 -0
  175. data/fixtures/spec/STRUCTMAP/structmap-examples.xml +21 -0
  176. data/fixtures/spec/STRUCTMAP/structmap-nested.xml +10 -0
  177. data/fixtures/spec/STRUCTMAP/structmap-recto.xml +4 -0
  178. data/fixtures/spec/STRUCTMAP/structmap-seq.xml +5 -0
  179. data/fixtures/spec/STRUCTMAP/structmap-unordered-seq.xml +5 -0
  180. data/lib/cul_hydra.rb +20 -0
  181. data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
  182. data/lib/cul_hydra/controllers.rb +13 -0
  183. data/lib/cul_hydra/controllers/aggregates.rb +93 -0
  184. data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
  185. data/lib/cul_hydra/controllers/catalog.rb +12 -0
  186. data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
  187. data/lib/cul_hydra/controllers/datastreams.rb +145 -0
  188. data/lib/cul_hydra/controllers/helpers.rb +10 -0
  189. data/lib/cul_hydra/controllers/helpers/active_fedora_helper_behavior.rb +9 -0
  190. data/lib/cul_hydra/controllers/helpers/application_helper_behavior.rb +16 -0
  191. data/lib/cul_hydra/controllers/helpers/dc_metadata_helper_behavior.rb +9 -0
  192. data/lib/cul_hydra/controllers/helpers/hydra_assets_helper_behavior.rb +46 -0
  193. data/lib/cul_hydra/controllers/helpers/hydra_autocomplete_helper_behavior.rb +35 -0
  194. data/lib/cul_hydra/controllers/helpers/hydra_uploader_helper_behavior.rb +34 -0
  195. data/lib/cul_hydra/controllers/helpers/resources_helper_behavior.rb +159 -0
  196. data/lib/cul_hydra/controllers/resources.rb +161 -0
  197. data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
  198. data/lib/cul_hydra/controllers/suggestions.rb +126 -0
  199. data/lib/cul_hydra/controllers/terms.rb +205 -0
  200. data/lib/cul_hydra/engine.rb +31 -0
  201. data/lib/cul_hydra/fedora.rb +41 -0
  202. data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
  203. data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
  204. data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
  205. data/lib/cul_hydra/indexer.rb +102 -0
  206. data/lib/cul_hydra/om.rb +7 -0
  207. data/lib/cul_hydra/om/standard_mods.rb +115 -0
  208. data/lib/cul_hydra/risearch_members.rb +92 -0
  209. data/lib/cul_hydra/solrizer.rb +10 -0
  210. data/lib/cul_hydra/solrizer/extractor.rb +27 -0
  211. data/lib/cul_hydra/solrizer/mods_fieldable.rb +473 -0
  212. data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
  213. data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
  214. data/lib/cul_hydra/solrizer_patch.rb +172 -0
  215. data/lib/cul_hydra/version.rb +8 -0
  216. data/lib/cul_hydra/version.rb~ +8 -0
  217. data/lib/tasks/cmodel.rake +122 -0
  218. data/lib/tasks/cul_hydra_dev.rake +54 -0
  219. data/lib/tasks/index.rake +73 -0
  220. data/lib/tasks/transform.rake +23 -0
  221. metadata +503 -0
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rdf'
3
+ module RDF
4
+ class SC < RDF::StrictVocabulary("http://www.shared-canvas.org/ns/")
5
+ term :Manifest,
6
+ type: "rdfs:Class".freeze
7
+ term :Sequence,
8
+ type: "rdfs:Class".freeze
9
+ term :Canvas,
10
+ type: "rdfs:Class".freeze
11
+ # IIIF 'attribution'
12
+ property :attributionLabel
13
+ # IIIF 'service'
14
+ property :hasRelatedService
15
+ # IIIF 'seeAlso'
16
+ property :hasRelatedDescription
17
+ # IIIF 'sequences'
18
+ # range is a collection of Sequence
19
+ property :hasSequences
20
+
21
+ property :withinManifest,
22
+ range: "http://www.shared-canvas.org/ns/Manifest".freeze,
23
+ subPropertyOf: "dc:isPartOf".freeze
24
+ property :withinSequence,
25
+ range: "http://www.shared-canvas.org/ns/Sequence".freeze,
26
+ subPropertyOf: "dc:isPartOf".freeze
27
+
28
+ # IIIF 'canvases'
29
+ # range is a collection of Canvas
30
+ property :hasCanvases
31
+ # IIIF 'resources'
32
+ property :hasAnnotations
33
+ # IIIF 'images'
34
+ property :hasImageAnnotations
35
+ # IIIF 'otherContent'
36
+ property :hasLists
37
+ # IIIF 'structures'
38
+ property :hasRanges
39
+ # IIIF 'metadata'
40
+ # range is a collection of Resource
41
+ property :metadataLabels
42
+ # IIIF 'viewingDirection'
43
+ property :viewingDirection
44
+ # IIIF 'viewingHint'
45
+ property :viewingHint
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ module SC
2
+ class Canvas < ORE::Proxy
3
+ include NIE::InformationElement
4
+ property :belongsToContainer, predicate: RDF::DC[:isPartOf], multivalue: false do |ix|
5
+ ix.as :stored_sortable
6
+ end
7
+ def initialize(proxy_for_uri, context_uri, *args)
8
+ super(proxy_for_uri, context_uri, *args)
9
+ self.get_values(:type) << RDF::SC[:Canvas]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ module SC
2
+ class Sequence < ORE::Proxy
3
+ include NIE::InformationElement
4
+ property :viewingDirection, predicate: RDF::SC[:viewingDirection], multivalue: false do |ix|
5
+ ix.as :stored_sortable
6
+ end
7
+ property :viewingHint, predicate: RDF::SC[:viewingHint], multivalue: false do |ix|
8
+ ix.as :stored_sortable
9
+ end
10
+ property :canvases, predicate: RDF::SC[:hasCanvases], multivalue: true do |ix|
11
+ ix.as :symbol
12
+ end
13
+ property :belongsToContainer, predicate: RDF::DC[:isPartOf], multivalue: false do |ix|
14
+ ix.as :stored_sortable
15
+ end
16
+ def initialize(proxy_for_uri, context_uri, *args)
17
+ super(proxy_for_uri, context_uri, *args)
18
+ self.get_values(:type) << RDF::SC[:Sequence]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ class ContentAggregator < GenericAggregator
2
+
3
+ end
@@ -0,0 +1,107 @@
1
+ require 'active-fedora'
2
+ module Cul
3
+ module Hydra
4
+ module Datastreams
5
+ class DCMetadata < ::ActiveFedora::OmDatastream
6
+
7
+ after_save :action_after_save
8
+ set_terminology do |t|
9
+ t.root(:path=>"dc", :namespace_prefix=>"oai_dc",
10
+ "xmlns:oai_dc"=>"http://www.openarchives.org/OAI/2.0/oai_dc/",
11
+ "xmlns:dc"=>"http://purl.org/dc/elements/1.1/",
12
+ :schema=>"http://www.openarchives.org/OAI/2.0/oai_dc.xsd")
13
+ t.dc_contributor(:path=>"contributor",
14
+ :namespace_prefix=>"dc",
15
+ :index_as=>[:displayable, :searchable])
16
+ t.dc_coverage(:path=>"coverage",
17
+ :namespace_prefix=>"dc",
18
+ :index_as=>[:displayable, :searchable])
19
+ t.dc_creator(:path=>"creator",
20
+ :namespace_prefix=>"dc",
21
+ :index_as=>[:displayable, :searchable])
22
+ t.dc_date(:path=>"date",
23
+ :namespace_prefix=>"dc",
24
+ :index_as=>[:displayable, :searchable])
25
+ t.dc_description(:path=>"description",
26
+ :namespace_prefix=>"dc",
27
+ :index_as=>[:displayable, :searchable])
28
+ t.dc_format(:path=>"format",
29
+ :namespace_prefix=>"dc",
30
+ :index_as=>[:displayable, :facetable])
31
+ t.dc_identifier(:path=>"identifier",
32
+ :namespace_prefix=>"dc",
33
+ :type=>:string,
34
+ :index_as=>[:symbol])
35
+ t.dc_language(:path=>"language",
36
+ :namespace_prefix=>"dc",
37
+ :index_as=>[:displayable, :searchable])
38
+ t.dc_publisher(:path=>"publisher",
39
+ :namespace_prefix=>"dc",
40
+ :index_as=>[:displayable, :searchable])
41
+ t.dc_relation(:path=>"relation",
42
+ :namespace_prefix=>"dc",
43
+ :index_as=>[:displayable, :searchable])
44
+ t.dc_rights(:path=>"rights",
45
+ :namespace_prefix=>"dc",
46
+ :index_as=>[:displayable, :searchable])
47
+ t.dc_source(:path=>"source",
48
+ :namespace_prefix=>"dc",
49
+ :index_as=>[:displayable, :searchable])
50
+ t.dc_subject(:path=>"subject",
51
+ :namespace_prefix=>"dc",
52
+ :index_as=>[:displayable, :searchable])
53
+ t.dc_title(:path=>"title",
54
+ :namespace_prefix=>"dc",
55
+ :index_as=>[:displayable, :searchable])
56
+ t.dc_type(:path=>"type",
57
+ :namespace_prefix=>"dc",
58
+ :index_as=>[:displayable, :facetable])
59
+ end
60
+
61
+ def self.xml_template
62
+
63
+ Nokogiri::XML::Document.parse(<<-src
64
+ <oai_dc:dc
65
+ xmlns:oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc/'
66
+ xmlns:dc='http://purl.org/dc/elements/1.1/'
67
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
68
+ xsi:schemaLocation='http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'></oai_dc:dc>
69
+ src
70
+ )
71
+ end
72
+ # Because FCRepo 3.5+ modifies DC on saves (to ensure that PID is a dc:identifier value),
73
+ # this datastream's content must be reloaded after saves
74
+ def action_after_save
75
+ @content = nil
76
+ @ng_xml = nil
77
+ remove_instance_variable(:@ng_xml)
78
+ end
79
+
80
+ def prefix
81
+ #if ::ActiveFedora::VERSION >= '8'
82
+ # Rails.logger.warn("the prefix method of #{self.class.name} was overriden to maintain backwards compatibility")
83
+ #end
84
+ ''
85
+ end
86
+
87
+ def method_missing method, *args
88
+ query = false
89
+ _mname = method.id2name
90
+ if _mname[-1,1] == '?'
91
+ query = true
92
+ _mname = _mname[0,_mname.length-1]
93
+ end
94
+ _msym = _mname.to_sym
95
+ has_term = self.class.terminology.has_term?(_msym)
96
+ return false if query and not has_term
97
+ _r = super(_mname.to_sym, *args)
98
+ if query
99
+ _r.length > 0
100
+ else
101
+ _r
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,195 @@
1
+ require 'active-fedora'
2
+ require 'solrizer'
3
+ require 'cul_hydra/solrizer'
4
+ module Cul
5
+ module Hydra
6
+ module Datastreams
7
+ class ModsDocument < ::ActiveFedora::OmDatastream
8
+ include ::OM::XML::TerminologyBasedSolrizer
9
+ include Cul::Hydra::Solrizer::TerminologyBasedSolrizer
10
+ include Cul::Hydra::Solrizer::ModsFieldable
11
+
12
+ #map_field("lib_repo_sim", :marc_to_facet)
13
+ #map_field("lib_repo_long_ssim", :marc_to_display)
14
+ #map_field("lib_project_sim", :project_to_facet)
15
+
16
+ set_terminology do |t|
17
+ t.root(:path=>"mods",
18
+ :xmlns=>"http://www.loc.gov/mods/v3",
19
+ :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-4.xsd") {
20
+ }
21
+
22
+ t.main_title_info(:path=>'titleInfo', :index_as=>[], :attributes=>{:type=>:none}){
23
+ t.non_sort(:path=>"nonSort", :index_as=>[])
24
+ t.main_title(:path=>"title", :index_as=>[])
25
+ }
26
+
27
+ t.title(:proxy=>[:mods, :main_title_info, :main_title], :type=>:string,
28
+ :index_as=>[:searchable, :sortable])
29
+ t.title_display(:proxy=>[:mods, :main_title_info], :type=>:string,
30
+ :index_as=>[:displayable])
31
+
32
+ t.search_title_info(:path=>'titleInfo', :index_as=>[]){
33
+ t.search_title(:path=>'title', :index_as=>[:textable])
34
+ }
35
+ t.part(:path=>"relatedItem", :attributes=>{:type=>"constituent"}, :index_as=>[]){
36
+ t.part_title_info(:path=>'titleInfo', :index_as=>[]){
37
+ t.lib_part(:path=>'title',:index_as=>[])
38
+ }
39
+ }
40
+ t.project(:path=>"relatedItem", :attributes=>{:type=>"host", :displayLabel=>"Project"}, :index_as=>[]){
41
+ t.project_title_info(:path=>'titleInfo', :index_as=>[]){
42
+ t.lib_project(:path=>'title',:index_as=>[])
43
+ }
44
+ }
45
+ t.collection(:path=>"relatedItem", :attributes=>{:type=>"host", :displayLabel=>"Collection"}, :index_as=>[]){
46
+ t.collection_title_info(:path=>'titleInfo', :index_as=>[]){
47
+ t.lib_collection(:path=>'title', :index_as=>[])
48
+ }
49
+ }
50
+ t.lib_project(:proxy=>[:project,:project_title_info], :index_as=>[:project_textable])
51
+ t.lib_collection(:proxy=>[:collection,:collection_title_info], :index_as=>[:displayable])
52
+ t.lib_part(:proxy=>[:part,:part_title_info], :index_as=>[:displayable, :textable])
53
+ # pattern matches
54
+ t.identifier(:path=>"identifier", :attributes=>{:type=>"local"}, :type=>:string, :index_as=>[:symbol, :textable])
55
+ t.clio(:path=>"identifier", :attributes=>{:type=>"CLIO"}, :data_type=>:symbol, :index_as=>[:symbol, :textable])
56
+ t.abstract(:index_as=>[:displayable, :textable])
57
+ t.table_of_contents(:path=>"tableOfContents", :index_as=>[:displayable, :textable])
58
+ t.subject(:index_as=>[:textable]){
59
+ t.topic(:index_as=>[:facetable, :displayable])
60
+ t.geographic(:index_as=>[:facetable])
61
+ t.hierarchical_geographic(:path=>'hierarchicalGeographic', :index_as=>[]){
62
+ t.country(:index_as=>[:symbol, :textable])
63
+ t.province(:index_as=>[:symbol, :textable])
64
+ t.region(:index_as=>[:symbol, :textable])
65
+ t.state(:index_as=>[:symbol, :textable])
66
+ t.county(:index_as=>[:symbol, :textable])
67
+ t.borough(:path=>'citySection', :attributes=>{:'citySectionType'=>"borough"}, :index_as=>[:symbol, :textable])
68
+ t.city(:index_as=>[:symbol, :textable])
69
+ t.neighborhood(:path=>'citySection', :attributes=>{:'citySectionType'=>"neighborhood"}, :index_as=>[:symbol, :textable])
70
+ t.zip_code(:path=>'citySection', :attributes=>{:'citySectionType'=>"zip code"}, :index_as=>[:symbol, :textable])
71
+ t.street(:path=>'citySection', :attributes=>{:'citySectionType'=>"street"}, :index_as=>[:symbol, :textable])
72
+ }
73
+ }
74
+ t.type_of_resource(:path=>"typeOfResource", :index_as=>[:displayable])
75
+ t.physical_description(:path=>"physicalDescription", :index_as=>[]){
76
+ t.form_marc(:path=>"form", :attributes=>{:authority=>"marcform"}, :index_as=>[:displayable])
77
+ t.form_aat(:path=>"form", :attributes=>{:authority=>"aat"}, :index_as=>[:displayable, :facetable])
78
+ t.form_local(:path=>"form", :attributes=>{:authority=>"local"}, :index_as=>[:displayable, :facetable])
79
+ t.form(:attributes=>{:authority=>:none}, :index_as=>[:displayable])
80
+ t.form_nomarc(:path=>"form[@authority !='marcform']", :index_as=>[])
81
+ t.extent(:path=>"extent", :index_as=>[:searchable, :displayable])
82
+ t.reformatting_quality(:path=>"reformattingQuality", :index_as=>[:displayable])
83
+ t.internet_media_type(:path=>"internetMediaType", :index_as=>[:displayable])
84
+ t.digital_origin(:path=>"digitalOrigin", :index_as=>[:displayable])
85
+ }
86
+ t.lib_format(:proxy=>[:physical_description, :form_nomarc], :index_as=>[:displayable, :facetable, :textable])
87
+ t.location(:path=>"location", :index_as=>[]){
88
+ t.repo_text(:path=>"physicalLocation",:attributes=>{:authority=>:none}, :index_as=>[])
89
+ t.lib_repo(:path=>"physicalLocation",
90
+ :attributes=>{:authority=>"marcorg"},
91
+ :index_as=>[:textable])
92
+ t.shelf_locator(:path=>"shelfLocator", :index_as=>[:textable, :displayable])
93
+ t.sublocation(:path=>"sublocation", :index_as=>[:textable, :displayable])
94
+ t.url
95
+ }
96
+ t.top_level_location_url(:proxy=>[:mods, :location, :url])
97
+ t.lib_repo(:proxy=>[:location, :lib_repo], :type=>:text,
98
+ :index_as=>[:marc_code_textable])
99
+ t.name_usage_primary(
100
+ :path=>'name',:attributes=>{:usage=>'primary'},
101
+ :index_as=>[]){
102
+ t.name_part(:path=>'namePart', :index_as=>[])
103
+ }
104
+ t.primary_name(proxy: [:name_usage_primary,:name_part], index_as: [:facetable, :displayable])
105
+ #t.name_corporate(
106
+ # :path=>'name',:attributes=>{:type=>'corporate'},
107
+ # :index_as=>[:facetable, :displayable],
108
+ # :variant_of=>{:field_base=>:lib_name}){
109
+ # t.name_part(
110
+ # :path=>'namePart',
111
+ # :index_as=>[])
112
+ #}
113
+ t.note(:path=>"note", :index_as=>[:textable])
114
+ t.access_condition(:path=>"accessCondition", :attributes=>{:type=>"useAndReproduction"}, :index_as => [:searchable, :symbol])
115
+ t.record_info(:path=>"recordInfo", :index_as=>[]) {
116
+ t.record_creation_date(:path=>"recordCreationDate",:attributes=>{:encoding=>"w3cdtf"}, :index_as=>[])
117
+ t.record_content_source(:path=>"recordContentSource",:attributes=>{:authority=>"marcorg"}, :index_as=>[])
118
+ t.language_of_cataloging(:path=>"languageOfCataloging", :index_as=>[]){
119
+ t.language_term(:path=>"languageTerm", :index_as=>[], :attributes=>{:type=>:none})
120
+ t.language_code(:path=>"languageTerm",:attributes=>{:type=>'code',:authority=>"iso639-2b"}, :index_as=>[])
121
+ }
122
+ t.record_origin(:path=>"recordOrigin", :index_as=>[])
123
+ }
124
+ t.language_term(:proxy=>[:record_info, :language_of_cataloging, :language_term])
125
+ t.language_code(:proxy=>[:record_info, :language_of_cataloging, :language_code])
126
+
127
+ t.language(:index_as=>[]){
128
+ t.language_term_text(:path=>"languageTerm", :attributes=>{:authority=>'iso639-2b',:type=>'text'}, :index_as=>[:symbol, :textable])
129
+ t.language_term_code(:path=>"languageTerm", :attributes=>{:authority=>'iso639-2b',:type=>'code'}, :index_as=>[:symbol, :textable])
130
+ }
131
+
132
+ t.origin_info(:path=>"originInfo", :index_as=>[]){
133
+ t.date_issued(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:displayable, :textable])
134
+ t.date_issued_start(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:displayable, :textable])
135
+ t.date_issued_end(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:displayable, :textable])
136
+ t.date_issued_textual(:path=>"dateIssued", :attributes=>{:encoding=>:none, :keyDate=>:none}, :index_as=>[:textable])
137
+
138
+ t.date_created(:path=>"dateCreated", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:displayable, :textable])
139
+ t.date_created_start(:path=>"dateCreated", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:displayable, :textable])
140
+ t.date_created_end(:path=>"dateCreated", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:displayable, :textable])
141
+ t.date_created_textual(:path=>"dateCreated", :attributes=>{:encoding=>:none, :keyDate=>:none}, :index_as=>[:textable])
142
+
143
+ t.date_other(:path=>"dateOther", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:displayable, :textable])
144
+ t.date_other_start(:path=>"dateOther", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:displayable, :textable])
145
+ t.date_other_end(:path=>"dateOther", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:displayable, :textable])
146
+ t.date_other_textual(:path=>"dateOther", :attributes=>{:encoding=>:none, :keyDate=>:none}, :index_as=>[:textable])
147
+
148
+ t.publisher(:index_as=>[:displayable])
149
+ t.edition(:index_as=>[:displayable])
150
+ }
151
+ t.lib_publisher(:proxy=>[:mods, :origin_info, :publisher], :index_as=>[:displayable])
152
+ end
153
+
154
+ def self.xml_template
155
+ builder = Nokogiri::XML::Builder.new do |xml|
156
+ xml.mods(:version=>"3.4",
157
+ "xmlns"=>"http://www.loc.gov/mods/v3",
158
+ "xmlns:xlink"=>"http://www.w3.org/1999/xlink",
159
+ "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance"){
160
+ }
161
+ end
162
+ builder.doc.encoding = 'UTF-8'
163
+ # for some reason, this is the only way to get an equivalent nokogiri root node; the attribute can't be in the original builder call
164
+ builder.doc.root["xsi:schemaLocation"] = 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'
165
+ return builder.doc
166
+ end
167
+
168
+ def prefix
169
+ #if ::ActiveFedora::VERSION >= '8'
170
+ # Rails.logger.warn("the prefix method of #{self.class.name} was overriden to maintain backwards compatibility")
171
+ #end
172
+ ''
173
+ end
174
+
175
+ def method_missing method, *args
176
+ query = false
177
+ _mname = method.id2name
178
+ if _mname[-1,1] == '?'
179
+ query = true
180
+ _mname = _mname[0,_mname.length-1]
181
+ end
182
+ _msym = _mname.to_sym
183
+ has_term = self.class.terminology.has_term?(_msym)
184
+ return false if query and not has_term
185
+ _r = super(_mname.to_sym, *args)
186
+ if query
187
+ _r.length > 0
188
+ else
189
+ _r
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end
@@ -0,0 +1,176 @@
1
+ module Cul
2
+ module Hydra
3
+ module Datastreams
4
+ class StructMetadata < ::ActiveFedora::Datastream
5
+ include ::ActiveFedora::Datastreams::NokogiriDatastreams
6
+
7
+ def self.default_attributes
8
+ super.merge(:controlGroup => 'M', :mimeType => 'text/xml')
9
+ end
10
+
11
+ def self.xml_template
12
+ Nokogiri::XML::Document.parse("<mets:structMap xmlns:mets=\"http://www.loc.gov/METS/\">")
13
+ end
14
+
15
+ def self.div_template(prefix="mets")
16
+ prefix.nil? ? '<div/>' : "<#{prefix}:div/>"
17
+ end
18
+
19
+ def initialize(digital_object=nil, dsid=nil, options={})
20
+ super
21
+ end
22
+
23
+ # Indicates that this datastream has metadata content.
24
+ # @return true
25
+ def metadata?
26
+ true
27
+ end
28
+
29
+ def autocreate?
30
+ changed_attributes.has_key? :profile
31
+ end
32
+
33
+ def label=(value)
34
+ struct_map["LABEL"] = value
35
+ ng_xml_will_change!
36
+ end
37
+
38
+ def label
39
+ struct_map["LABEL"]
40
+ end
41
+
42
+ def type=(value)
43
+ struct_map["TYPE"] = value
44
+ ng_xml_will_change!
45
+ end
46
+
47
+ def type
48
+ struct_map["TYPE"]
49
+ end
50
+
51
+ def prefix
52
+ prefix = nil
53
+ ng_xml.namespaces.each do |p, href|
54
+ prefix = p.sub(/xmlns:/,'') if href == "http://www.loc.gov/METS/"
55
+ end
56
+ prefix
57
+ end
58
+
59
+ def struct_map
60
+ prefix = self.prefix
61
+ path = prefix.nil? ? 'xmlns:structMap' : "#{prefix}:structMap"
62
+ ng_xml.xpath(path, ng_xml.namespaces).first
63
+ end
64
+
65
+ def create_div_node(parent=nil, atts={})
66
+ if parent.nil?
67
+ parent = struct_map
68
+ end
69
+ divNode = parent.add_child(StructMetadata.div_template(parent.namespace.prefix)).first
70
+ [:label, :order, :contentids]. each do |key|
71
+ divNode[key.to_s.upcase] = atts[key].to_s if atts.has_key? key
72
+ end
73
+ ng_xml_will_change! if (divNode.document == ng_xml.document)
74
+ divNode
75
+ end
76
+
77
+ def divs_with_attribute(descend=true, name=nil, value=nil)
78
+ prefix = self.prefix || 'xmlns'
79
+ xpath = descend ? "//#{prefix}:div" : "/#{prefix}:structMap/#{prefix}:div"
80
+ if !name.nil?
81
+ xpath << "[@#{name}"
82
+ if !value.nil?
83
+ xpath << "='#{value}'"
84
+ end
85
+ xpath << ']'
86
+ end
87
+ ng_xml.xpath(xpath, ng_xml.namespaces)
88
+ end
89
+
90
+ def first_ordered_content_div
91
+ divs_with_contentids_attr = self.divs_with_attribute(true, 'CONTENTIDS')
92
+ sorted_divs_with_contentids_attr = divs_with_contentids_attr.sort_by{ |node|
93
+ node.attr("ORDER").to_i
94
+ }
95
+ return sorted_divs_with_contentids_attr.first
96
+ end
97
+
98
+ # a convenience method for setting attributes and creating divs (if necessary) for R/V structure
99
+ # returns the mets:structMap node
100
+ def recto_verso!
101
+ self.type= 'physical' unless self.type == 'physical'
102
+ self.label= 'Sides' unless self.label == 'Sides'
103
+ create_div_node struct_map, {:order=>'1'} unless divs_with_attribute(false,'ORDER','1').first
104
+ create_div_node struct_map, {:order=>'2'} unless divs_with_attribute(false,'ORDER','2').first
105
+ if (div = divs_with_attribute(false,'ORDER','1').first)
106
+ div['LABEL'] = 'Recto' unless div['LABEL'] == 'Recto'
107
+ end
108
+ if (div = divs_with_attribute(false,'ORDER','2').first)
109
+ div['LABEL'] = 'Verso' unless div['LABEL'] == 'Verso'
110
+ end
111
+ struct_map
112
+ end
113
+
114
+ def recto
115
+ divs_with_attribute(false, 'LABEL', 'Recto').first
116
+ end
117
+
118
+ def verso
119
+ divs_with_attribute(false, 'LABEL', 'Verso').first
120
+ end
121
+
122
+ def to_solr(doc={})
123
+ doc[:structured_bsi] = (has_content? ? 'true' : 'false')
124
+ doc
125
+ end
126
+
127
+ def proxies
128
+ divs = divs_with_attribute(true)
129
+ graph_context_uri = RDF::URI("info:fedora/#{self.pid}")
130
+ file_system = self.type.eql?(RDF::NFO[:"#Filesystem"].to_s)
131
+ divs.collect do |div|
132
+ proxy_uri_chain = proxy_uri_chain_for(div)
133
+ proxy_resource_uri = proxy_uri_chain.pop
134
+ if div['CONTENTIDS']
135
+ subclass = file_system ?
136
+ NFO::FileDataObject : SC::Canvas
137
+ proxy = subclass.new(proxy_resource_uri, graph_context_uri)
138
+ proxy.proxyFor = RDF::URI(div['CONTENTIDS'])
139
+ else
140
+ subclass = file_system ?
141
+ NFO::Folder : SC::Sequence
142
+ proxy = subclass.new(proxy_resource_uri, graph_context_uri)
143
+ end
144
+ if div.parent and div.parent.name == 'div'
145
+ proxy.belongsToContainer = proxy_uri_for(div.parent)
146
+ end
147
+ proxy.isPartOf = proxy_uri_chain unless proxy_uri_chain.empty?
148
+ proxy.index = div['ORDER']
149
+ proxy.label = div['LABEL']
150
+ proxy
151
+ end
152
+ end
153
+
154
+ private
155
+ def ancestors(node)
156
+ current = node
157
+ labels = []
158
+ while (current.name == 'div')
159
+ labels.unshift URI.escape(current['LABEL'])
160
+ current = current.parent
161
+ end
162
+ labels
163
+ end
164
+ def proxy_uri_chain_for(node)
165
+ uris = []
166
+ ancestors(node).inject(RDF::URI("info:fedora/#{self.pid}/#{self.dsid}")) {|m,a| (uris << m/a).last}
167
+ uris
168
+ end
169
+ def proxy_uri_for(node)
170
+ # uri = segments.inject(base_uri) {|m,a| m/a}
171
+ ancestors(node).inject(RDF::URI("info:fedora/#{self.pid}/#{self.dsid}")) {|m,a| m/a}
172
+ end
173
+ end
174
+ end
175
+ end
176
+ end