module GDor::Indexer::PublicXmlFields

A mixin to the GDor::Indexer::SolrDocBuilder class. Methods for Solr field values determined from the DOR object's purl page public xml

Public Instance Methods

collection?() click to toggle source

@return true if the identityMetadata has <objectType>collection</objectType>, false otherwise

# File lib/gdor/indexer/public_xml_fields.rb, line 47
def collection?
  resource.collection?
end
collections() click to toggle source
# File lib/gdor/indexer/public_xml_fields.rb, line 51
def collections
  resource.collections
end
display_type() click to toggle source

value is used to tell SearchWorks UI app of specific display needs for objects a config file value for add_display_type can be used to prepend a string to

xxx_collection or xxx_object

e.g., Hydrus objects are a special display case Based on a value of :add_display_type in a collection's config yml file

information on DOR content types:

https://consul.stanford.edu/display/chimera/DOR+content+types%2C+resource+types+and+interpretive+metadata

@return String the string to pre-pend to the display_type value (e.g. ) @return [String] 'collection' or DOR content type

# File lib/gdor/indexer/public_xml_fields.rb, line 14
def display_type
  case dor_content_type
  when 'book'
    'book'
  when 'image', 'manuscript', 'map'
    'image'
  else
    'file'
  end
end
file_ids() click to toggle source

the @id attribute of resource/file elements that match the display_type, including extension @return [Array<String>] filenames

# File lib/gdor/indexer/public_xml_fields.rb, line 27
def file_ids
  @file_ids ||= begin
    ids = []
    if content_md
      if display_type == 'image'
        content_md.root.xpath('resource[@type="image"]/file/@id').each do |node|
          ids << node.text unless node.text.empty?
        end
      elsif display_type == 'file'
        content_md.root.xpath('resource/file/@id').each do |node|
          ids << node.text unless node.text.empty?
        end
      end
    end
    return nil if ids.empty?
    ids
  end
end