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,41 @@
1
+ module Cul
2
+ module Hydra
3
+ module Fedora
4
+ autoload :DummyObject, 'cul_hydra/fedora/dummy_object'
5
+ autoload :RubydoraPatch, 'cul_hydra/fedora/rubydora_patch'
6
+ autoload :UrlHelperBehavior, 'cul_hydra/fedora/url_helper_behavior'
7
+ module ClassMethods
8
+ def config_path
9
+ File.join(Rails.root.to_s, 'config', 'fedora.yml')
10
+ end
11
+ def config
12
+ ActiveFedora.fedora_config.credentials
13
+ end
14
+ def connection
15
+ @connection ||= ActiveFedora::RubydoraConnection.new(ActiveFedora.fedora_config.credentials)
16
+ end
17
+
18
+ def repository
19
+ @repository ||= begin
20
+ repo = connection.connection
21
+ repo.extend(RubydoraPatch)
22
+ repo
23
+ end
24
+ end
25
+
26
+ def ds_for_uri(fedora_uri, fake_obj=nil)
27
+ return nil unless fedora_uri =~ /info\:fedora\/.*/
28
+ p = fedora_uri.split('/')
29
+ return ds_for_opts({pid: p[1], dsid: p[2]})
30
+ end
31
+
32
+ def ds_for_opts(opts={}, fake_obj=nil)
33
+ return nil unless opts[:pid] and opts[:dsid]
34
+ fake_obj = fake_obj.nil? ? DummyObject.new(opts[:pid]) : fake_obj.spawn(opts[:pid])
35
+ return (opts[:class] || ::Rubydora::Datastream).new(fake_obj, opts[:dsid])
36
+ end
37
+ end
38
+ extend ClassMethods
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ module Cul
2
+ module Hydra
3
+ module Fedora
4
+ class DummyObject
5
+ attr_accessor :pid
6
+ def initialize(pid, isNew=false)
7
+ @pid = pid
8
+ @isNew = isNew
9
+ end
10
+ def new_record?
11
+ @isNew
12
+ end
13
+ def new_record=(val)
14
+ @isNew = val
15
+ end
16
+ def internal_uri
17
+ @uri ||= "info:fedora/#{@pid}"
18
+ end
19
+ def connection
20
+ Cul::Hydra::Fedora.connection
21
+ end
22
+ def repository
23
+ Cul::Hydra::Fedora.repository
24
+ end
25
+ def spawn(pid)
26
+ s = DummyObject.new(pid, @isNew)
27
+ s.connection= connection
28
+ s.repository= repository
29
+ s
30
+ end
31
+ protected
32
+ def connection=(connection); @connection = connection; end
33
+ def repository=(repo); @repository = repo; end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,16 @@
1
+ module Cul
2
+ module Hydra
3
+ module Fedora
4
+ module RubydoraPatch
5
+ def find_by_itql query, options = {}
6
+ begin
7
+ self.risearch(query, {:lang => 'itql'}.merge(options))
8
+ rescue Exception => e
9
+ logger.error e if defined?(logger)
10
+ "{\"results\":[]}"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ module Cul
2
+ module Hydra
3
+ module Fedora
4
+ module UrlHelperBehavior
5
+
6
+ def fedora_url
7
+ @fedora_url ||= ActiveFedora.config.credentials[:url]
8
+ end
9
+
10
+ def pid_for_url(pid)
11
+ pid.gsub(/^\//,'').gsub(/info:fedora\//,'')
12
+ end
13
+
14
+ def fedora_object_url(pid)
15
+ fedora_url + '/objects/' + pid_for_url(pid)
16
+ end
17
+
18
+ def fedora_ds_url(pid, dsid)
19
+ fedora_object_url(pid) + '/datastreams/' + dsid
20
+ end
21
+
22
+ def fedora_method_url(pid, method)
23
+ fedora_object_url(pid) + '/methods/' + method
24
+ end
25
+
26
+ def fedora_risearch_url
27
+ fedora_url + '/risearch'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,102 @@
1
+ module Cul::Hydra::Indexer
2
+
3
+ NUM_FEDORA_RETRY_ATTEMPTS = 3
4
+ DELAY_BETWEEN_FEDORA_RETRY_ATTEMPTS = 5.seconds
5
+
6
+ def self.descend_from(pid, pids_to_omit=nil, verbose_output=false)
7
+ if pid.blank?
8
+ raise 'Please supply a pid (e.g. rake recursively_index_fedora_objects pid=ldpd:123)'
9
+ end
10
+
11
+ begin
12
+
13
+ unless ActiveFedora::Base.exists?(pid)
14
+ raise 'Could not find Fedora object with pid: ' + pid
15
+ end
16
+
17
+ if pids_to_omit.present? && pids_to_omit.include?(pid)
18
+ puts 'Skipping topmost object in this set (' + pid + ') because it has been intentionally omitted...' if verbose_output
19
+ else
20
+ puts 'Indexing topmost object in this set (' + pid + ')...' if verbose_output
21
+ puts 'If this is a BagAggregator with a lot of members, this may take a while...' if verbose_output
22
+
23
+ yield pid
24
+
25
+ end
26
+
27
+ puts 'Recursively retreieving and indexing all members of ' + pid + '...'
28
+
29
+ unique_pids = Cul::Hydra::RisearchMembers.get_recursive_member_pids(pid, true)
30
+
31
+ total_number_of_members = unique_pids.length
32
+ puts 'Recursive search found ' + total_number_of_members.to_s + ' members.' if verbose_output
33
+
34
+ if pids_to_omit.present?
35
+ unique_pids = unique_pids - pids_to_omit
36
+ total_number_of_members = unique_pids.length
37
+ puts 'After checking against the list of omitted pids, the total number of objects to index will be: ' + total_number_of_members.to_s if verbose_output
38
+ end
39
+
40
+ i = 1
41
+ if total_number_of_members > 0
42
+ unique_pids.each {|pid|
43
+
44
+ puts 'Recursing on ' + i.to_s + ' of ' + total_number_of_members.to_s + ' members (' + pid + ')...' if verbose_output
45
+
46
+ yield pid
47
+
48
+ i += 1
49
+ }
50
+ end
51
+
52
+ rescue RestClient::Unauthorized => e
53
+ error_message = "Skipping #{pid} due to error: " + e.message + '. Problem with Fedora object?'
54
+ puts error_message
55
+ logger.error error_message if defined?(logger)
56
+ end
57
+
58
+ puts 'Recursion complete!'
59
+
60
+ end
61
+ def self.recursively_index_fedora_objects(top_pid, pids_to_omit=nil, skip_generic_resources=false, verbose_output=false)
62
+
63
+ descend_from(top_pid, pids_to_omit, verbose_output) do |pid|
64
+ self.index_pid(pid, skip_generic_resources, verbose_output)
65
+ end
66
+
67
+ end
68
+
69
+ def self.index_pid(pid, skip_generic_resources=false, verbose_output=false)
70
+ # We found an object with the desired PID. Let's reindex it
71
+ begin
72
+ active_fedora_object = nil
73
+
74
+ NUM_FEDORA_RETRY_ATTEMPTS.times { |i|
75
+ begin
76
+ active_fedora_object = ActiveFedora::Base.find(pid, :cast => true)
77
+ break
78
+ rescue RestClient::RequestTimeout, Errno::EHOSTUNREACH => e
79
+ remaining_attempts = (NUM_FEDORA_RETRY_ATTEMPTS-1) - i
80
+ if remaining_attempts == 0
81
+ raise e
82
+ else
83
+ Rails.logger.error "Error: Could not connect to fedora. (#{e.class.to_s + ': ' + e.message}). Will retry #{remaining_attempts} more #{remaining_attempts == 1 ? 'time' : 'times'} (after a #{DELAY_BETWEEN_FEDORA_RETRY_ATTEMPTS} second delay)."
84
+ sleep DELAY_BETWEEN_FEDORA_RETRY_ATTEMPTS
85
+ end
86
+ end
87
+ }
88
+
89
+ if skip_generic_resources && active_fedora_object.is_a?(GenericResource)
90
+ puts 'Object was skipped because GenericResources are being skipped and it is a GenericResource.'
91
+ else
92
+ active_fedora_object.update_index
93
+ puts 'done.' if verbose_output
94
+ end
95
+ rescue SystemExit, Interrupt => e
96
+ # Allow system interrupt (ctrl+c)
97
+ raise e
98
+ rescue Exception => e
99
+ puts "Encountered problem with #{pid}. Skipping record. Exception: #{e.message}"
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,7 @@
1
+ module Cul
2
+ module Hydra
3
+ module Om
4
+ autoload :StandardMods, "cul_hydra/om/standard_mods"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,115 @@
1
+ require 'active-fedora'
2
+ require 'solrizer'
3
+ require 'cul_hydra/solrizer_patch'
4
+ module Cul
5
+ module Hydra
6
+ module Om
7
+ class StandardMods < ::ActiveFedora::OmDatastream
8
+
9
+ set_terminology do |t|
10
+ t.root(:path=>"mods",
11
+ :xmlns=>"http://www.loc.gov/mods/v3",
12
+ :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-4.xsd")
13
+ t.identifier(:path=>"identifier", :attributes=>{:type=>"local"}, :data_type=>:symbol)
14
+ t.clio(:path=>"identifier", :attributes=>{:type=>"CLIO"}, :data_type=>:symbol)
15
+ t.title_info(:path=>"titleInfo", :index_as=>[:not_searchable]) {
16
+ t.main_title(:path=>"title", :index_as=>[:not_searchable])
17
+ }
18
+ t.title(:path=>'mods/oxns:titleInfo/oxns:title', :index_as=>[:searchable,:displayable, :sortable])
19
+ t.abstract
20
+ t.subject {
21
+ t.topic
22
+ }
23
+ t.type_of_resource(:path=>"typeOfResource", :index_as=>[:not_searchable])
24
+ t.physical_description(:path=>"physicalDescription", :index_as=>[:not_searchable]){
25
+ t.form_marc(:path=>"form", :attributes=>{:authority=>"marcform"}, :index_as=>[:not_searchable])
26
+ t.form_nomarc(:path=>"form[@authority !='marcform']", :index_as=>[:not_searchable, :displayable, :facetable, :textable])
27
+ t.extent(:path=>"extent", :index_as=>[:not_searchable])
28
+ t.reformatting_quality(:path=>"reformattingQuality", :index_as=>[:not_searchable])
29
+ t.internet_media_type(:path=>"internetMediaType", :index_as=>[:not_searchable])
30
+ t.digital_origin(:path=>"digitalOrigin", :index_as=>[:not_searchable])
31
+ }
32
+ t.lib_format(proxy: [:physical_description, :form_nomarc] )
33
+ t.location(:path=>"location", :index_as=>[:not_searchable]){
34
+ t.repo_text(:path=>"physicalLocation",:attributes=>{:authority=>:none}, :index_as=>[:not_searchable])
35
+ t.repo_code(:path=>"physicalLocation",:attributes=>{:authority=>"marcorg"}, :index_as=>[:not_searchable])
36
+ }
37
+ t.lib_repo_text(:ref=>[:location, :repo_text], :label=>"lib_repo", :index_as=>[:searchable])
38
+ t.lib_repo(:ref=>[:location, :repo_code], :index_as=>[:not_searchable,:facetable, :displayable])
39
+ t.project_host(:path=>"relatedItem", :attributes=>{:type=>"host", :displayLabel=>"Project"}, :index_as=>[:not_searchable]){
40
+ t.p_title(:path=>'titleInfo',:index_as=>[:not_searchable])
41
+ }
42
+ t.lib_project(:proxy=>[:project_host, :p_title],:index_as=>[:facetable,:displayable, :not_searchable])
43
+ t.collection_host(:path=>"relatedItem", :attributes=>{:type=>"host", :displayLabel=>"Collection"}, :index_as=>[:not_searchable]){
44
+ t.c_title(:path=>'titleInfo',:index_as=>[:not_searchable])
45
+ }
46
+ t.lib_project(:path=>"mods/oxns:relatedItem[@type='host'][@displayLabel='Project']/oxns:titleInfo/oxns:title",:index_as=>[:facetable,:displayable, :not_searchable])
47
+ t.lib_collection(:path=>"mods/oxns:relatedItem[@type='host'][@displayLabel='Collection']/oxns:titleInfo/oxns:title",:index_as=>[:facetable,:displayable, :not_searchable])
48
+ t.note(:path=>"note")
49
+ t.access_condition(:path=>"accessCondition", :attributes=>{:type=>"useAndReproduction"}, :index_as => [:searchable], :data_type => :symbol)
50
+ t.record_info(:path=>"recordInfo", :index_as=>[:not_searchable]) {
51
+ t.record_creation_date(:path=>"recordCreationDate",:attributes=>{:encoding=>"w3cdtf"}, :index_as=>[:not_searchable])
52
+ t.record_content_source(:path=>"recordContentSource",:attributes=>{:authority=>"marcorg"}, :index_as=>[:not_searchable])
53
+ t.language_of_cataloging(:path=>"languageOfCataloging", :index_as=>[:not_searchable]){
54
+ t.language_term(:path=>"languageTerm", :index_as=>[:not_searchable], :attributes=>{:type=>:none})
55
+ t.language_code(:path=>"languageTerm",:attributes=>{:type=>'code',:authority=>"iso639-2b"}, :index_as=>[:not_searchable])
56
+ }
57
+ t.record_origin(:path=>"recordOrigin", :index_as=>[:not_searchable])
58
+ }
59
+
60
+ t.origin_info(:path=>"originInfo", :index_as=>[:not_searchable]){
61
+ t.date(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf'}, :index_as=>[:not_searchable])
62
+ t.key_date(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:not_searchable])
63
+ t.start_date(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:not_searchable])
64
+ t.end_date(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:not_searchable])
65
+ }
66
+ end
67
+
68
+ def self.xml_template
69
+ builder = Nokogiri::XML::Builder.new do |xml|
70
+ xml.mods(:version=>"3.4",
71
+ "xmlns"=>"http://www.loc.gov/mods/v3",
72
+ "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance"){
73
+ }
74
+ end
75
+ builder.doc.encoding = 'UTF-8'
76
+ builder.doc.root["xsi:schemaLocation"] = 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'
77
+ return builder.doc
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
+ begin
96
+ has_term = self.class.terminology.has_term?(_msym)
97
+
98
+ _r = (has_term)? find_by_terms(_msym, *args) : nil
99
+ if query
100
+ return !( _r.nil? || _r.size()==0)
101
+ else
102
+ return _r
103
+ end
104
+ rescue
105
+ super
106
+ end
107
+ end
108
+ def update_values(params)
109
+ super
110
+ self.dirty = true
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,92 @@
1
+ module Cul::Hydra::RisearchMembers
2
+ module ClassMethods
3
+ def get_recursive_member_pids(pid, verbose_output=false, cmodel_type='all')
4
+
5
+ recursive_member_query =
6
+ 'select $child $parent from <#ri>
7
+ where
8
+ walk($child <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '> and $child <http://purl.oclc.org/NET/CUL/memberOf> $parent)'
9
+
10
+ unless cmodel_type == 'all'
11
+ recursive_member_query += ' and $child <fedora-model:hasModel> $cmodel'
12
+ recursive_member_query += ' and $cmodel <mulgara:is> <info:fedora/ldpd:' + cmodel_type + '>'
13
+ end
14
+
15
+ puts 'Performing query:' if verbose_output
16
+ puts recursive_member_query if verbose_output
17
+
18
+ search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(recursive_member_query, {
19
+ :type => 'tuples',
20
+ :format => 'json',
21
+ :limit => '',
22
+ :stream => 'on'
23
+ }))
24
+
25
+ unique_pids = search_response['results'].map{|result| result['child'].gsub('info:fedora/', '') }.uniq
26
+
27
+ return unique_pids
28
+
29
+ end
30
+
31
+ def get_direct_member_results(pid, verbose_output=false, format='json')
32
+
33
+ direct_member_query =
34
+ 'select $pid from <#ri>
35
+ where $pid <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '>'
36
+
37
+ puts 'Performing query:' if verbose_output
38
+ puts direct_member_query if verbose_output
39
+
40
+ search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(direct_member_query, {
41
+ :type => 'tuples',
42
+ :format => format,
43
+ :limit => '',
44
+ :stream => 'on'
45
+ }))
46
+
47
+ return search_response['results']
48
+ end
49
+
50
+ def get_direct_member_pids(pid, verbose_output=false)
51
+ unique_pids = get_direct_member_results(pid,verbose_output,'json')
52
+ unique_pids.map{|result| result['pid'].gsub('info:fedora/', '') }.uniq
53
+ end
54
+
55
+ def get_direct_member_count(pid, verbose_output=false)
56
+ count = get_direct_member_results(pid,verbose_output,'count/json')
57
+ return count.blank? ? 0 : count[0]['count'].to_i
58
+ end
59
+
60
+ #Project constituents
61
+
62
+ def get_project_constituent_results(pid, verbose_output=false, format='json')
63
+
64
+ project_constituent_query =
65
+ 'select $pid from <#ri>
66
+ where $pid <info:fedora/fedora-system:def/relations-external#isConstituentOf> <fedora:' + pid + '>'
67
+
68
+ puts 'Performing query:' if verbose_output
69
+ puts project_constituent_query if verbose_output
70
+
71
+ search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(project_constituent_query, {
72
+ :type => 'tuples',
73
+ :format => format,
74
+ :limit => '',
75
+ :stream => 'on'
76
+ }))
77
+
78
+ return search_response['results']
79
+ end
80
+
81
+ def get_project_constituent_pids(pid, verbose_output=false)
82
+ unique_pids = get_project_constituent_results(pid,verbose_output,'json')
83
+ unique_pids.map{|result| result['pid'].gsub('info:fedora/', '') }.uniq
84
+ end
85
+
86
+ def get_project_constituent_count(pid, verbose_output=false)
87
+ count = get_project_constituent_results(pid,verbose_output,'count/json')
88
+ return count.blank? ? 0 : count[0]['count'].to_i
89
+ end
90
+ end
91
+ extend ClassMethods
92
+ end