Module: Solrizer::Fedora::Extractor
- Defined in:
- lib/solrizer/fedora/extractor.rb
Overview
Solrizer::Fedora::Extractor provides Fedora-specific extractor behaviors This module is automatically mixed into Solrizer::Extractor when you load the solrizer-fedora gem into an application. This is carried out in solrizer/fedora.rb
Instance Method Summary collapse
-
#extract_rels_ext(text, solr_doc = Hash.new) ⇒ Object
Extracts content-model and hydra-type from RELS-EXT datastream.
Instance Method Details
#extract_rels_ext(text, solr_doc = Hash.new) ⇒ Object
Extracts content-model and hydra-type from RELS-EXT datastream
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/solrizer/fedora/extractor.rb', line 12 def extract_rels_ext( text, solr_doc=Hash.new ) # TODO: only read in this file once if defined?(Rails.root.to_s) config_path = File.join(Rails.root.to_s, "config","hydra_types.yml") config_path = nil unless File.exist?(config_path) end unless config_path config_path = File.join(File.dirname(__FILE__), "..", "..", "..", "config","hydra_types.yml") end map = YAML.load(File.open(config_path)) doc = Nokogiri::XML(text) doc.xpath( '//foo:hasModel', 'foo' => 'info:fedora/fedora-system:def/model#' ).each do |element| cmodel = element.attributes['resource'].to_s ::Solrizer::Extractor.insert_solr_field_value(solr_doc, :cmodel_t, cmodel ) if map.has_key?(cmodel) ::Solrizer::Extractor.insert_solr_field_value(solr_doc, :hydra_type_t, map[cmodel] ) end end return solr_doc end |