cul_hydra 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,35 @@
1
+ require 'om'
2
+ module Cul::Hydra::Solrizer::TerminologyBasedSolrizer
3
+ # copied from Solrizer::XML::TerminologyBasedSolrizer
4
+
5
+ def self.included(klass)
6
+ klass.send(:extend, ClassMethods)
7
+ end
8
+
9
+ # Module Methods
10
+
11
+ module ClassMethods
12
+ # Populate a solr document with solr fields corresponding to the given xml node
13
+ # Field names are generated using settings from the term in the +doc+'s terminology corresponding to +term_pointer+
14
+ # @param [Nokogiri::XML::Node] node to solrize
15
+ # @param [OM::XML::Document] doc document the node came from
16
+ # @param [Array] term_pointer Array pointing to the term that should be used for solrization settings
17
+ # @param [Hash] (optional) solr_doc (values hash) to populate
18
+ def solrize_node(node_value, doc, term_pointer, term, solr_doc = Hash.new, field_mapper = nil, opts = {})
19
+ return solr_doc unless term.index_as && !term.index_as.empty?
20
+ generic_field_name_base = OM::XML::Terminology.term_generic_name(*term_pointer)
21
+ create_and_insert_terms(generic_field_name_base, node_value, term.index_as, solr_doc)
22
+ if term_pointer.length > 1
23
+ #hierarchical_field_name_base = OM::XML::Terminology.term_hierarchical_name(*term_pointer)
24
+ #create_and_insert_terms(hierarchical_field_name_base, node_value, term.index_as, solr_doc)
25
+ end
26
+ if term.variant_of and term.variant_of[:field_base]
27
+ #create_and_insert_terms(term.variant_of[:field_base], node_value, term.index_as, solr_doc)
28
+ create_and_insert_terms(term.variant_of[:field_base], node_value, term.index_as, solr_doc)
29
+ end
30
+ solr_doc
31
+ end
32
+
33
+ end
34
+
35
+ end # module
@@ -0,0 +1,46 @@
1
+ module Cul::Hydra::Solrizer
2
+ # This class uses a yaml map to translate field values for solr
3
+ class ValueMapper
4
+ def self.load_value_maps(config_path=nil)
5
+ if config_path.nil?
6
+ if defined?(Rails.root) && !Rails.root.nil?
7
+ config_path = File.join(Rails.root, "config", "solr_value_maps.yml")
8
+ end
9
+ # Default to using the config file within the gem
10
+ if !File.exist?(config_path.to_s)
11
+ config_path = File.join(File.dirname(__FILE__), "..", "..", "..", "config", "solr_value_maps.yml")
12
+ end
13
+ end
14
+ #logger.info("ValueMapper: loading field value maps from #{File.expand_path(config_path)}")
15
+ YAML::load(File.open(config_path))
16
+ end
17
+
18
+ def self.default_value_maps
19
+ @@value_maps ||= self.load_value_maps
20
+ end
21
+ # Instance methods
22
+
23
+ def initialize(value_maps=nil)
24
+ @value_maps = (value_maps || Cul::Hydra::Solrizer::ValueMapper.default_value_maps).with_indifferent_access
25
+ @mapped_fields = {}.with_indifferent_access
26
+ end
27
+
28
+ def maps_field?(field_key)
29
+ @mapped_fields.has_key? field_key
30
+ end
31
+
32
+ def map_field(field_key, map_key)
33
+ @mapped_fields[field_key] = map_key
34
+ end
35
+
36
+ def map_value(field_key, value_key)
37
+ map_key = @mapped_fields[field_key]
38
+ return value_key unless @mapped_fields.has_key? field_key and @value_maps.has_key? map_key
39
+ if value_key.is_a? Array
40
+ value_key.collect{ |val| @value_maps[map_key].fetch(val, val) }
41
+ else
42
+ @value_maps[map_key].fetch(value_key, value_key)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,172 @@
1
+ require 'solrizer'
2
+ module Solrizer::DefaultDescriptors
3
+ def self.date_sortable
4
+ @date_sortable ||= Solrizer::Descriptor.new(:date, :stored, :indexed, converter: date_sortable_converter)
5
+ end
6
+
7
+ # Produces the field name 'all_text_teim'
8
+ def self.textable
9
+ @textable_type ||= TextableDescriptor.new(:text_en, :indexed, :multivalued)
10
+ end
11
+
12
+ # Produces _sim suffix
13
+ def self.project_facetable
14
+ @project_facet_type ||= ProjectFacetDescriptor.new(:string, :indexed, :multivalued)
15
+ end
16
+
17
+ def self.project_textable
18
+ @project_textable_type ||= ProjectTextableDescriptor.new(:text_en, :indexed, :multivalued)
19
+ end
20
+
21
+ ## Produces _sim suffix and a value-mapping converter
22
+ #def self.marc_code_facetable
23
+ # @marc_code_facet_type ||= MarcCodeFacetDescriptor.new(:string, :indexed, :multivalued)
24
+ #end
25
+
26
+ ## Produces _ssm suffix and a value-mapping converter
27
+ #def self.marc_code_displayable
28
+ # @marc_code_type ||= MarcCodeDisplayDescriptor.new(:string, :stored, :indexed, :multivalued)
29
+ #end
30
+
31
+ # Produces all_text_timv fieldname and a value-mapping converter
32
+ def self.marc_code_textable
33
+ @marc_code_map_text_type ||= MarcCodeTextableDescriptor.new(:text_en, :indexed, :multivalued)
34
+ end
35
+
36
+ def self.load_value_maps(config_path=nil)
37
+ if config_path.nil?
38
+ if defined?(Rails.root) && !Rails.root.nil?
39
+ config_path = File.join(Rails.root, "config", "solr_value_maps.yml")
40
+ end
41
+ # Default to using the config file within the gem
42
+ if !File.exist?(config_path.to_s)
43
+ logger.warn("ValueMapper: no field value maps at #{config_path}")
44
+ config_path = File.join(File.dirname(__FILE__), "..", "..", "..", "config", "solr_value_maps.yml")
45
+ end
46
+ if !File.exist?(config_path.to_s)
47
+ logger.warn("ValueMapper: no field value maps at #{File.expand_path(config_path)}")
48
+ return {}
49
+ end
50
+ end
51
+ logger.info("ValueMapper: loading field value maps from #{File.expand_path(config_path)}")
52
+ YAML::load(File.open(config_path))
53
+ end
54
+
55
+ def self.value_maps
56
+ @@value_maps ||= load_value_maps
57
+ end
58
+
59
+ def self.date_sortable_converter
60
+ lambda do |type|
61
+ lambda do |val|
62
+ begin
63
+ d = val.length < 11 ? Date.new(*(val.split('-').collect {|s| s.to_i})) : Date.parse(val)
64
+ iso8601_date(d)
65
+ rescue ArgumentError
66
+ nil
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ module Normal
73
+ SHORT_REPO = "ldpd.short.repo"
74
+ LONG_REPO = "ldpd.long.repo"
75
+ FULL_REPO = "ldpd.full.repo"
76
+ SHORT_PROJ = "ldpd.short.project"
77
+ FULL_PROJ = "ldpd.full.project"
78
+ def normal(value)
79
+ normal!(value.clone)
80
+ end
81
+ def normal!(value)
82
+ value.gsub!(/\s+/,' ')
83
+ value.strip!
84
+ value
85
+ end
86
+ def translate_with_default(prefix, value, default)
87
+ begin
88
+ # Using method below to handle translations because our YAML keys can contain periods and this doesn't play well with the translation dot-syntax
89
+ translations = HashWithIndifferentAccess.new(I18n.t(prefix))
90
+ if translations.has_key?(value)
91
+ return translations[value]
92
+ else
93
+ return default
94
+ end
95
+ rescue
96
+ return default
97
+ end
98
+ end
99
+ end
100
+
101
+ class TextableDescriptor < Solrizer::Descriptor
102
+ include Normal
103
+ def name_and_converter(field_name, args=nil)
104
+ super('all_text', args)
105
+ end
106
+ def converter(field_type)
107
+ lambda {|value| normal(value)}
108
+ end
109
+ end
110
+
111
+ class ProjectTextableDescriptor < Solrizer::Descriptor
112
+ include Normal
113
+ def name_and_converter(field_name, args=nil)
114
+ super('all_text', args)
115
+ end
116
+ def converter(field_type)
117
+ lambda do |value|
118
+ if value.is_a? String
119
+ normal!(value)
120
+ r = [translate_with_default(SHORT_PROJ, value, normal!(value))]
121
+ r << translate_with_default(FULL_PROJ, value, normal!(value))
122
+ r.uniq!
123
+ r.join(' ')
124
+ else
125
+ raise "unexpected project_textable #{value.inspect}"
126
+ value
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ class ProjectFacetDescriptor < Solrizer::Descriptor
133
+ include Normal
134
+ def converter(field_type)
135
+ lambda {|value| translate_with_default(SHORT_PROJ, normal!(value), normal!(value))}
136
+ end
137
+ end
138
+
139
+ #class MarcCodeFacetDescriptor < Solrizer::Descriptor
140
+ # include Normal
141
+ # def converter(field_type)
142
+ # lambda {|value| translate_with_default(SHORT_REPO, normal!(value), 'Non-Columbia Location')}
143
+ # end
144
+ #end
145
+
146
+ #class MarcCodeDisplayDescriptor < Solrizer::Descriptor
147
+ # include Normal
148
+ # def converter(field_type)
149
+ # lambda {|value| translate_with_default(LONG_REPO, normal!(value), 'Non-Columbia Location')}
150
+ # end
151
+ #end
152
+
153
+ class MarcCodeTextableDescriptor < Solrizer::Descriptor
154
+ include Normal
155
+ def name_and_converter(field_name, args=nil)
156
+ super('all_text', args)
157
+ end
158
+ def converter(field_type)
159
+ lambda do |value|
160
+ if value.is_a? String
161
+ normal!(value)
162
+ r = [translate_with_default(SHORT_REPO, value, 'Non-Columbia Location')]
163
+ r << translate_with_default(LONG_REPO, value, 'Non-Columbia Location')
164
+ r.uniq!
165
+ r.join(' ')
166
+ else
167
+ value
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,8 @@
1
+ module Cul
2
+ module Hydra
3
+ VERSION = '1.0.0'
4
+ def self.version
5
+ VERSION
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Cul
2
+ module Hydra
3
+ VERSION = '0.22.9.10'
4
+ def self.version
5
+ VERSION
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,122 @@
1
+ APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../") unless defined?(APP_ROOT)
2
+ require 'active-fedora'
3
+
4
+ def logger
5
+ @logger ||= Logger.new($stdout)
6
+ end
7
+
8
+ def filename_for_pid(pid)
9
+ pid.gsub(/\:/,'_') + '.xml'
10
+ end
11
+
12
+ def pid_for_filename(fname)
13
+ fname.sub(/\.xml$/,'').sub(/_/,':')
14
+ end
15
+
16
+ def cmodel_fixture(name)
17
+ path = File.join(APP_ROOT, 'fixtures','cmodels',name)
18
+ File.open(path, 'rb')
19
+ end
20
+
21
+ def each_cmodel
22
+ path = File.join(APP_ROOT, 'fixtures','cmodels')
23
+ Dir.new(path).each do |fname|
24
+ if fname =~ /\.xml$/
25
+ yield pid_for_filename(fname)
26
+ end
27
+ end
28
+ end
29
+
30
+ def config_subs
31
+ @subs ||= begin
32
+ cfile = File.join(APP_ROOT,'config','subs.yml')
33
+ subs = {}
34
+ if File.exists? cfile
35
+ open(cfile) {|blob| subs = YAML::load(blob)[ENV['RAILS_ENV'] || 'test'] }
36
+ else
37
+ logger.warn("No subs.yml found; CModels will be loaded without inline substitutions")
38
+ end
39
+ subs
40
+ end
41
+ @subs
42
+ end
43
+
44
+ def do_subs(orig)
45
+ content = orig.clone
46
+ config_subs.each do |key, val|
47
+ content.gsub!(/\$#{key.to_s}\$/, val)
48
+ end
49
+ content
50
+ end
51
+
52
+ def connection
53
+ # no need to go through AF for this except laziness re: finding the YAML
54
+ @connection ||= (ActiveFedora::Base.fedora_connection[0] ||= ActiveFedora::RubydoraConnection.new(ActiveFedora.config.credentials)).connection
55
+ end
56
+
57
+ def content_for(pid)
58
+ fname = filename_for_pid(pid)
59
+ fcontent = cmodel_fixture(fname).read
60
+ fcontent = do_subs(fcontent)
61
+ end
62
+
63
+ def load_content(content, pid)
64
+ begin
65
+ connection.ingest(:file=>StringIO.new(content), :pid=>pid)
66
+ rescue Exception => e
67
+ puts "possible problem with ingest of #{pid}: #{e.message}"
68
+ raise e
69
+ end
70
+ end
71
+
72
+ def purge(pid)
73
+ begin
74
+ connection.purge_object :pid=>pid
75
+ rescue Exception => e
76
+ puts "possible problem with purge of #{pid}: #{e.message}"
77
+ end
78
+
79
+ end
80
+
81
+ def reload(pid)
82
+ fcontent = content_for(pid)
83
+ purge(pid)
84
+ load_content(fcontent, pid)
85
+ end
86
+
87
+
88
+ namespace :cul_hydra do
89
+ namespace :cmodel do
90
+ task :test do #=> :environment do
91
+ pid = ENV["PID"]
92
+ puts content_for(pid)
93
+ end
94
+
95
+ task :load do #=> :environment do
96
+ pid = ENV["PID"]
97
+ load_content(content_for(pid),pid)
98
+ end
99
+
100
+ task :purge do #=> :environment do
101
+ pid = ENV["PID"]
102
+ purge(pid)
103
+ end
104
+
105
+ task :reload do #=> :environment do
106
+ pid = ENV["PID"]
107
+ reload(pid)
108
+ end
109
+
110
+ task :reload_all do #=> :environment do
111
+ pattern = ENV["PATTERN"]
112
+ pattern = Regexp.compile(pattern) if pattern
113
+ reload("ldpd:nullbind")
114
+ each_cmodel do |pid|
115
+ unless (pattern and not pid =~ pattern)
116
+ puts "reloading #{pid}"
117
+ reload(pid)
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,54 @@
1
+ APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../") unless defined?(APP_ROOT)
2
+
3
+ require 'jettywrapper'
4
+ JETTY_ZIP_BASENAME = '7.x-stable'
5
+ Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/#{JETTY_ZIP_BASENAME}.zip"
6
+
7
+ namespace :cul_hydra do
8
+
9
+ begin
10
+ # This code is in a begin/rescue block so that the Rakefile is usable
11
+ # in an environment where RSpec is unavailable (i.e. production).
12
+
13
+ require 'rspec/core/rake_task'
14
+
15
+ RSpec::Core::RakeTask.new(:rspec) do |spec|
16
+ spec.pattern = FileList['spec/**/*_spec.rb']
17
+ spec.pattern += FileList['spec/*_spec.rb']
18
+ spec.rspec_opts = ['--backtrace'] if ENV['CI']
19
+ end
20
+
21
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
22
+ spec.pattern = FileList['spec/**/*_spec.rb']
23
+ spec.pattern += FileList['spec/*_spec.rb']
24
+ spec.rcov = true
25
+ end
26
+
27
+ rescue LoadError => e
28
+ puts "[Warning] Exception creating rspec rake tasks. This message can be ignored in environments that intentionally do not pull in the RSpec gem (i.e. production)."
29
+ puts e
30
+ end
31
+
32
+ desc "CI build"
33
+ task :ci do
34
+ ENV['environment'] = "test"
35
+ #Rake::Task["active_fedora:configure_jetty"].invoke
36
+ jetty_params = Jettywrapper.load_config
37
+ error = Jettywrapper.wrap(jetty_params) do
38
+ Rake::Task["cul_hydra:cmodel:reload_all"].invoke
39
+ Rake::Task['cul_hydra:coverage'].invoke
40
+ end
41
+ raise "test failures: #{error}" if error
42
+ end
43
+
44
+ desc "Execute specs with coverage"
45
+ task :coverage do
46
+ # Put spec opts in a file named .rspec in root
47
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
48
+ ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
49
+
50
+ # Rake::Task["active_fedora:fixtures"].invoke
51
+ Rake::Task["cul_hydra:rspec"].invoke
52
+ end
53
+
54
+ end