Sha256: c47f90ea5958d269727888caf8938778fdd7438d95c7a139dd5d1dcfa6b5e3a4

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module Sufia
  class GenericFileIndexingService < ActiveFedora::IndexingService
    STORED_INTEGER = Solrizer::Descriptor.new(:integer, :stored)

    def generate_solr_document
      super.tap do |solr_doc|
        solr_doc[Solrizer.solr_name('label')] = object.label
        solr_doc[Solrizer.solr_name('file_format')] = object.file_format
        solr_doc[Solrizer.solr_name('file_format', :facetable)] = object.file_format
        solr_doc['all_text_timv'] = object.full_text.content
        solr_doc[Solrizer.solr_name('file_size', STORED_INTEGER)] = object.content.size.to_i
        # Index the Fedora-generated SHA1 digest to create a linkage
        # between files on disk (in fcrepo.binary-store-path) and objects
        # in the repository.
        solr_doc[Solrizer.solr_name('digest', :symbol)] = digest_from_content
        object.index_collection_ids(solr_doc) unless Sufia.config.collection_facet.nil?
      end
    end

    private

      def digest_from_content
        return unless object.content.has_content?
        object.content.digest.first.to_s
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sufia-models-6.7.0 app/services/sufia/generic_file_indexing_service.rb
sufia-models-6.6.1 app/services/sufia/generic_file_indexing_service.rb
sufia-models-6.6.0 app/services/sufia/generic_file_indexing_service.rb
sufia-models-6.5.0 app/services/sufia/generic_file_indexing_service.rb