Class: ActiveFedora::IndexingService
- Inherits:
-
Object
- Object
- ActiveFedora::IndexingService
- 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
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
-
#generate_solr_document {|Hash| ... } ⇒ Hash
Creates a solr document hash for the #object.
-
#initialize(obj) ⇒ IndexingService
constructor
The class of obj must respond to these methods: inspect outgoing_reflections.
- #rdf_service ⇒ Object
Constructor Details
#initialize(obj) ⇒ IndexingService
The class of obj must respond to these methods:
inspect
outgoing_reflections
14 15 16 |
# File 'lib/active_fedora/indexing_service.rb', line 14 def initialize(obj) @object = obj end |
Instance Attribute Details
#object ⇒ Object (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_name ⇒ Object
22 23 24 |
# File 'lib/active_fedora/indexing_service.rb', line 22 def self.create_time_solr_name @create_time_solr_name ||= ActiveFedora::SolrQueryBuilder.solr_name('system_create', :stored_sortable, type: :date) end |
.modified_time_solr_name ⇒ Object
26 27 28 |
# File 'lib/active_fedora/indexing_service.rb', line 26 def self.modified_time_solr_name @modified_time_solr_name ||= ActiveFedora::SolrQueryBuilder.solr_name('system_modified', :stored_sortable, type: :date) end |
.profile_solr_name ⇒ Object
18 19 20 |
# File 'lib/active_fedora/indexing_service.rb', line 18 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
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/active_fedora/indexing_service.rb', line 37 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.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_service ⇒ Object
30 31 32 |
# File 'lib/active_fedora/indexing_service.rb', line 30 def rdf_service RDF::IndexingService end |