Module: Hydra::ModelMixins::SolrDocumentExtension
- Defined in:
- lib/hydra/model_mixins/solr_document_extension.rb
Instance Method Summary collapse
- #document_type(display_type = CatalogController.blacklight_config.show.display_type) ⇒ Object
- #get_file_asset_count ⇒ Object
- #get_person_from_role(role, opts = {}) ⇒ Object
Instance Method Details
#document_type(display_type = CatalogController.blacklight_config.show.display_type) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/hydra/model_mixins/solr_document_extension.rb', line 3 def document_type display_type = CatalogController.blacklight_config.show.display_type type = self.fetch(:medium_t, nil) type ||= self.fetch(display_type, nil) if display_type type.first.to_s.gsub("info:fedora/afmodel:","").gsub("Hydrangea","").gsub(/^Generic/,"") end |
#get_file_asset_count ⇒ Object
21 22 23 |
# File 'lib/hydra/model_mixins/solr_document_extension.rb', line 21 def get_file_asset_count() ActiveFedora::Base.count(:conditions=>"is_part_of_t:#{ActiveFedora::Base.quote_for_solr(id)}") end |
#get_person_from_role(role, opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hydra/model_mixins/solr_document_extension.rb', line 11 def get_person_from_role(role, opts={}) i = 0 while i < 10 persons_roles = self["person_#{i}_role_t"].map{|w|w.strip.downcase} unless self["person_#{i}_role_t"].nil? if persons_roles and persons_roles.include?(role.downcase) return {:first=>self["person_#{i}_first_name_t"], :last=>self["person_#{i}_last_name_t"]} end i += 1 end end |