Class: Dor::DescMetadataDS

Inherits:
ActiveFedora::OmDatastream
  • Object
show all
Defined in:
lib/dor/datastreams/desc_metadata_ds.rb

Overview

Descriptive metadata

Constant Summary collapse

MODS_NS =
'http://www.loc.gov/mods/v3'
MODS_HEADER_CONFIG =
{
  'xmlns' => MODS_NS,
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
  version: '3.6',
  'xsi:schemaLocation' => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.xml_templateObject



49
50
51
52
53
54
55
56
57
# File 'lib/dor/datastreams/desc_metadata_ds.rb', line 49

def self.xml_template
  Nokogiri::XML::Builder.new do |xml|
    xml.mods(MODS_HEADER_CONFIG) do
      xml.titleInfo do
        xml.title
      end
    end
  end.doc
end

Instance Method Details

#full_titleObject



79
80
81
# File 'lib/dor/datastreams/desc_metadata_ds.rb', line 79

def full_title
  stanford_mods.sw_title_display
end

#mods_titleObject



59
60
61
# File 'lib/dor/datastreams/desc_metadata_ds.rb', line 59

def mods_title
  term_values(:title_info, :main_title).first
end

#mods_title=(val) ⇒ Object



63
64
65
# File 'lib/dor/datastreams/desc_metadata_ds.rb', line 63

def mods_title=(val)
  update_values(%i[title_info main_title] => val)
end

#prefixObject

maintain AF < 8 indexing behavior



84
85
86
# File 'lib/dor/datastreams/desc_metadata_ds.rb', line 84

def prefix
  ''
end

#stanford_mods(content = nil, ns_aware = true) ⇒ Object

intended for read-access, “as SearchWorks would see it”, mostly for to_solr()

Parameters:

  • content (Nokogiri::XML::Document) (defaults to: nil)

    Nokogiri descMetadata document (overriding internal data)

  • ns_aware (boolean) (defaults to: true)

    namespace awareness toggle for from_nk_node()



70
71
72
73
74
75
76
77
# File 'lib/dor/datastreams/desc_metadata_ds.rb', line 70

def stanford_mods(content = nil, ns_aware = true)
  @stanford_mods ||= begin
    m = Stanford::Mods::Record.new
    desc = content.nil? ? ng_xml : content
    m.from_nk_node(desc.root, ns_aware)
    m
  end
end