Class: ActiveFedora::IndexingService

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/indexing_service.rb

Overview

Responsible for generating the solr document (via #generate_solr_document) of the given object.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ IndexingService

The class of obj must respond to these methods:

inspect
outgoing_reflections

Parameters:

  • obj (#create_date, #modified_date, #has_model, #id, #to_json, #attached_files, #[])


14
15
16
# File 'lib/active_fedora/indexing_service.rb', line 14

def initialize(obj)
  @object = obj
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



8
9
10
# File 'lib/active_fedora/indexing_service.rb', line 8

def object
  @object
end

Class Method Details

.create_time_solr_nameObject



18
19
20
# File 'lib/active_fedora/indexing_service.rb', line 18

def self.create_time_solr_name
  @create_time_solr_name ||= ActiveFedora.index_field_mapper.solr_name('system_create', :stored_sortable, type: :date)
end

.modified_time_solr_nameObject



22
23
24
# File 'lib/active_fedora/indexing_service.rb', line 22

def self.modified_time_solr_name
  @modified_time_solr_name ||= ActiveFedora.index_field_mapper.solr_name('system_modified', :stored_sortable, type: :date)
end

Instance Method Details

#generate_solr_document {|Hash| ... } ⇒ Hash

Creates a solr document hash for the #object

Yields:

  • (Hash)

    yields the solr document

Returns:

  • (Hash)

    the solr document



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_fedora/indexing_service.rb', line 33

def generate_solr_document
  solr_doc = {}
  ActiveFedora.index_field_mapper.set_field(solr_doc, 'system_create', c_time, :stored_sortable)
  ActiveFedora.index_field_mapper.set_field(solr_doc, 'system_modified', m_time, :stored_sortable)
  solr_doc[QueryResultBuilder::HAS_MODEL_SOLR_FIELD] = object.has_model
  solr_doc[ActiveFedora.id_field.to_sym] = object.id
  object.declared_attached_files.each do |name, file|
    solr_doc.merge! file.to_solr(solr_doc, name: name.to_s)
  end
  solr_doc = solrize_rdf_assertions(solr_doc)
  yield(solr_doc) if block_given?
  solr_doc
end

#rdf_serviceObject



26
27
28
# File 'lib/active_fedora/indexing_service.rb', line 26

def rdf_service
  RDF::IndexingService
end