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

Object must respond to

create_date
modified_date
has_model
id
to_json
attached_files
[]

and it’s class must respond to

inspect
outgoing_reflections


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

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



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

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



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

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_relationships(solr_doc)
  solr_doc = solrize_rdf_assertions(solr_doc)
  yield(solr_doc) if block_given?
  solr_doc
end

#profile_serviceObject



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

def profile_service
  ProfileIndexingService
end

#rdf_serviceObject



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

def rdf_service
  RDF::IndexingService
end