Module: Hydra::Datastream::CommonModsIndexMethods
- Included in:
- ModsArticle, ModsBasic, ModsDataset, ModsGenericContent, ModsImage, ModsArticle
- Defined in:
- app/models/hydra/datastream/common_mods_index_methods.rb
Instance Method Summary collapse
-
#extract_person_full_names ⇒ Object
Extracts the first and last names of persons and creates Solr::Field objects with for person_full_name_facet.
-
#extract_person_organizations ⇒ Object
Extracts the affiliations of persons and creates Solr::Field objects for them.
Instance Method Details
#extract_person_full_names ⇒ Object
Extracts the first and last names of persons and creates Solr::Field objects with for person_full_name_facet
Returns:
An array of Solr::Field objects
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/hydra/datastream/common_mods_index_methods.rb', line 20 def extract_person_full_names names = {} self.find_by_terms(:person).each do |person| name_parts = person.children.inject({}) do |hash,child| hash[child.get_attribute(:type)] = child.text if ["family","given"].include? child.get_attribute(:type) hash end ::Solrizer::Extractor.insert_solr_field_value(names, "person_full_name_facet", [name_parts["family"], name_parts["given"]].join(", ") ) if name_parts.keys.sort == ["family","given"] names end return names end |
#extract_person_organizations ⇒ Object
Extracts the affiliations of persons and creates Solr::Field objects for them
Returns:
An array of Solr::Field objects
38 39 40 41 42 43 44 |
# File 'app/models/hydra/datastream/common_mods_index_methods.rb', line 38 def extract_person_organizations orgs = {} self.find_by_terms(:person,:affiliation).each do |org| ::Solrizer::Extractor.insert_solr_field_value(orgs, "mods_organization_facet", org.text) end return orgs end |