Class: ActiveFedora::IndexingService

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

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, #[])


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

def initialize(obj)
  @object = obj
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



3
4
5
# File 'lib/active_fedora/indexing_service.rb', line 3

def object
  @object
end

Class Method Details

.profile_solr_nameObject



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

def self.profile_solr_name
  @profile_solr_name ||= ActiveFedora::SolrQueryBuilder.solr_name("object_profile", :displayable)
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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/active_fedora/indexing_service.rb', line 28

def generate_solr_document
  solr_doc = {}
  Solrizer.set_field(solr_doc, 'system_create', c_time, :stored_sortable)
  Solrizer.set_field(solr_doc, 'system_modified', m_time, :stored_sortable)
  Solrizer.set_field(solr_doc, 'active_fedora_model', object.class.inspect, :stored_sortable)
  solr_doc.merge!(QueryResultBuilder::HAS_MODEL_SOLR_FIELD => object.has_model)
  solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => object.id)
  solr_doc.merge!(self.class.profile_solr_name => profile_service.new(object).export)
  object.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

#profile_serviceObject



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

def profile_service
  ProfileIndexingService
end

#rdf_serviceObject



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

def rdf_service
  RDF::IndexingService
end