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,108 @@
1
+ module Cul::Hydra::Models::LinkableResources
2
+ include Cul::Hydra::Fedora::UrlHelperBehavior
3
+ # so as to avoid including all the url hepers via:
4
+ ## include Rails.application.routes.url_helpers
5
+ # we are just going to delegate
6
+ delegate :fedora_content_path, :to => 'Rails.application.routes.url_helpers'
7
+ delegate :cache_path, :to => 'Rails.application.routes.url_helpers'
8
+
9
+ def http_client
10
+ unless @http_client
11
+ @http_client ||= HTTPClient.new
12
+ @http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
13
+ uname = Cul::Hydra::Fedora.repository.config[:user]
14
+ pwd = Cul::Hydra::Fedora.repository.config[:password]
15
+ @http_client.set_auth(nil, uname, pwd)
16
+ end
17
+ @http_client
18
+ end
19
+
20
+ def linkable_resources
21
+ r = self.parts(:response_format => :solr)
22
+ return [] if r.blank?
23
+ members = r.collect {|hit|
24
+ SolrDocument.new(hit)
25
+ }
26
+ members.delete_if { |sd| (sd[:has_model_ssim] & ["info:fedora/ldpd:Resource"]).blank? }
27
+ case self.route_as
28
+ when "zoomingimage"
29
+ results = members.collect {|doc| image_resource(doc)}
30
+ base_id = self.pid
31
+ url = fedora_ds_url(base_id, 'SOURCE') + '/content'
32
+ head_req = http_client().head(url)
33
+ file_size = head_req.header["Content-Length"].first.to_i
34
+ results << {
35
+ :dimensions => "Original",
36
+ :mime_type => "image/jp2",
37
+ :uri=>base_id, :block=>"SOURCE", :filename=>base_id + "_source.jp2",
38
+ :content_models=>[]}
39
+ when "audio"
40
+ results = members.collect {|doc| audio_resource(doc)}
41
+ when "image"
42
+ results = members.collect {|doc| image_resource(doc)}
43
+ else
44
+ raise "Unknown format #{self.route_as}"
45
+ end
46
+ return results
47
+ end
48
+
49
+ def basic_resource(document)
50
+ res = {}
51
+ res[:pid] = document["id"]
52
+ res[:dsid] = "CONTENT"
53
+ res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
54
+ res[:content_models] = document["has_model_ssim"]
55
+ res[:file_size] = document["extent_ssim"].first.to_i
56
+ res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
57
+ res
58
+ end
59
+
60
+ def image_resource(document)
61
+ res = basic_resource(document)
62
+ if document["image_width_ssim"]
63
+ res[:dimensions] = document["image_width_ssim"].first + " x " + document["image_length_ssim"].first
64
+ res[:width] = document["image_width_ssim"].first
65
+ res[:height] = document["image_length_ssim"].first
66
+ else
67
+ res[:dimensions] = "? x ?"
68
+ res[:width] = "0"
69
+ res[:height] = "0"
70
+ end
71
+ base_id = document["id"]
72
+ base_filename = base_id.gsub(/\:/,"")
73
+ img_filename = base_filename + "." + document["dc_format_ssm"].first.gsub(/^[^\/]+\//,"")
74
+ res[:filename] = img_filename
75
+ res[:block] = "CONTENT"
76
+ res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
77
+ res[:content_models] = document["has_model_ssim"]
78
+ res[:file_size] = document["extent_ssim"].first.to_i
79
+ res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
80
+ res[:uri] = base_id
81
+ res
82
+ end
83
+
84
+ def audio_resource(document)
85
+ res = basic_resource(document)
86
+ base_id = document["id"]
87
+ base_filename = base_id.gsub(/\:/,"")
88
+ if res[:mime_type] =~ /wav/
89
+ ext = 'wav'
90
+ elsif res[:mime_type] =~ /mpeg/
91
+ ext = 'mp3'
92
+ else
93
+ ext = 'bin'
94
+ end
95
+ filename = base_filename + "." + ext
96
+ dc_filename = base_filename + "_dc.xml"
97
+ res[:uri] = base_id
98
+ res[:block] = "CONTENT"
99
+ res[:filename] = filename
100
+ res[:dc_path] = fedora_content_path(:download_method=>"show_pretty", :uri=>base_id, :block=>"DC", :filename=>dc_filename)
101
+ res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
102
+ res[:content_models] = document["has_model_ssim"]
103
+ res[:file_size] = document["extent_ssim"].first.to_i
104
+ res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
105
+ res
106
+ end
107
+
108
+ end
@@ -0,0 +1,87 @@
1
+ module Cul::Hydra::Models::Resource
2
+ extend ActiveSupport::Concern
3
+ # constants #
4
+ IMAGE_MIME_TYPES = [
5
+ 'image/bmp',
6
+ 'image/gif',
7
+ 'image/jpeg',
8
+ 'image/png',
9
+ 'image/tiff'
10
+ ]
11
+
12
+ included do
13
+ if self.is_a? ::ActiveFedora::SemanticNode
14
+ props = {
15
+ "image_width" => :image_width,
16
+ "image_length" => :image_length,
17
+ "x_sampling" => :x_sampling,
18
+ "y_sampling" => :y_sampling,
19
+ "sampling_unit" => :sampling_unit,
20
+ "extent" => :extent,
21
+ }
22
+ props.each { |x, y|
23
+ class_eval %Q{
24
+ def #{x}
25
+ return relationships[:#{y.to_s}]
26
+ }
27
+ }
28
+
29
+ after_create :resource!
30
+ end
31
+ if self.respond_to? :has_datastream
32
+ has_datastream :name => "CONTENT", :type=>::ActiveFedora::Datastream, :versionable => true
33
+ end
34
+ end
35
+
36
+ def resource!
37
+ add_relationship(:rdf_type, Cul::Hydra::Models::RESOURCE_TYPE.to_s)
38
+ @metadata_is_dirty = true
39
+ update
40
+ end
41
+
42
+ def add_content_blob(blob, opts)
43
+ file_name = opts[:file_name]
44
+ mime = opts[:mime_type].nil? ? mime_type(file_name) : opts[:mime_type]
45
+ add_file_datastream(blob, :label=>file_name, :mimeType=>mime, :dsid => 'CONTENT')
46
+ set_title_and_label( file_name, :only_if_blank=>true )
47
+ if IMAGE_MIME_TYPES.include? mime
48
+ blob.rewind
49
+ # retrieve Nokogiri of image property RDF
50
+ image_properties = Cul::Image::Properties.identify(blob)
51
+ if image_properties
52
+ image_prop_nodes = image_properties.nodeset
53
+ relsext = datastreams['RELS-EXT']
54
+ image_prop_nodes.each { |node|
55
+ if node["resource"]
56
+ is_literal = false
57
+ object = RDF::URI.new(node["resource"])
58
+ else
59
+ is_literal = true
60
+ object = RDF::Literal(node.text)
61
+ end
62
+ subject = RDF::URI(internal_uri)
63
+ predicate = RDF::URI("#{node.namespace.href}#{node.name}")
64
+ query = RDF::Query.new({ :subject => {predicate => :object}})
65
+ relationships(predicate).dup.each { |stmt|
66
+ relationships.delete(stmt)
67
+ }
68
+ add_relationship(predicate,object, is_literal)
69
+ relationships_are_dirty=true
70
+ }
71
+ # add mimetype to DC:format values
72
+ self.datastreams['DC'].update_values({[:format] => mime})
73
+ end
74
+ end
75
+ blob.rewind
76
+ end
77
+
78
+ private
79
+
80
+ # Return the mimeType for a given file name
81
+ # @param [String] file_name The filename to use to get the mimeType
82
+ # @return [String] mimeType for filename passed in. Default: application/octet-stream if mimeType cannot be determined
83
+ def mime_type file_name
84
+ mime_types = MIME::Types.of(file_name)
85
+ mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
86
+ end
87
+ end
@@ -0,0 +1,17 @@
1
+ module NFO
2
+ module Common
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ property :belongsToContainer, predicate: RDF::NFO[:"#belongsToContainer"], multivalue: false do |ix|
6
+ ix.as :stored_sortable
7
+ end
8
+ end
9
+
10
+ def to_solr(solr_doc={})
11
+ solr_doc = super(solr_doc)
12
+ if solr_doc['']
13
+ end
14
+ solr_doc
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module NFO
2
+ class FileDataObject < ORE::Proxy
3
+ include NIE::InformationElement
4
+ include NFO::Common
5
+ def initialize(proxy_for_uri, context_uri, *args)
6
+ super(proxy_for_uri, context_uri, *args)
7
+ self.get_values(:type) << RDF::NFO[:"#FileDataObject"]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module NFO
2
+ class Folder < ORE::Proxy
3
+ include NIE::InformationElement
4
+ include NFO::Common
5
+ def initialize(proxy_for_uri, context_uri, *args)
6
+ super(proxy_for_uri, context_uri, *args)
7
+ self.get_values(:type) << RDF::NFO[:"#Folder"]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module NIE
2
+ module InformationElement
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ property :isPartOf, predicate: RDF::NIE[:"#isPartOf"], multivalue: true do |ix|
6
+ ix.as :symbol
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,124 @@
1
+ # A named graph describing the location of a Resource in a virtual nested structure
2
+ require 'digest'
3
+ require 'active_triples'
4
+ module ORE
5
+ class Proxy < ActiveTriples::Resource
6
+ include Digest
7
+ include Solrizer::Common
8
+ include ActiveFedora::Rdf::Indexing
9
+
10
+ module Id
11
+ class Descriptor < Solrizer::Descriptor
12
+ def name_and_converter(field_name, field_type)
13
+ ['id']
14
+ end
15
+ end
16
+ def self.id_for2(proxy_in, proxy_for)
17
+ path = proxy_for.to_s
18
+ path = path.sub(/^info.fedora\/[^\/]+\/structMetadata\//,'')
19
+ "urn:proxy:#{proxy_in ? Digest::MD5.hexdigest(proxy_in.to_s) : '' }:#{path}"
20
+ end
21
+ end
22
+ def self.type
23
+ RDF::ORE.Proxy
24
+ end
25
+ property :id, predicate: RDF.nodeID, multivalue: false do |ix|
26
+ ix.as Id::Descriptor.new
27
+ end
28
+ property :isAggregatedBy, predicate: RDF::ORE.isAggregatedBy, multivalue: false do |ix|
29
+ ix.as :stored_sortable
30
+ end
31
+ property :lineage, predicate: RDF::ORE.lineage, multivalue: false do |ix|
32
+ ix.as :stored_sortable
33
+ end
34
+ property :proxyFor, predicate: RDF::ORE.proxyFor, multivalue: false do |ix|
35
+ ix.as :stored_sortable
36
+ end
37
+ property :proxyIn, predicate: RDF::ORE.proxyIn, multivalue: false do |ix|
38
+ ix.as :stored_sortable
39
+ end
40
+ property :index, predicate: RDF::OLO.index, multivalue: false do |ix|
41
+ ix.as :stored_sortable
42
+ ix.type :integer
43
+ end
44
+ property :format, predicate: RDF::DC.format, multivalue: false do |ix|
45
+ ix.as :stored_sortable
46
+ end
47
+ property :extent, predicate: RDF::DC.extent, multivalue: false do |ix|
48
+ ix.as :displayable
49
+ end
50
+ property :label, predicate: RDF::RDFS.label, multivalue: false do |ix|
51
+ ix.as :stored_sortable
52
+ end
53
+ property :hasModel, predicate: RDF::FCREPO3::MODEL.hasModel, multivalue: false do |ix|
54
+ ix.as :stored_sortable
55
+ end
56
+
57
+ def initialize(proxy_resource_uri, graph_context_uri, *args)
58
+ proxy_resource_uri = RDF::URI(proxy_resource_uri)
59
+ super(proxy_resource_uri,*args)
60
+ update(RDF::Statement(rdf_subject,RDF.nodeID,proxy_resource_uri))
61
+ self.proxyIn = graph_context_uri
62
+ self.proxyFor = proxy_resource_uri
63
+ end
64
+
65
+ # override to obscure attempts to identify a containing Datastream
66
+ def apply_prefix(name)
67
+ name
68
+ end
69
+
70
+ def resource
71
+ self
72
+ end
73
+
74
+ def to_json
75
+ to_solr.with_indifferent_access
76
+ end
77
+
78
+ def to_solr(solr_doc = {}) # :nodoc:
79
+ fields.each do |field_key, field_info|
80
+ values = resource.get_values(field_key.to_sym).result || []
81
+ values = [values] unless values.is_a? Array
82
+ values.each do |val|
83
+ if val.kind_of? RDF::URI
84
+ val = val.to_s
85
+ elsif val.kind_of? ActiveTriples::Resource
86
+ val = val.solrize
87
+ end
88
+ self.class.create_and_insert_terms(apply_prefix(field_key), val, field_info[:behaviors], solr_doc)
89
+ end
90
+ end
91
+ solr_doc
92
+ end
93
+ # returns a Hash, e.g.: {field => {:values => [], :type => :something, :behaviors => []}, ...}
94
+ def fields
95
+ field_map = {}.with_indifferent_access
96
+ insert_field_map(:type, type_config(),field_map)
97
+ self.class.properties.each do |name, config|
98
+ insert_field_map(name, config, field_map)
99
+ end
100
+ field_map
101
+ end
102
+
103
+ def insert_field_map(name, config, field_map={})
104
+ type = config[:type]
105
+ behaviors = config[:behaviors]
106
+ return field_map unless type and behaviors
107
+ return field_map if config[:class_name] && config[:class_name] < ActiveFedora::Base
108
+ resource.query(:subject => rdf_subject, :predicate => config[:predicate]).each_statement do |statement|
109
+ field_map[name] ||= {:values => [], :type => type, :behaviors => behaviors, term: config[:term]}
110
+ field_map[name][:values] << statement.object.to_s
111
+ end
112
+ field_map
113
+ end
114
+
115
+ def type_config
116
+ @type_node_config ||= begin
117
+ config = ActiveTriples::NodeConfig.new(:type, RDF.type)
118
+ config.with_index {|ix| ix.as :symbol }
119
+ config
120
+ end
121
+ end
122
+
123
+ end
124
+ end
@@ -0,0 +1,77 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # This file generated automatically using vocab-fetch from http://www.semanticdesktop.org/ontologies/2007/03/22/nfo
3
+ require 'rdf'
4
+ module RDF
5
+ class CUL < RDF::StrictVocabulary("http://purl.oclc.org/NET/CUL/")
6
+ term :Aggregator,
7
+ comment: %(An collection of Aggregators or Resources).freeze,
8
+ label: "Aggregator".freeze,
9
+ type: "rdfs:Class".freeze
10
+ term :Resource,
11
+ comment: %(A file-like Resource).freeze,
12
+ label: "Resource".freeze,
13
+ type: "rdfs:Class".freeze
14
+ property :hasMember,
15
+ comment: %(The object is a member of the subject Aggregator.).freeze,
16
+ domain: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
17
+ label: "hasMember".freeze,
18
+ range: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
19
+ subPropertyOf: "info:fedora/fedora-system:def/relations-external#hasMember".freeze,
20
+ type: "rdf:Property".freeze
21
+ property :memberOf,
22
+ comment: %(The subject is a member of the object Aggregator.).freeze,
23
+ domain: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
24
+ label: "memberOf".freeze,
25
+ range: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
26
+ subPropertyOf: "info:fedora/fedora-system:def/relations-external#isMemberOf".freeze,
27
+ type: "rdf:Property".freeze
28
+ property :obsoleteFrom,
29
+ comment: %(The subject is an obsolete member of the object Aggregator.).freeze,
30
+ domain: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
31
+ label: "obsoleteFrom".freeze,
32
+ range: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
33
+ subPropertyOf: "info:fedora/fedora-system:def/relations-external#isMemberOf".freeze,
34
+ type: "rdf:Property".freeze
35
+ property :metadataFor,
36
+ comment: %(The subject is an obsolete description of the object.).freeze,
37
+ domain: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
38
+ label: "metadataFor".freeze,
39
+ range: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
40
+ subPropertyOf: "info:fedora/fedora-system:def/relations-external#isMetadataFor".freeze,
41
+ type: "rdf:Property".freeze
42
+ module RESOURCE
43
+ module STILLIMAGE
44
+ class BASIC < RDF::StrictVocabulary("http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/")
45
+ property :imageWidth,
46
+ label: "imageWidth",
47
+ type: "rdf:Property".freeze
48
+ property :imageLength,
49
+ label: "imageLength",
50
+ type: "rdf:Property".freeze
51
+ end
52
+ class ASSESSMENT < RDF::StrictVocabulary("http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/ASSESSMENT/")
53
+ property :xSamplingFrequency,
54
+ label: "xSamplingFrequency",
55
+ type: "rdf:Property".freeze
56
+ property :ySamplingFrequency,
57
+ label: "ySamplingFrequency",
58
+ type: "rdf:Property".freeze
59
+ property :samplingFrequencyUnit,
60
+ label: "samplingFrequencyUnit",
61
+ type: "rdf:Property".freeze
62
+ end
63
+ end
64
+ end
65
+ # An addition to FOAF used locally at CUL
66
+ class FOAF < RDF::StrictVocabulary("http://xmlns.com/foaf/0.1/")
67
+ property :zoomingImage,
68
+ comment: %(A derived zoomable image.).freeze,
69
+ domain: "foaf:Image".freeze,
70
+ label: "zoomingImage".freeze,
71
+ range: "foaf:Image".freeze,
72
+ "rdfs:isDefinedBy" => %(foaf:).freeze,
73
+ type: ["rdf:Property".freeze, "owl:ObjectProperty".freeze],
74
+ "vs:term_status" => %(testing).freeze
75
+ end
76
+ end
77
+ end