Sha256: de36fd991e5e1c9d74b7be617aca096c402378588bece2a79f262bbc38ddaf06

Contents?: true

Size: 1.49 KB

Versions: 27

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 = {}, *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, [:symbol])
      add_solr_value(solr_doc, "apo_role_#{role_type}", val, :string, [:symbol])
      if ['dor-apo-manager', 'dor-apo-depositor'].include? role_type
        add_solr_value(solr_doc, 'apo_register_permissions', val, :string, [:symbol, :stored_searchable])
      end
    end
    solr_doc
  end

end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dor-services-5.12.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.11.1 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.11.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.10.4 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.10.3 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.10.2 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.10.1 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.10.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.9.1 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.9.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.8.2 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.8.1 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.8.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.7.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.6.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.5.3 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.5.2 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.5.1 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.5.0 lib/dor/datastreams/role_metadata_ds.rb
dor-services-5.4.2 lib/dor/datastreams/role_metadata_ds.rb