Class: Cul::Hydra::Datastreams::ModsDocument

Inherits:
ActiveFedora::OmDatastream
  • Object
show all
Includes:
Solrizer::ModsFieldable, Solrizer::TerminologyBasedSolrizer, OM::XML::TerminologyBasedSolrizer
Defined in:
app/models/cul/hydra/datastreams/mods_document.rb

Constant Summary

Constants included from Solrizer::ModsFieldable

Solrizer::ModsFieldable::MODS_NS, Solrizer::ModsFieldable::ORIGIN_INFO_DATES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Solrizer::ModsFieldable

#add_names_by_text_role!, #add_notes_by_type!, #all_subjects, #alternative_titles, #archival_context_json, #archive_org_identifier, #archive_org_identifiers, #classification_other, #clio_ids, #collections, #coordinates, #copyright_statement, #date_range_to_textual_date, #dates, #durst_subjects, #formats, #item_in_context_url, #key_date_range, #languages_iso639_2_code, #languages_iso639_2_text, #main_title, #mods, #names, #non_item_in_context_url, #notes_by_type, #origin_info_place, #origin_info_place_for_display, #project_url, #projects, #reading_room_locations, #repository_code, #repository_text, #search_scope, #shelf_locators, #sort_title, #sublocation, #textual_dates, #titles, #to_solr, #translate_project_title, #translate_repo_marc_code, #url_locations, #zero_pad_year

Methods included from Solrizer::ModsFieldable::ClassMethods

#map_field, #map_value, #maps_field?, #normalize, #role_text_to_solr_field_name, #value_mapper

Methods included from Solrizer::TerminologyBasedSolrizer

included

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'app/models/cul/hydra/datastreams/mods_document.rb', line 179

def method_missing method, *args
  query = false
  _mname = method.id2name
  if _mname[-1,1] == '?'
    query = true
    _mname = _mname[0,_mname.length-1]
  end
  _msym = _mname.to_sym
  has_term = self.class.terminology.has_term?(_msym)
  return false if query and not has_term
  _r = super(_mname.to_sym, *args)
  if query
    _r.length > 0
  else
    _r
  end
end

Class Method Details

.xml_templateObject



158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'app/models/cul/hydra/datastreams/mods_document.rb', line 158

def self.xml_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.mods(:version=>"3.4",
       "xmlns"=>"http://www.loc.gov/mods/v3",
       "xmlns:xlink"=>"http://www.w3.org/1999/xlink",
       "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance"){
    }
  end
  builder.doc.encoding = 'UTF-8'
  # for some reason, this is the only way to get an equivalent nokogiri root node; the attribute can't be in the original builder call
  builder.doc.root["xsi:schemaLocation"] = 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'
  return builder.doc
end

Instance Method Details

#prefixObject



172
173
174
175
176
177
# File 'app/models/cul/hydra/datastreams/mods_document.rb', line 172

def prefix
  #if ::ActiveFedora::VERSION >= '8'
  #  Rails.logger.warn("the prefix method of #{self.class.name} was overriden to maintain backwards compatibility")
  #end
  ''
end