Class: Hyrax::Indexers::FileSetIndexer

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

Overview

Indexes Hyrax::FileSet objects

Direct Known Subclasses

ValkyrieFileSetIndexer

Instance Attribute Summary

Attributes inherited from ResourceIndexer

#resource

Instance Method Summary collapse

Methods included from ThumbnailIndexer

#index_thumbnails, #thumbnail_path

Methods inherited from ResourceIndexer

for, #generate_solr_document, #initialize

Constructor Details

This class inherits a constructor from Hyrax::Indexers::ResourceIndexer

Instance Method Details

#to_solrObject

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity



14
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
99
100
101
102
103
104
105
# File 'app/indexers/hyrax/indexers/file_set_indexer.rb', line 14

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.iiif_id
    solr_doc['extracted_text_id_ssi']        = resource.extracted_text_id.to_s
    solr_doc['hasRelatedMediaFragment_ssim'] = resource.representative_id.to_s
    solr_doc['hasRelatedImage_ssim']         = resource.thumbnail_id.to_s

    index_lease(solr_doc)
    index_embargo(solr_doc)

    # Add in metadata from the primary file.
     = Hyrax.config.file_set_file_service.new(file_set: resource).primary_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']           = .recorded_size[0]
    solr_doc['type_tesim']              = .pcdm_use.map(&:to_s) if .pcdm_use.present?
    solr_doc['pcdm_use_tesim'] = .pcdm_use.map(&:to_s) if .pcdm_use.present?

    # attributes set by fits
    solr_doc['format_label_tesim']      = .format_label if .format_label.present?
    solr_doc['size_tesim']              = .recorded_size if .recorded_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
    solr_doc['height_is']               = Integer(.height.first) if .height.present?
    solr_doc['width_is']                = Integer(.width.first) if .width.present?

    # 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['alpha_channels_ssi']      = .channels.first 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