Class: SimpleDublinCoreDs

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.xml_templateObject


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dor/datastreams/simple_dublin_core_ds.rb', line 10

def self.xml_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.dc(:xmlns=>"http://www.openarchives.org/OAI/2.0/oai_dc/", 
      'xmlns:dc'=>'http://purl.org/dc/elements/1.1/') {
        xml['dc'].title
        xml['dc'].creator
        xml['dc'].identifier
    }   
  end

  return builder.doc
end

Instance Method Details

#to_solr(solr_doc = Hash.new, *args) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dor/datastreams/simple_dublin_core_ds.rb', line 23

def to_solr(solr_doc=Hash.new, *args)
  # There are a whole bunch of namespace-related things that can go
  # wrong with this terminology. Until it's fixed in OM, ignore them all.
  begin
    doc = super solr_doc, *args

    add_solr_value(doc, 'dc_title', self.title.first, :string, [:sortable])
    add_solr_value(doc, 'dc_creator', self.creator.first, :string, [:sortable])
    
    identifiers = {}

    self.identifier.each { |i| ns, val = i.split(":"); identifiers[ns] ||= val }

    identifiers.each do |ns, val|
      add_solr_value(doc, "dc_identifier_#{ns}", val, :string, [:sortable])
    end

    return doc
  rescue 
    solr_doc
  end
end