Module: GDor::Indexer::PublicXmlFields

Included in:
SolrDocBuilder
Defined in:
lib/gdor/indexer/public_xml_fields.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#collection?Boolean

Returns true if the identityMetadata has <objectType>collection</objectType>, false otherwise.

Returns:

  • (Boolean)

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



47
48
49
# File 'lib/gdor/indexer/public_xml_fields.rb', line 47

def collection?
  resource.collection?
end

#collectionsObject



51
52
53
# File 'lib/gdor/indexer/public_xml_fields.rb', line 51

def collections
  resource.collections
end

#display_typeObject

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

Returns:

  • String the string to pre-pend to the display_type value (e.g. )

  • (String)

    ‘collection’ or DOR content type



14
15
16
17
18
19
20
21
22
23
# 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_idsArray<String>

the @id attribute of resource/file elements that match the display_type, including extension

Returns:

  • (Array<String>)

    filenames



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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