Class: Hyrax::ValkyrieFileSetIndexer

Inherits:
ValkyrieIndexer show all
Includes:
PermissionIndexer, ResourceIndexer, VisibilityIndexer
Defined in:
app/indexers/hyrax/valkyrie_file_set_indexer.rb

Overview

Indexes Hyrax::FileSet objects

Instance Attribute Summary

Attributes inherited from ValkyrieIndexer

#resource

Instance Method Summary collapse

Methods inherited from ValkyrieIndexer

for, #generate_solr_document, #initialize

Constructor Details

This class inherits a constructor from Hyrax::ValkyrieIndexer

Instance Method Details

#to_solrObject

include Hyrax::IndexesThumbnails # TODO: Is there a Valkyrie version of a thumbnail indexer?



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/indexers/hyrax/valkyrie_file_set_indexer.rb', line 15

def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  super.tap do |solr_doc| # rubocop:disable Metrics/BlockLength
    solr_doc['generic_type_si'] = 'FileSet'

    # Metadata from the FileSet
    solr_doc['file_ids_ssim']         = resource.file_ids&.map(&:to_s)
    solr_doc['original_file_id_ssi']  = resource.original_file_id.to_s
    solr_doc['thumbnail_id_ssi']      = resource.thumbnail_id.to_s
    solr_doc['extracted_text_id_ssi'] = resource.extracted_text_id.to_s

    # Add in metadata from the original file.
     = original_file
    return solr_doc unless 

    # Label is the actual file name. It's not editable by the user.
    solr_doc['original_file_alternate_ids_tesim'] = .alternate_ids&.map(&:to_s) if .alternate_ids.present?

    solr_doc['original_filename_tesi']  = .original_filename if .original_filename.present?
    solr_doc['original_filename_ssi']   = .original_filename if .original_filename.present?
    solr_doc['mime_type_tesi']          = .mime_type if .mime_type.present?
    solr_doc['mime_type_ssi']           = .mime_type if .mime_type.present?

    solr_doc['file_format_tesim']       = file_format()
    solr_doc['file_format_sim']         = file_format()
    solr_doc['file_size_lts']           = .size[0]
    solr_doc['type_tesim']              = .type if .type.present?

    # attributes set by fits
    solr_doc['format_label_tesim']      = .format_label if .format_label.present?
    solr_doc['size_tesim']              = .size if .size.present?
    solr_doc['well_formed_tesim']       = .well_formed if .well_formed.present?
    solr_doc['valid_tesim']             = .valid if .valid.present?
    solr_doc['fits_version_tesim']      = .fits_version if .fits_version.present?
    solr_doc['exif_version_tesim']      = .exif_version if .exif_version.present?
    solr_doc['checksum_tesim']          = .checksum if .checksum.present?

    # shared attributes across multiple file types
    solr_doc['frame_rate_tesim']        = .frame_rate if .frame_rate.present? # audio, video
    solr_doc['bit_rate_tesim']          = .bit_rate if .bit_rate.present? # audio, video
    solr_doc['duration_tesim']          = .duration if .duration.present? # audio, video
    solr_doc['sample_rate_tesim']       = .sample_rate if .sample_rate.present? # audio, video

    solr_doc['height_tesim']            = .height if .height.present? # image, video
    solr_doc['width_tesim']             = .width if .width.present? # image, video

    # attributes set by fits for audio files
    solr_doc['bit_depth_tesim']         = .bit_depth if .bit_depth.present?
    solr_doc['channels_tesim']          = .channels if .channels.present?
    solr_doc['data_format_tesim']       = .data_format if .data_format.present?
    solr_doc['offset_tesim']            = .offset if .offset.present?

    # attributes set by fits for documents
    solr_doc['file_title_tesim']        = .file_title if .file_title.present?
    solr_doc['page_count_tesim']        = .page_count if .page_count.present?
    solr_doc['language_tesim']          = .language if .language.present?
    solr_doc['word_count_tesim']        = .word_count if .word_count.present?
    solr_doc['character_count_tesim']   = .character_count if .character_count.present?
    solr_doc['line_count_tesim']        = .line_count if .line_count.present?
    solr_doc['character_set_tesim']     = .character_set if .character_set.present?
    solr_doc['markup_basis_tesim']      = .markup_basis if .markup_basis.present?
    solr_doc['paragraph_count_tesim']   = .paragraph_count if .paragraph_count.present?
    solr_doc['markup_language_tesim']   = .markup_language if .markup_language.present?
    solr_doc['table_count_tesim']       = .table_count if .table_count.present?
    solr_doc['graphics_count_tesim']    = .graphics_count if .graphics_count.present?

    # attributes set by fits for images
    solr_doc['byte_order_tesim']        = .byte_order if .byte_order.present?
    solr_doc['compression_tesim']       = .compression if .compression.present?
    solr_doc['color_space_tesim']       = .color_space if .color_space.present?
    solr_doc['profile_name_tesim']      = .profile_name if .profile_name.present?
    solr_doc['profile_version_tesim']   = .profile_version if .profile_version.present?
    solr_doc['orientation_tesim']       = .orientation if .orientation.present?
    solr_doc['color_map_tesim']         = .color_map if .color_map.present?
    solr_doc['image_producer_tesim']    = .image_producer if .image_producer.present?
    solr_doc['capture_device_tesim']    = .capture_device if .capture_device.present?
    solr_doc['scanning_software_tesim'] = .scanning_software if .scanning_software.present?
    solr_doc['gps_timestamp_tesim']     = .gps_timestamp if .gps_timestamp.present?
    solr_doc['latitude_tesim']          = .latitude if .latitude.present?
    solr_doc['longitude_tesim']         = .longitude if .longitude.present?

    # attributes set by fits for video
    solr_doc['aspect_ratio_tesim']      = .aspect_ratio if .aspect_ratio.present?
  end
end