Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a service object for indexing profile json documents #655

Merged
merged 1 commit into from
Dec 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/active_fedora.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ module ActiveFedora #:nodoc:
autoload :NomDatastream
autoload :NullRelation
autoload :OmDatastream
autoload :Property
autoload :Persistence
autoload :ProfileIndexingService
autoload :Property
autoload :QualifiedDublinCoreDatastream
autoload :Querying
autoload :QueryResultBuilder
Expand Down
6 changes: 5 additions & 1 deletion lib/active_fedora/indexing_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def self.profile_solr_name
@profile_solr_name ||= ActiveFedora::SolrQueryBuilder.solr_name("object_profile", :displayable)
end

def profile_service
ProfileIndexingService
end


def generate_solr_document
solr_doc = {}
Expand All @@ -28,7 +32,7 @@ def generate_solr_document
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 => object.to_json)
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
Expand Down
11 changes: 11 additions & 0 deletions lib/active_fedora/profile_indexing_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ActiveFedora
class ProfileIndexingService
def initialize(object)
@object = object
end

def export
@object.serializable_hash.to_json
end
end
end