Sha256: ddee4ea00e91ce5d3d1a1e18a0d404987c1038a2fe113d77cc538a2b8a87515e

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

module Dor
class RoleMetadataDS < ActiveFedora::OmDatastream
  include SolrDocHelper

  set_terminology do |t|
    t.root :path => 'roleMetadata'

    t.actor do
      t.identifier do
        t.type_ :path => {:attribute => 'type'}
      end
      t.name
    end
    t.person :ref => [:actor], :path => 'person'
    t.group  :ref => [:actor], :path => 'group'

    t.role do
      t.type_ :path => {:attribute => 'type'}
      t.person :ref => [:person]
      t.group  :ref => [:group]
    end

    t.manager    :ref => [:role], :attributes => {:type => 'manager'}
    t.depositor  :ref => [:role], :attributes => {:type => 'depositor'}
    t.reviewer   :ref => [:role], :attributes => {:type => 'reviewer'}
    t.viewer     :ref => [:role], :attributes => {:type => 'viewer'}
  end

  def self.xml_template
    Nokogiri::XML::Builder.new do |xml|
      xml.roleMetadata{
      }
    end.doc
  end


  def to_solr(solr_doc = Hash.new, *args)
    find_by_xpath('/roleMetadata/role/*').each do |actor|
      role_type = actor.parent['type']
      val = [actor.at_xpath('identifier/@type'),actor.at_xpath('identifier/text()')].join ':'
      add_solr_value(solr_doc, "apo_role_#{actor.name}_#{role_type}", val, :string, [:searchable, :facetable])
      add_solr_value(solr_doc, "apo_role_#{role_type}", val, :string, [:searchable, :facetable])
      unless role_type =~ /^hydrus/
        add_solr_value(solr_doc, "apo_register_permissions", val, :string, [:searchable, :facetable])
      end
    end
    solr_doc
  end

end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dor-services-4.25.1 lib/dor/datastreams/role_metadata_ds.rb
dor-services-4.25.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-4.24.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-4.23.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-4.22.6 lib/dor/datastreams/role_metadata_ds.rb
dor-services-4.22.5 lib/dor/datastreams/role_metadata_ds.rb
dor-services-4.22.4 lib/dor/datastreams/role_metadata_ds.rb