Sha256: a9be333af0485d1b9178b6b6174fb76bd0f9de2ab0a0068c5b318433b2ca2cf4

Contents?: true

Size: 1.8 KB

Versions: 12

Compression:

Stored size: 1.8 KB

Contents

module Dor
class SimpleDublinCoreDs < ActiveFedora::OmDatastream

  set_terminology do |t|
    t.root(:path => 'dc', :xmlns => 'http://www.openarchives.org/OAI/2.0/oai_dc/', :schema => 'http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd', :namespace_prefix => 'oai_dc', :index_as => [:not_searchable])
    t.title(     :index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
    t.creator(   :index_as => [:stored_sortable, :stored_searchable], :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
    t.identifier(:index_as => [:symbol, :stored_searchable],          :xmlns => 'http://purl.org/dc/elements/1.1/', :namespace_prefix => 'dc')
  end

  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

    builder.doc
  end

  def to_solr(solr_doc = {}, *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.

    doc = super solr_doc, *args

    add_solr_value(doc, 'dc_title',   title.first,   :string, [:stored_sortable, :stored_searchable])
    add_solr_value(doc, 'dc_creator', creator.first, :string, [:stored_sortable, :stored_searchable])

    identifiers = {}

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

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

    return doc
  rescue Exception => e
    warn "ERROR in SimpleDublinCoreDs to_solr()! #{e}"
    solr_doc
  end
end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dor-services-5.5.3 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.5.2 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.5.1 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.5.0 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.4.2 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.4.1 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.4.0 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.3.4 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.3.3 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.3.2 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.3.1 lib/dor/datastreams/simple_dublin_core_ds.rb
dor-services-5.3.0 lib/dor/datastreams/simple_dublin_core_ds.rb